/* ============================================================
   ZENTHRIX — MOBILE RESPONSIVE STYLES
   Covers all breakpoints: 320px → 768px (mobile), 769px → 1024px (tablet)
   ============================================================ */

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

/* Never allow horizontal scroll / content cut off on phones */
html, body { max-width: 100%; overflow-x: hidden; }

img { max-width: 100%; height: auto; }

/* Cart button — always visible on all screen sizes */
.mobile-cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 22px;
    color: white;
    text-decoration: none;
    width: 44px;
    height: 44px;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
@media (max-width: 768px) {
    nav {
        padding: 12px 16px;
        position: fixed;
        width: 100%;
        top: 0;
        z-index: 9000;
    }

    .nav-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;
    }

    /* Hide desktop nav links */
    .nav-links {
        display: none !important;
    }

    /* Logo */
    .logo-text {
        font-size: 18px;
    }

    /* Hamburger */
    .menu-toggle {
        display: flex;
        order: 3;
        z-index: 9100;
    }

    /* Cart icon — always visible, sits between logo and hamburger */
    .mobile-cart-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: relative;
        font-size: 22px;
        color: white;
        text-decoration: none;
        width: 44px;
        height: 44px;
        order: 2;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-cart-btn .icon-badge {
        position: absolute;
        top: 2px;
        right: 2px;
        background: #00e5ff;
        color: #000;
        font-size: 10px;
        font-weight: 700;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile nav drawer */
    .mobile-nav {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: #0a0a0a;
        border-left: 1px solid rgba(255,255,255,0.1);
        transition: right 0.3s ease;
        z-index: 9200;
        overflow-y: auto;
        /* Smaller top offset so the auth/logout button sits near the top,
           not below the fold on short phones */
        padding: 64px 0 32px;
    }

    .mobile-nav.open {
        right: 0;
    }

    .mobile-nav-links {
        list-style: none;
        padding: 0 24px;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .mobile-nav-links li a {
        display: block;
        color: rgba(255,255,255,0.8);
        text-decoration: none;
        font-size: 18px;
        font-weight: 600;
        padding: 13px 0;
        border-bottom: 1px solid rgba(255,255,255,0.08);
        transition: color 0.2s;
        letter-spacing: 0.05em;
    }

    .mobile-nav-links li a:hover,
    .mobile-nav-links li a.active {
        color: #00e5ff;
    }

    /* Auth buttons in drawer — sits right under the links, near the top,
       so the Logout button is visible without scrolling on any phone */
    .mobile-nav-auth {
        padding: 16px 24px 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 14px;
    }

    .mobile-nav-auth a {
        display: block;
        text-align: center;
        padding: 9px 14px;
        border-radius: 24px;
        font-weight: 600;
        text-decoration: none;
        font-size: 14px;
    }

    .mobile-nav-auth .btn-login {
        border: 1px solid rgba(255,255,255,0.3);
        color: white;
    }

    .mobile-nav-auth .btn-signup {
        background: #00e5ff;
        color: #000;
    }

    /* Logout — clearly visible red button at the bottom of the mobile menu */
    .mobile-nav-auth .btn-mobile-logout {
        display: block;
        text-align: center;
        padding: 12px;
        border-radius: 24px;
        font-weight: 700;
        font-size: 15px;
        text-decoration: none;
        background: rgba(255,77,77,0.12);
        border: 1.5px solid #ff4d4d;
        color: #ff4d4d;
        margin-top: 4px;
    }
    .mobile-nav-auth .btn-mobile-logout:active {
        background: #ff4d4d;
        color: #fff;
    }

    /* Overlay behind drawer */
    .mobile-nav-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.7);
        z-index: 9150;
    }

    .mobile-nav-overlay.open {
        display: block;
    }
}

/* ============================================================
   HERO / LANDING PAGE
   ============================================================ */
