/* ===================================================================
   UNIVERSAL PRODUCTS — Master Responsive Engine
   Complete device optimization: Mobile (320px-576px), Tablet (768px-1024px), Desktop (1200px+)
   =================================================================== */

/* ===================================================================
   1. GLOBAL FLUID RESETS & CONTAINER SAFETY
   =================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    min-width: 320px;
}

img, picture, video, canvas, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent layout breaking on any device */
.catalog-container,
.header-container,
.top-bar-container,
.footer-container {
    width: 100%;
    max-width: 1320px;
    margin-left: auto;
    margin-right: auto;
}

/* ===================================================================
   2. DESKTOP & LARGE SCREENS (>= 1280px)
   =================================================================== */
@media (min-width: 1280px) {
    .catalog-container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 2rem;
    }
}

/* ===================================================================
   3. LAPTOPS & SMALL DESKTOPS (1025px - 1279px)
   =================================================================== */
@media (max-width: 1279px) {
    .nav-menu {
        gap: 1.2rem;
    }
    
    .nav-link {
        font-size: 0.82rem;
    }
    
    .header-actions .btn-brass,
    .header-actions .btn-outline-brass {
        padding: 0.55rem 1.1rem;
        font-size: 0.8rem;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
        gap: 1.5rem;
    }
}

/* ===================================================================
   4. TABLETS & IPADS (769px - 1024px)
   =================================================================== */
