@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Sarabun:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #c5a880; /* Rose Gold / Gold tone */
    --primary-hover: #b0936b;
    --dark: #121214;
    --dark-surface: #1e1e24;
    --light: #f7f7f9;
    --border: #e2e8f0;
    --text-main: #1a202c;
    --text-muted: #718096;
    --danger: #e53e3e;
    --success: #38a169;
    --warning: #dd6b20;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --font-eng: 'Outfit', sans-serif;
    --font-th: 'Sarabun', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-th), var(--font-eng);
    background-color: #fafafb;
    color: var(--text-main);
    line-height: 1.6;
}

/* Header & Navigation */
header {
    background-color: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.logo {
    font-family: var(--font-eng);
    font-size: 24px;
    font-weight: 800;
    text-decoration: none;
    color: var(--dark);
    letter-spacing: 1px;
}

.logo span {
    color: var(--primary);
}

.nav-menu {
    display: flex;
    gap: 30px;
    list-style: none;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    transition: color 0.2s;
    font-size: 15px;
}

.nav-link:hover {
    color: var(--primary);
}

.nav-link.admin-btn {
    background-color: var(--dark);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
}

.nav-link.admin-btn:hover {
    background-color: var(--primary);
}

.cart-icon-wrapper {
    position: relative;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -10px;
    background-color: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Container */
.container {
    max-width: 1440px;
    margin: 30px auto;
    padding: 0 24px;
    width: 100%;
    box-sizing: border-box;
}

/* Main Shop Page (Index) Layout */
.shop-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 30px;
}

/* Filter Sidebar */
.filter-sidebar {
    background: white;
    border: 1px solid var(--border);
    padding: 25px;
    border-radius: var(--radius);
    height: fit-content;
}

.filter-section {
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}

.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

.filter-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    transition: color 0.2s;
}

.filter-links a.active, .filter-links a:hover {
    color: var(--primary);
    font-weight: 600;
}

.filter-options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Color Swatches inside filter */
.color-filter-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    cursor: pointer;
    position: relative;
}

.color-filter-btn.active::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

.size-filter-btn {
    border: 1px solid var(--border);
    background: white;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.size-filter-btn.active, .size-filter-btn:hover {
    border-color: var(--dark);
    background: var(--dark);
    color: white;
}

/* Price Range Input */
.price-range-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.price-range-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.filter-submit-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--dark);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 10px;
    transition: background-color 0.2s;
}

.filter-submit-btn:hover {
    background-color: var(--primary);
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 280px));
    gap: 25px;
}

.product-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 280px;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.product-card-img-wrapper {
    width: 100%;
    padding-top: 100%; /* 1:1 ratio for neat proportions */
    position: relative;
    background-color: #f8fafc;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.product-card-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Full image visible, no cropping */
    padding: 10px;
    transition: transform 0.4s ease;
}

.product-card:hover .product-card-img {
    transform: scale(1.05);
}

.product-card-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-card-cat {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.product-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.4;
    height: 44px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-card-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-card-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
}

/* Product Detail Page */
.product-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 480px) 1fr;
    gap: 40px;
    align-items: start;
}

/* Gallery Section */
.gallery-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 480px;
    width: 100%;
}

.gallery-main-wrapper {
    width: 100%;
    height: 440px;
    max-height: 450px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.gallery-main-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

.gallery-main-img:hover {
    transform: scale(1.03);
}

/* Horizontal Thumbnail Carousel with Arrow Navigation (< >) */
.gallery-thumbs-carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.gallery-thumbs-scroll-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 6px 2px;
    flex: 1;
    scrollbar-width: thin;
}

.gallery-thumbs-scroll-container::-webkit-scrollbar {
    height: 4px;
}

.gallery-thumbs-scroll-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.thumb-nav-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 32px;
    height: 85px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    cursor: pointer;
    z-index: 2;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
}

.thumb-nav-btn:hover {
    background: var(--dark);
    color: white;
    border-color: var(--dark);
}

.gallery-thumb-item {
    position: relative;
    width: 75px;
    height: 85px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.2s ease;
    pointer-events: all;
    z-index: 1;
    -webkit-user-select: none;
    user-select: none;
}

.gallery-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Full thumbnail picture visible, no cropping */
    padding: 3px;
    pointer-events: none; /* Prevent img from intercepting clicks meant for parent div */
}

.gallery-thumb-item.size-chart-thumb img {
    padding-bottom: 16px; /* Room for badge at bottom */
}

.gallery-thumb-item:hover, .gallery-thumb-item.active {
    border-color: #e53e3e !important; /* Bold Red/Orange focus outline like screenshot */
    box-shadow: 0 0 0 1px #e53e3e;
}

.gallery-thumb-item.size-chart-thumb {
    border-color: #3182ce;
}

.gallery-thumb-item.size-chart-thumb.active {
    border-color: #e53e3e !important;
}