@media (max-width: 768px) {
    .hero-container {
        grid-template-columns: 1fr;
        padding: 100px 20px 60px;
        text-align: center;
        gap: 40px;
    }

    .hero-left {
        padding: 0;
    }

    .hero-title {
        font-size: clamp(32px, 9vw, 52px);
        line-height: 1.15;
    }

    .hero-subtitle {
        font-size: 15px;
    }

    .hero-stats {
        justify-content: center;
        gap: 24px;
        flex-wrap: wrap;
    }

    .stat-number {
        font-size: 26px;
    }

    .stat-label {
        font-size: 12px;
    }

    .hero-right {
        display: none;
    }

    .cta-group {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .cta-button {
        width: 100%;
        max-width: 280px;
        text-align: center;
        padding: 14px 24px;
        font-size: 14px;
    }
}

/* ============================================================
   STORE — PRODUCT GRID
   ============================================================ */
@media (max-width: 768px) {
    .collections,
    .store-section,
    .featured,
    .contact {
        padding: 80px 16px 50px;
    }

    /* "Digital Innovation" featured section — fit cleanly on any phone width */
    .featured-hero {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
        margin-bottom: 50px !important;
    }
    .featured-content {
        padding: 0 !important;            /* section already has side padding */
        max-width: 100%;
        min-width: 0;                    /* allow text to shrink/wrap */
    }
    .featured-content h2 {
        font-size: clamp(28px, 8vw, 40px) !important;
        letter-spacing: -1px;
        word-break: break-word;
    }
    .featured-content p {
        font-size: 15px !important;
        overflow-wrap: anywhere;         /* never overflow the screen edge */
    }
    /* Service cards stack in one column so nothing spills off-screen */
    .feature-highlights {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    .highlight-item {
        min-width: 0;
        width: 100%;
    }

    /* 2-column grid on mobile */
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .collection-card {
        -webkit-tap-highlight-color: rgba(0, 229, 255, 0.15);
        touch-action: manipulation;
    }

    .collection-thumbnail {
        height: 180px;
    }

    .collection-thumbnail img {
        object-fit: cover;
        width: 100%;
        height: 100%;
    }

    .card-content {
        padding: 12px;
    }

    .card-content h3 {
        font-size: 14px;
        margin-bottom: 4px;
    }

    .card-content .subtitle {
        font-size: 11px;
    }

    .card-content .price {
        font-size: 14px;
    }

    /* Category tabs — wrap to 2 rows so all 5 categories are always visible */
    .category-tabs,
    .filter-tabs {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding-bottom: 4px;
    }

    .tab-btn,
    .filter-btn {
        white-space: nowrap;
        flex: 0 0 auto;
        font-size: 13px;
        padding: 9px 14px;
        min-height: 40px;
    }

    /* Search + sort row */
    .search-sort-row,
    .store-controls {
        flex-direction: column;
        gap: 10px;
    }

    .search-sort-row input,
    .store-controls input {
        width: 100%;
    }

    .search-sort-row select,
    .store-controls select {
        width: 100%;
        font-size: 16px;
    }
}

@media (max-width: 380px) {
    /* Very small phones — still 2 col but tighter */
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .collection-thumbnail {
        height: 150px;
    }
}

/* ============================================================
   PRODUCT MODAL — FULL SCREEN ON MOBILE
   ============================================================ */
@media (max-width: 768px) {
    /* Modal backdrop fills screen and scrolls */
    .product-modal,
    .product-modal.active {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
        padding: 0 !important;
        align-items: unset !important;
        justify-content: unset !important;
    }

    .product-modal { display: none !important; }
    .product-modal.active { display: block !important; }

    /* Modal card fills screen — no centering, no transform */
    .product-modal .modal-content {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: none !important;
        min-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        display: flex;
        flex-direction: column;
    }

    .product-modal .modal-body {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 16px;
        overflow: visible;
        flex: 1;
    }

    /* Gallery image fills its square stage on mobile (no black gap) */
    .product-modal .modal-image { width: 100%; }
    .product-modal .gallery-stage {
        aspect-ratio: 1 / 1;
        width: 100%;
    }
    .product-modal #modalProductImage {
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        object-fit: cover !important;
        border-radius: 12px;
    }

    .product-modal .modal-info h2 {
        font-size: 20px;
        margin-top: 12px;
    }

    .product-modal .modal-close {
        top: 12px;
        right: 12px;
        width: 48px;
        height: 48px;
        font-size: 26px;
        z-index: 10;
    }

    .product-modal .modal-footer {
        padding: 16px;
        position: sticky;
        bottom: 0;
        background: #0a0a0a;
        border-top: 1px solid rgba(255,255,255,0.1);
        flex-shrink: 0;
        z-index: 5;
    }

    /* Give the reviews section breathing room so the sticky footer never overlaps it */
    .product-modal .modal-reviews {
        padding-bottom: 24px;
    }

    .product-modal .modal-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .product-modal .btn-add-to-cart,
    .product-modal .btn-buy-now {
        width: 100%;
        padding: 14px;
        font-size: 14px;
    }
}

/* ============================================================
   CART SIDEBAR
   ============================================================ */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh;
    }

    .cart-content {
        height: 100%;
    }

    .cart-items {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cart-item {
        padding: 12px;
        gap: 10px;
    }

    .cart-item-image {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }

    .cart-item-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 6px;
    }

    .cart-item-name {
        font-size: 13px;
    }

    .cart-item-price {
        font-size: 13px;
    }

    .cart-footer {
        padding: 16px;
        width: 100%;
    }

    .btn-checkout {
        display: block;
        width: 100%;
        box-sizing: border-box;
        padding: 15px;
        font-size: 15px;
        text-align: center;
        border-radius: 10px;
    }
}