@media (max-width: 1024px) {
    /* Hide desktop nav, reveal mobile toggle */
    .nav-menu,
    .header-actions {
        display: none !important;
    }

    .mobile-toggle {
        display: flex !important;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: rgba(197, 155, 81, 0.12);
        border: 1px solid rgba(197, 155, 81, 0.3);
        border-radius: 10px;
        color: var(--foundry-brass);
        font-size: 1.2rem;
        cursor: pointer;
        transition: all 0.25s ease;
    }

    .mobile-toggle:hover {
        background: rgba(197, 155, 81, 0.22);
    }

    .top-bar-container {
        padding: 0.4rem 1.25rem;
        font-size: 0.72rem;
    }

    .hero-stats-row {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .hero-stats-row > div[style*="width: 1px"] {
        display: none !important;
    }

    .brands-grid-layout {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .footer-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 2.5rem 2rem;
    }
}

/* ===================================================================
   5. MOBILE DEVICES (<= 768px) — FULL OPTIMIZATION
   =================================================================== */
@media (max-width: 768px) {
    /* ── Top Bar ── */
    .top-bar {
        padding: 0.35rem 0;
    }

    .top-bar-container {
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
        padding: 0.2rem 1rem;
    }

    .top-bar-info {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.6rem;
        font-size: 0.68rem;
    }

    /* ── Site Header ── */
    .site-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: rgba(14, 11, 8, 0.95) !important;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid rgba(197, 155, 81, 0.2);
    }

    .header-container {
        padding: 0.75rem 1rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .brand-title {
        font-size: 1.2rem;
        letter-spacing: 0.05em;
    }

    .brand-sub {
        font-size: 0.58rem;
        letter-spacing: 0.08em;
    }

    /* ── Mobile Drawer ── */
    .mobile-drawer {
        width: 88%;
        max-width: 340px;
        padding: 2rem 1.5rem;
        padding-top: max(2rem, env(safe-area-inset-top));
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
        background: rgba(18, 14, 11, 0.98);
        backdrop-filter: blur(20px);
        border-left: 1px solid rgba(197, 155, 81, 0.3);
    }

    .drawer-header {
        margin-bottom: 1.5rem;
        padding-bottom: 0.8rem;
    }

    .drawer-close {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.06);
        color: #fff;
        border: 1px solid rgba(197, 155, 81, 0.2);
        cursor: pointer;
    }

    .mobile-nav-list {
        gap: 0.9rem;
        overflow-y: auto;
        max-height: calc(100vh - 220px);
    }

    .mobile-nav-link {
        font-size: 1.05rem;
        padding: 0.4rem 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    /* ── Hero Section ── */
    .hero-scroll-container {
        padding-top: 2rem;
        padding-bottom: 3rem;
    }

    .hero-content {
        padding: 0 1rem;
    }

    .hero-eyebrow {
        font-size: 0.65rem;
        letter-spacing: 0.12em;
        padding: 0.4rem 0.85rem;
        white-space: normal;
        text-align: center;
        line-height: 1.4;
    }

    .hero-title {
        font-size: clamp(2rem, 8vw, 2.75rem);
        line-height: 1.15;
        letter-spacing: -0.02em;
        margin: 1rem 0;
    }

    .hero-subtitle {
        font-size: 0.92rem;
        line-height: 1.65;
        margin-bottom: 1.75rem;
    }

    /* Hero Stats Row — Responsive Grid */
    .hero-stats-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.85rem;
        padding: 1.25rem 1rem;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(197, 155, 81, 0.2);
        border-radius: 16px;
        margin-bottom: 2rem;
    }

    .hero-stats-row > div[style*="width: 1px"] {
        display: none !important;
    }

    .hero-stat-item {
        display: flex;
        align-items: center;
        gap: 0.85rem;
    }

    .hero-stat-item i {
        font-size: 1.35rem;
        color: var(--foundry-brass);
        width: 32px;
        text-align: center;
        flex-shrink: 0;
    }

    .hero-stat-val {
        font-size: 0.95rem;
        font-weight: 700;
        color: #fff;
    }

    .hero-stat-lbl {
        font-size: 0.72rem;
        color: var(--text-dim-dark);
    }

    /* Hero CTA Button Stack */
    .hero-cta-group {
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
        width: 100%;
        margin-bottom: 2.5rem;
    }

    .hero-cta-group .btn-brass,
    .hero-cta-group .btn-outline-brass {
        width: 100%;
        min-height: 48px;
        justify-content: center;
        font-size: 0.92rem;
        padding: 0.85rem 1.5rem;
    }

    /* Room Fill Stage — Mobile Responsive Aspect Ratio */
    .room-fill-stage {
        height: auto !important;
        aspect-ratio: 4 / 3 !important;
        min-height: 280px;
        padding: 0.85rem !important;
        border-radius: 16px !important;
    }

    .stage-controls-pills {
        overflow-x: auto;
        white-space: nowrap;
        display: flex;
        gap: 0.45rem;
        padding-bottom: 0.35rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .stage-controls-pills::-webkit-scrollbar {
        display: none;
    }

    .stage-pill-btn {
        font-size: 0.65rem;
        padding: 0.35rem 0.75rem;
        flex-shrink: 0;
    }

    .stage-badge {
        padding: 0.6rem 0.85rem;
        border-radius: 10px;
        gap: 0.6rem;
    }

    .stage-badge i {
        font-size: 1.1rem !important;
    }

    .stage-badge > div > div:first-child {
        font-size: 0.78rem !important;
    }

    .stage-badge > div > div:last-child {
        font-size: 0.65rem !important;
    }

    /* ── Catalog Toolbar & Filters ── */
    .catalog-section {
        padding: 3.5rem 1rem !important;
    }

    .catalog-toolbar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
        margin-bottom: 2rem;
    }

    .catalog-toolbar > div:first-child {
        text-align: center;
    }

    .catalog-toolbar > div:first-child h2 {
        font-size: 1.85rem !important;
    }

    .catalog-toolbar > div:last-child {
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
        width: 100%;
    }

    .filter-pills {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        gap: 0.5rem;
        padding: 0.25rem 0.25rem 0.5rem 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        justify-content: flex-start;
    }

    .filter-pills::-webkit-scrollbar {
        display: none;
    }

    .filter-btn {
        font-size: 0.72rem;
        padding: 0.45rem 1rem;
        flex-shrink: 0;
        border-radius: 9999px;
    }

    .search-box {
        width: 100% !important;
        min-width: 100% !important;
    }

    .search-input {
        width: 100%;
        padding: 0.65rem 1rem 0.65rem 2.4rem;
        font-size: 0.88rem;
        border-radius: 12px;
    }

    /* ── Product Grid ── */
    .product-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    .product-media {
        aspect-ratio: 1152 / 841 !important;
        height: auto !important;
    }

    .product-card .product-body {
        padding: 1.15rem 1.15rem 1.25rem !important;
    }

    .product-card .product-title {
        font-size: 1.15rem !important;
    }

    .product-card .product-footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .product-card .btn-wa-sm {
        padding: 0.55rem 1rem !important;
        font-size: 0.75rem !important;
        min-height: 42px;
    }

    /* ── Product Detail Modal — Bottom Sheet on Mobile ── */
    #product-detail-modal {
        padding: 0 !important;
        align-items: flex-end !important;
    }

    #product-detail-modal .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        border-radius: 24px 24px 0 0 !important;
        border-bottom: none !important;
        margin: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    #product-modal-body {
        padding: 1.5rem 1.2rem 2rem !important;
    }

    #product-modal-body > div {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    #modal-main-image {
        height: 250px !important;
    }

    #product-modal-body h2 {
        font-size: 1.45rem !important;
    }

    #close-product-modal {
        top: 1rem !important;
        right: 1rem !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 1.25rem !important;
        background: rgba(0, 0, 0, 0.7) !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 10 !important;
    }

    /* ── Brands & Feature Cards ── */
    .brands-grid-layout {
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }

    .brand-card {
        padding: 1.5rem 1.25rem !important;
    }

    /* ── Configurator Banner ── */
    .configurator-section {
        padding: 3rem 1rem !important;
    }

    .configurator-section > div > div {
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: center;
        gap: 1.75rem !important;
    }

    .configurator-section h2 {
        font-size: 1.75rem !important;
    }

    .configurator-section .font-spec {
        justify-content: center;
    }

    .configurator-section .btn-brass {
        width: 100%;
        justify-content: center;
        min-height: 48px;
    }

    /* ── Comparison Table ── */
    .comparison-table-wrap {
        border-radius: 12px;
        margin: 0 -0.5rem;
    }

    .comparison-table-wrap table {
        font-size: 0.8rem;
    }

    .comparison-table-wrap th,
    .comparison-table-wrap td {
        padding: 0.75rem 0.65rem;
        white-space: normal;
    }

    /* ── Reviews Grid ── */
    .reviews-grid,
    main > section > div > div[style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    /* ── Footer ── */
    .site-footer {
        padding: 3.5rem 1rem 2rem !important;
    }

    .footer-container {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        text-align: left;
    }

    .footer-bottom {
        flex-direction: column !important;
        gap: 0.85rem !important;
        text-align: center !important;
        padding-top: 1.5rem !important;
    }

    /* ── Floating WhatsApp Button & Back-to-Top ── */
    .whatsapp-float-widget {
        bottom: max(1.25rem, env(safe-area-inset-bottom) + 0.75rem) !important;
        right: 1.25rem !important;
        padding: 0.85rem !important;
        border-radius: 50% !important;
    }

    .whatsapp-float-widget .whatsapp-text {
        display: none !important;
    }

    .scroll-to-top-btn {
        bottom: max(1.25rem, env(safe-area-inset-bottom) + 0.75rem) !important;
        left: 1.25rem !important;
        width: 42px !important;
        height: 42px !important;
    }
}