.thumb-size-chart-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(26, 32, 44, 0.88);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    padding: 2px 0;
    pointer-events: none; /* Don't intercept clicks meant for parent div */
}

/* Detail Form Section */
.product-info-panel h1 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 10px;
}

.product-info-cat {
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
}

.product-info-price {
    font-size: 32px;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}

.variant-selector-group {
    margin-bottom: 25px;
}

.variant-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.variant-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.color-option-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px var(--border);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.color-option-btn.active {
    box-shadow: 0 0 0 2px var(--dark);
}

.size-option-btn {
    min-width: 46px;
    height: 40px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    transition: all 0.2s;
    position: relative;
}

.size-option-btn.active {
    border-color: var(--dark);
    background: var(--dark);
    color: white;
}

.size-option-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    background-color: #f7f7f9;
}

/* Strike-through for out-of-stock sizes */
.size-option-btn.out-of-stock::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 1px;
    background: var(--text-muted);
    transform: rotate(-45deg);
    top: 50%;
    left: 0;
}

/* Stock status tags */
.stock-status-tag {
    font-size: 13px;
    font-weight: 600;
}
.stock-status-tag.in-stock { color: var(--success); }
.stock-status-tag.low-stock { color: var(--warning); }
.stock-status-tag.out-stock { color: var(--danger); }

/* Size chart button */
.size-chart-link-btn {
    background: none;
    border: none;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin-top: 10px;
    margin-bottom: 25px;
    display: block;
}

/* Add to Cart button */
.add-to-cart-form {
    margin-top: 30px;
}

.add-to-cart-btn {
    width: 100%;
    padding: 16px;
    background: var(--dark);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
}

.add-to-cart-btn:hover {
    background-color: var(--primary);
}

.add-to-cart-btn:disabled {
    background-color: #cbd5e0;
    color: #718096;
    cursor: not-allowed;
}

.product-desc-box {
    margin-top: 40px;
    border-top: 1px solid var(--border);
    padding-top: 30px;
}

.product-desc-box h3 {
    margin-bottom: 15px;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-backdrop.open .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

/* Size chart table styling */
.size-chart-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.size-chart-table th, .size-chart-table td {
    padding: 12px 15px;
    border: 1px solid var(--border);
    text-align: center;
}

.size-chart-table th {
    background: var(--light);
    font-weight: 600;
}

/* Lightbox Image Preview */
.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Cart Page */
.cart-layout {
    display: grid;
    grid-template-columns: 1.6fr 0.9fr;
    gap: 40px;
}

.cart-items-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
}

.cart-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
}

.cart-item {
    display: flex;
    gap: 20px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-img {
    width: 80px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    background: #f7f7f9;
}

.cart-item-details {
    flex-grow: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--dark);
    margin-bottom: 5px;
}

.cart-item-variant {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Highlight Variant text in bold for error prevention */
.cart-item-variant strong {
    color: var(--dark);
    font-weight: 700;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.cart-item-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.cart-item-price {
    font-weight: 700;
    font-size: 16px;
}

/* Checkout Form Panel */
.checkout-panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    height: fit-content;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    margin-bottom: 15px;
}

.summary-row.total {
    border-top: 1px solid var(--border);
    padding-top: 15px;
    font-weight: 700;
    font-size: 20px;
    color: var(--dark);
    margin-bottom: 25px;
}

.checkout-form-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
}

.form-group textarea {
    height: 80px;
    resize: none;
}

.checkout-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
}

.checkout-btn:hover {
    background-color: var(--primary-hover);
}

/* Order Success Panel */
.success-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 600px;
    margin: 40px auto;
    padding: 40px;
    text-align: center;
}

.success-icon {
    font-size: 60px;
    color: var(--success);
    margin-bottom: 20px;
}

/* Admin Dashboard CSS */
.admin-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 30px;
}

.admin-menu-sidebar {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    height: fit-content;
}

.admin-menu-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    list-style: none;
}

.admin-menu-item a {
    display: block;
    padding: 12px 15px;
    text-decoration: none;
    color: var(--text-main);
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.admin-menu-item.active a, .admin-menu-item a:hover {
    background-color: var(--light);
    color: var(--primary);
}

/* Admin Panels */
.admin-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 30px;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 25px;
    display: flex;
    flex-direction: column;
}

