/* =====================================================================
   RM Packaging — Responsive Breakpoints (Premium)
   ===================================================================== */

/* =============== GLOBAL BASE (DESKTOP) =============== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--paper, #fff);
    border-bottom: 1px solid var(--ink-100, #eee);
    height: var(--header-h, 64px);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 var(--sp-4, 16px);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2, 8px);
    text-decoration: none;
    color: var(--ink-900, #111);
    font-weight: var(--fw-bold, 700);
    font-size: 1.25rem;
    z-index: 102;
}

.brand-mark {
    background: var(--brand-500, #e86e0f);
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: var(--r-sm, 6px);
    font-size: 0.9rem;
}

/* Desktop Nav */
.nav-menu {
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-list {
    display: flex;
    align-items: center;
    gap: var(--sp-6, 24px);
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list a {
    text-decoration: none;
    color: var(--ink-600, #555);
    font-size: var(--fs-sm, 14px);
    font-weight: var(--fw-medium, 500);
    transition: color 0.2s ease;
}

.nav-list a:hover,
.nav-list a.is-active {
    color: var(--brand-600, #c25a0a);
}

.nav-actions-desktop {
    display: flex;
    align-items: center;
    gap: var(--sp-2, 8px);
}

.nav-actions-mobile { display: none; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--ink-900, #111);
    cursor: pointer;
    padding: var(--sp-2, 8px);
    z-index: 102;
}

/* Backdrop */
.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
    z-index: 98;
}

.nav-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 8px;
    background: #000;
    color: #fff;
    z-index: 9999;
}
.skip-link:focus { left: 8px; }

/* =============== TABLET (< 992px) =============== */
@media (max-width: 991.98px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .product-detail { grid-template-columns: 1fr; }
    .product-gallery { position: static; }

    /* Show Hamburger */
    .nav-toggle { display: flex; align-items: center; justify-content: center; }
    .nav-actions-desktop { display: none; }

    /* Mobile Menu Drawer */
    .nav-menu {
        position: fixed;
        top: var(--header-h, 64px);
        left: 0;
        right: 0;
        height: calc(100vh - var(--header-h, 64px));
        background: var(--paper, #fff);
        flex-direction: column;
        align-items: stretch;
        padding: var(--sp-4, 16px);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease, visibility 0.35s;
        overflow-y: auto;
        z-index: 99;
    }

    .nav-menu.is-open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
    }

    .nav-list a {
        display: block;
        padding: var(--sp-4, 16px) 0;
        border-bottom: 1px solid var(--ink-100, #eee);
        font-size: var(--fs-lg, 18px);
        color: var(--ink-800, #333);
    }

    /* Show mobile actions */
    .nav-actions-mobile {
        display: flex;
        flex-direction: column;
        gap: var(--sp-3, 12px);
        margin-top: var(--sp-6, 24px);
    }

    /* Admin sidebar */
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
        z-index: 90;
    }
    .admin-layout.sidebar-open .admin-sidebar { transform: translateX(0); }
    .admin-layout.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 80;
    }
    .admin-main { margin-left: 0 !important; }
    .admin-search { display: none; }

    /* Hero */
    .hero-slide { min-height: 400px; padding: 4rem 0; }
    .cta-banner { flex-direction: column; text-align: center; padding: 2rem 1rem; gap: 1rem; }
}

/* =============== MOBILE (< 768px) =============== */
@media (max-width: 767.98px) {
    
    /* 🟢 THE 2-PRODUCT GRID FIX 🟢 */
    .product-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
        padding: 10px !important;
        width: 100% !important;
    }

    .product-grid.grid-2, 
    .product-grid.grid-3, 
    .product-grid.grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    /* Tweak product card for mobile 2-up */
    .product-card-title { font-size: 12px; }
    .product-card-desc { font-size: 10px; }
    .product-card .price-range--sm .price-min, 
    .product-card .price-range--sm .price-max { font-size: 13px; }
    .product-card .product-card-cta { width: 100%; font-size: 11px; }

    /* Sections & Typography */
    .section { padding: 2.5rem 0; }
    .section-sm { padding: 2rem 0; }
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    p { max-width: 100%; }

    /* Hero */
    .hero-slide { min-height: 340px; padding: 3rem 0; }
    .hero-content h1 { font-size: 1.9rem; line-height: 1.15; }
    .hero-content p { font-size: var(--fs-base); max-width: 100%; }

    /* Product Gallery & Actions */
    .product-gallery-thumbs { grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
    .product-actions { flex-wrap: wrap; gap: var(--sp-2); }
    .product-actions .btn { flex: 1 1 100%; justify-content: center; }

    /* Tables */
    .table-wrap { overflow-x: auto; border-radius: var(--r-md); }
    .table { min-width: 560px; }
    .table th, .table td { padding: 0.65rem 0.75rem; font-size: var(--fs-xs); white-space: nowrap; }

    /* Page Header */
    .page-header { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
    .page-actions { width: 100%; display: flex; gap: var(--sp-2); }
    .page-actions .btn { flex: 1; }

    /* Filter Bar */
    .filter-bar { flex-direction: column; gap: var(--sp-2); }
    .filter-bar .form-control, .filter-bar .form-select { max-width: none; width: 100%; }

    /* Admin */
    .admin-content { padding: var(--sp-4); }
    .admin-topbar { padding: 0 var(--sp-4); gap: var(--sp-2); }
    .admin-topbar-title { font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
    .kpi-value { font-size: var(--fs-2xl); }
    .kpi-icon { width: 36px; height: 36px; font-size: 1rem; }
    .contact-form-wrap { padding: var(--sp-5); border-radius: var(--r-lg); }
    .site-footer { padding-top: var(--sp-10); }
}

/* =============== SMALL MOBILE (< 480px) =============== */
@media (max-width: 479.98px) {
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.1rem; }

    .container { padding: 0 var(--sp-4); }
    .kpi-grid { grid-template-columns: 1fr; }
    .hero-content h1 { font-size: 1.5rem; }
    .hero-content p { font-size: var(--fs-sm); }

    .btn { padding: 0.6rem 1rem; font-size: var(--fs-xs); gap: var(--sp-1); }
    .btn-lg { padding: 0.85rem 1.25rem; font-size: var(--fs-sm); }
    .btn-sm { padding: 0.4rem 0.85rem; font-size: 0.65rem; }

    .product-actions { flex-direction: column; }
    .product-actions .btn { width: 100%; }

    .admin-topbar-right { gap: var(--sp-2); }
    .user-chip span { display: none; }
    .user-chip { padding: var(--sp-1); }

    .table th, .table td { padding: 0.5rem; font-size: 0.72rem; }

    .pagination { flex-wrap: wrap; justify-content: center; gap: var(--sp-1); }
    .pagination a, .pagination span { min-width: 34px; height: 34px; font-size: var(--fs-xs); }

    .modal-content, .dialog-content { padding: var(--sp-5); border-radius: var(--r-md); }
    .filter-bar { gap: var(--sp-1); }
}

/* =============== TOUCH TARGETS =============== */
@media (hover: none) {
    .btn { min-height: 42px; }
    .icon-btn { min-height: 42px; min-width: 42px; }
    .nav-list a { min-height: 42px; display: flex; align-items: center; }
    .pagination a, .pagination span { min-width: 42px; min-height: 42px; }
    .form-control, .form-select { min-height: 44px; }
    .btn:hover, .product-card:hover, .icon-btn:hover { transform: none; }
}

/* =============== LANDSCAPE MOBILE =============== */
@media (max-width: 900px) and (orientation: landscape) {
    .hero-slide { min-height: 300px; padding: var(--sp-10) 0; }
    .hero-content h1 { font-size: 1.8rem; }
    .nav-menu { max-height: calc(100vh - var(--header-h)); }
}

/* =============== REDUCED MOTION =============== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .btn:hover, .product-card:hover { transform: none; }
}

/* =============== PRINT =============== */
@media print {
    .site-header, .site-footer, .no-print { display: none !important; }
    .admin-sidebar, .admin-topbar { display: none !important; }
    .admin-main { margin-left: 0 !important; }
    body { background: #fff !important; color: #000 !important; }
    .btn, .card, .product-card, .table-wrap { box-shadow: none !important; border: 1px solid #ccc !important; }
    .table { min-width: 0; }
    .table th, .table td { font-size: 9pt; padding: 4pt 6pt; white-space: normal; }
    a[href]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
    .page-break { page-break-before: always; }
    .no-break { page-break-inside: avoid; }
}