/* ============================================================
   SERVICES PAGE
   ============================================================ */
@media (max-width: 768px) {
    .services-grid,
    .collection-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .service-card,
    .collection-card.service {
        padding: 24px 20px;
    }

    .get-a-quote-section,
    #get-a-quote {
        padding: 60px 16px 40px;
    }

    .quote-form-container {
        padding: 24px 16px;
    }

    .quote-form .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   CHECKOUT PAGE
   ============================================================ */
@media (max-width: 768px) {
    .checkout-container {
        padding: 74px 14px 32px;
    }
    .checkout-container h1 { font-size: 30px; margin-bottom: 16px; }

    .checkout-content {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .checkout-sidebar {
        order: -1;
        padding: 16px !important;
    }
    .checkout-sidebar h3 { font-size: 17px; margin-bottom: 10px; }

    /* The step cards (.checkout-step) already provide their own padding, so the
       wrapper must not add more — double padding was shoving the delivery
       content well to the right on phones. */
    .checkout-main { padding: 0 !important; background: transparent !important; }

    .form-row {
        grid-template-columns: 1fr;
    }

    /* Step indicators — compact horizontal pills, not big stacked boxes.
       Must force row direction to beat ecommerce-styles.css which sets
       flex-direction:column at this same breakpoint. */
    .checkout-steps {
        flex-direction: row !important;
        font-size: 12px;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
        margin-bottom: 20px !important;
    }
    .checkout-steps::before { display: none; } /* remove the connecting line on mobile */
    .step-indicator {
        padding: 7px 12px;
        flex: 0 0 auto;
        width: auto;
        border-radius: 20px;
        white-space: nowrap;
    }

    /* Review item — compact card */
    .checkout-item {
        gap: 10px;
        padding: 10px;
        align-items: center;
        margin-bottom: 8px;
    }
    .checkout-item img {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
        border-radius: 8px;
    }
    .checkout-item-info { min-width: 0; }
    .checkout-item-info h4 { font-size: 14px; margin-bottom: 2px; }
    .checkout-item-info p { font-size: 12px; margin: 1px 0; }
    .checkout-item-total { display: none; }

    .checkout-navigation {
        flex-direction: column;
        gap: 10px;
    }

    .checkout-navigation button {
        width: 100%;
    }

    /* Tighter delivery step — headings and method rows less spread out */
    .checkout-step { padding: 18px 16px !important; }
    .checkout-step h2 { font-size: 22px; margin-bottom: 14px; }
    #deliveryMethods { gap: 8px !important; }
    #deliveryMethods label { padding: 12px 14px !important; }

    .ikhokha-payment-info {
        padding: 20px 16px;
    }

    #placeOrderBtn {
        width: 100%;
        padding: 16px;
        font-size: 16px;
    }
}

/* ============================================================
   FOOTER
   ============================================================ */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 40px 20px;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 8px;
        padding: 20px;
        font-size: 13px;
    }
}

/* ============================================================
   TABLET (769px – 1024px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .hero-title {
        font-size: clamp(40px, 5vw, 64px);
    }

    .modal-content {
        max-width: 85vw;
    }

    .modal-body {
        grid-template-columns: 1fr 1fr;
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .checkout-content {
        grid-template-columns: 1fr 340px;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
@media (max-width: 768px) {
    /* Prevent iOS font size inflation */
    html {
        -webkit-text-size-adjust: 100%;
    }

    /* All inputs 16px to prevent iOS zoom */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Proper scroll padding for fixed nav */
    html {
        scroll-padding-top: 70px;
    }

    section {
        scroll-margin-top: 70px;
    }
}