.stat-title {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

/* Admin Tables */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.admin-table th, .admin-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.admin-table th {
    background: var(--light);
    font-weight: 600;
}

.admin-table tr:hover td {
    background-color: #fafafb;
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
    text-transform: uppercase;
}

.badge.pending { background: #fef3c7; color: #d97706; }
.badge.processing { background: #dbeafe; color: #2563eb; }
.badge.shipped { background: #dcfce7; color: #16a34a; }
.badge.cancelled { background: #fee2e2; color: #dc2626; }

/* Image upload styling in admin */
.admin-uploader-box {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    background: var(--light);
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.2s;
}

.admin-uploader-box:hover {
    border-color: var(--primary);
}

.admin-uploader-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.uploader-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    padding-top: 125%;
    background: white;
}

.uploader-preview-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.uploader-preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Attribute creator design */
.attributes-setup-section {
    background: var(--light);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.attributes-input-group {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

/* Variant matrix generator table inside form */
.variant-matrix-container {
    margin-top: 25px;
    border-top: 1px solid var(--border);
    padding-top: 25px;
}

.variant-matrix-table {
    width: 100%;
    border-collapse: collapse;
}

.variant-matrix-table th, .variant-matrix-table td {
    padding: 10px 12px;
    border: 1px solid var(--border);
}

.variant-matrix-table input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    outline: none;
}

/* Helper Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-size: 14px;
    transition: all 0.2s;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-dark {
    background-color: var(--dark);
    color: white;
}

.btn-dark:hover {
    background-color: #2d3748;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--light);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #c53030;
}

.flex-btn-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.grid-three-cols {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* ==========================================================================
   Responsive & Device Adaptations (รองรับการแสดงผลทุกหน้าจอ)
   ========================================================================== */

/* จอแท็บเล็ตและหน้าจอขนาดกลาง (ต่ำกว่า 1024px) */
@media screen and (max-width: 1024px) {
    .container {
        margin: 20px auto;
        padding: 0 16px;
    }
    
    .admin-layout {
        grid-template-columns: 1fr; /* ยุบ Sidebar ลงมาซ้อนแนวตั้ง */
        gap: 20px;
    }
    
    .shop-layout {
        grid-template-columns: 1fr;
    }
    
    .product-detail-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .cart-layout {
        grid-template-columns: 1fr;
    }
}

/* จอสมาร์ทโฟนและหน้าจอขนาดเล็ก (ต่ำกว่า 768px) */
@media screen and (max-width: 768px) {
    /* ปรับแต่งส่วนหัว (Header Navigation) */
    .nav-container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px 10px;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        width: 100%;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 14px;
    }

    /* แดชบอร์ดสถิติในหน้า Admin */
    .admin-stats-grid {
        grid-template-columns: 1fr; /* แสดงแถวละ 1 กล่องสถิติ */
        gap: 15px;
    }
    
    /* ป้องกันตารางหลังบ้านบีบตัวจนอ่านไม่ได้ (ทำให้ปัดซ้าย-ขวาได้) */
    .admin-card {
        padding: 20px 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .admin-table {
        min-width: 600px; /* บังคับขนาดตารางขั้นต่ำให้เลื่อนดูได้ ไม่บีบตัว */
    }

    /* ตารางตัวเลือก Variants ในหน้าเพิ่มสินค้า */
    .variant-matrix-table {
        min-width: 500px;
    }
    
    /* ปรับปรุงแผงกรอก Attributes */
    .attributes-input-group {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* ปรับฟอร์มข้อมูลสินค้าให้อ่านง่ายขึ้นบนมือถือ */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .grid-three-cols {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* ปรับปุ่มต่าง ๆ ให้ยืดเต็มหน้าจอ */
    .flex-btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .flex-btn-group .btn {
        width: 100%;
    }
    
    /* หน้ารายละเอียดสินค้าฝั่งลูกค้า */
    .gallery-container {
        flex-direction: column-reverse; /* ให้รูปย่อยลงไปอยู่ด้านล่างรูปใหญ่ */
    }
    
    .gallery-thumbs {
        flex-direction: row;
        overflow-x: auto;
        justify-content: center;
        width: 100%;
        margin-top: 10px;
    }
    
    .gallery-thumb-item {
        width: 70px;
        height: 70px;
    }
}

/* จอโทรศัพท์มือถือขนาดเล็กมาก (ต่ำกว่า 480px) */
@media screen and (max-width: 480px) {
    h1 {
        font-size: 20px !important;
    }
    
    .admin-card h2 {
        font-size: 16px !important;
    }
    
    .stat-value {
        font-size: 22px;
    }
}

/* Print Styling for Packing Slips */
@media print {
    body {
        background-color: white;
        color: black;
        font-size: 12pt;
    }

    header, 
    .nav-container, 
    .admin-menu-sidebar, 
    .btn, 
    .no-print {
        display: none !important;
    }

    .container, .admin-layout {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    .admin-card {
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
    }

    .packing-slip-header {
        border-bottom: 3px double #000;
        padding-bottom: 20px;
        margin-bottom: 30px;
    }

    /* Make color and size text HUGE and EXTRA BOLD to prevent packing errors */
    .print-bold-details {
        display: inline-block;
        border: 4px solid #000 !important;
        padding: 10px 15px !important;
        background-color: #e2e8f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        margin-top: 8px;
    }

    .print-bold-details strong {
        font-size: 26px !important;
        font-weight: 900 !important;
        font-family: sans-serif !important;
        color: black !important;
    }

    .packing-slip-item {
        page-break-inside: avoid;
        border-bottom: 2px dashed #000 !important;
        padding: 20px 0 !important;
    }
}