/* ===================================================================
   6. SMALL PHONES (<= 380px, e.g. iPhone SE, Galaxy Fold)
   =================================================================== */
@media (max-width: 380px) {
    .brand-title {
        font-size: 1.05rem;
    }

    .brand-sub {
        display: none;
    }

    .hero-title {
        font-size: 1.85rem;
    }

    .product-media {
        aspect-ratio: 1152 / 841 !important;
        height: auto !important;
    }

    .product-card .price-selling {
        font-size: 1.2rem !important;
    }

    .product-card .price-mrp {
        font-size: 0.78rem !important;
    }

    .product-card .product-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .product-card .btn-wa-sm {
        width: 100%;
        justify-content: center;
    }
}

/* ===================================================================
   7. TOUCH DEVICE INTERACTION POLISH
   =================================================================== */
@media (hover: none) and (pointer: coarse) {
    /* Eliminate hover stickiness on touch devices */
    .product-card:hover {
        transform: none !important;
    }

    .product-card:active {
        transform: scale(0.985) !important;
        transition: transform 0.15s ease !important;
    }

    .btn-brass:active,
    .btn-outline-brass:active,
    .btn-wa-sm:active {
        transform: scale(0.96) !important;
        transition: transform 0.1s ease !important;
    }

    /* Make Quick View badge always visible or accessible on mobile */
    .quick-view-badge {
        opacity: 0.9 !important;
        transform: none !important;
        font-size: 0.62rem !important;
        padding: 0.25rem 0.6rem !important;
        bottom: 0.65rem !important;
        right: 0.65rem !important;
    }
}
