/* ============================================
   MASTER RESPONSIVE FIX
   Ensures all screens auto-adapt properly
   This file MUST be loaded LAST in HTML
   ============================================ */

/* ============================================
   1. PREVENT HORIZONTAL SCROLL (CRITICAL)
   ============================================ */
html {
    max-width: 100vw !important;
}

body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

* {
    box-sizing: border-box !important;
}

/* ============================================
   2. MOBILE BASE FIXES (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {

    /* Container must not overflow */
    .container {
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        overflow-x: hidden !important;
    }

    /* ============================================
       COMPACT SECTION SPACING - Reduce gaps
       ============================================ */
    .concern-section {
        padding: 8px 0 !important;
        margin: 0 !important;
        background: #fff !important;
    }

    .product-section {
        padding: 12px 0 !important;
        margin: 0 !important;
    }

    .product-section.lightning-sale {
        padding-top: 8px !important;
    }

    .section-header {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 10px !important;
        margin-bottom: 12px !important;
        padding: 0 12px !important;
    }

    .section-title {
        font-size: 19px !important;
        margin-bottom: 0 !important;
        position: relative !important;
    }

    /* Hide underline on mobile for cleaner look with timer */
    .section-title::after {
        display: none !important;
    }

    .title-group {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
    }

    .timer-badge {
        font-size: 10px !important;
        padding: 4px 10px !important;
        margin: 0 !important;
        border-radius: 4px !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }

    .view-all {
        display: inline-block !important;
        padding: 6px 16px !important;
        border: 1px solid #2D5016 !important;
        border-radius: 50px !important;
        color: #2D5016 !important;
        -webkit-text-fill-color: #2D5016 !important;
        /* CRITICAL FIX: Ensure text is visible */
        font-size: 11px !important;
        font-weight: 700 !important;
        text-decoration: none !important;
        background: transparent !important;
        transition: all 0.3s ease !important;
        white-space: nowrap !important;
        margin: 0 !important;
    }

    .view-all::after {
        display: none !important;
        /* Remove old underline */
    }

    /* ============================================
       REAL STORIES SECTION - Compact
       ============================================ */
    .real-stories-section {
        padding: 15px 0 !important;
        margin: 0 !important;
    }

    .real-stories-header {
        margin-bottom: 10px !important;
        padding: 0 12px !important;
    }

    .real-stories-title {
        font-size: 18px !important;
    }

    .stories-scroll-container {
        gap: 12px !important;
        padding: 5px 12px 15px !important;
    }

    .story-card {
        min-width: 140px !important;
        width: 140px !important;
        gap: 4px !important;
    }

    .story-image-wrapper {
        margin-bottom: 4px !important;
        border-radius: 10px !important;
    }

    .story-stars {
        font-size: 12px !important;
    }

    .story-name {
        font-size: 12px !important;
        margin: 2px 0 !important;
    }

    .story-text {
        font-size: 11px !important;
        -webkit-line-clamp: 2 !important;
    }

    /* ============================================
       TRUST BADGES SECTION - Compact
       ============================================ */
    .trust-section,
    .trust-certifications-section {
        padding: 15px 0 !important;
        margin: 0 !important;
    }

    .trust-section .section-title,
    .trust-header h2 {
        font-size: 16px !important;
        margin-bottom: 5px !important;
    }

    .trust-section .section-subtitle,
    .trust-header p {
        font-size: 12px !important;
        margin-bottom: 10px !important;
    }

    .trust-badges-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
        padding: 0 10px !important;
    }

    .trust-cert-badge {
        padding: 10px 8px !important;
        border-radius: 10px !important;
    }

    .trust-cert-badge img {
        width: 40px !important;
        height: 40px !important;
        margin-bottom: 6px !important;
    }

    .trust-cert-badge h4 {
        font-size: 10px !important;
        margin-bottom: 2px !important;
    }

    .trust-cert-badge p {
        font-size: 8px !important;
        display: none !important;
    }

    /* LEFT ALIGN FOOTER ON MOBILE */
    .footer-brand-col,
    .footer-bottom,
    .partners-row,
    .partner-group,
    .policies-row,
    .policy-links {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        text-align: left !important;
        width: 100% !important;
    }

    .partner-logos {
        justify-content: flex-start !important;
    }

    .policy-links {
        gap: 10px !important;
    }

    /* COMPACT FOOTER SPACING ON MOBILE */
    .modern-footer {
        padding: 25px 0 15px !important;
    }

    .footer-top {
        margin-bottom: 20px !important;
        gap: 20px !important;
    }

    .footer-brand-col {
        margin-bottom: 20px !important;
    }

    .footer-logo {
        margin-bottom: 15px !important;
    }

    .footer-address {
        margin-bottom: 15px !important;
    }

    .contact-item {
        margin-bottom: 8px !important;
    }

    .footer-bottom {
        padding-top: 15px !important;
    }

    .partners-row {
        margin-bottom: 15px !important;
        padding-bottom: 15px !important;
        gap: 10px !important;
    }

    .policies-row {
        padding-top: 15px !important;
    }

    .link-group h4 {
        margin-bottom: 12px !important;
    }

    .link-group ul li {
        margin-bottom: 8px !important;
    }

    .footer-newsletter-col h4 {
        margin-bottom: 15px !important;
    }

    .newsletter-input-group {
        margin-bottom: 20px !important;
    }













    /* HIDE HAMBURGER/MENU ICON ON MOBILE - Using bottom nav instead */
    #mobileMenuToggle,
    .mobile-menu-toggle,
    .hamburger-icon,
    .mobile-menu-drawer,
    .mobile-menu-overlay,
    .nav-item[href*="menu"],
    .menu-toggle,
    .menu-icon,
    [class*="hamburger"],
    [class*="menu-toggle"] {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        z-index: -1 !important;
    }

    /* All images responsive */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Search bars must fit screen */
    .search-bar,
    .search-container,
    input[type="search"],
    input[type="text"] {
        max-width: 100% !important;
    }

    /* Tables responsive */
    table {
        display: block !important;
        overflow-x: auto !important;
        max-width: 100% !important;
    }

    /* Fixed width elements override */
    [style*="width:"],
    [style*="min-width:"] {
        max-width: 100% !important;
    }

    /* Flex items must wrap */
    .header-row,
    .nav-links,
    .footer-top,
    .partners-row {
        flex-wrap: wrap !important;
    }

    /* Header - logo and search side by side */
    /* Header - Single Line Layout: Logo | Search | Location */
    .header-main-row {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding: 8px 10px !important;
        align-items: center !important;
    }

    /* 1. Logo (Left) */
    .brand-logo {
        height: auto !important;
        flex-shrink: 0 !important;
        order: 1 !important;
        margin-right: 0 !important;
    }

    .brand-logo img {
        height: 32px !important;
        /* Compact */
        width: auto !important;
    }

    /* 2. Search (Center - Flexible) */
    .search-container {
        order: 2 !important;
        flex: 1 !important;
        /* Takes remaining space */
        width: auto !important;
        min-width: 0 !important;
        margin-top: 0 !important;
        position: relative !important;
    }

    /* CRITICAL: Disable transform on mobile to allow fixed child to be screen-relative */
    .search-container:focus-within {
        transform: none !important;
        box-shadow: none !important;
    }

    .search-icon {
        display: block !important;
        left: 10px !important;
        width: 14px !important;
        height: 14px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        color: #666 !important;
    }

    .search-container input {
        height: 36px !important;
        font-size: 13px !important;
        padding-left: 32px !important;
        /* Icon space */
        padding-right: 8px !important;
        width: 100% !important;
        border-radius: 6px !important;
    }

    /* Hide big search button */
    .search-button {
        display: none !important;
    }

    /* 3. Location (Right - Icon Only) */
    .header-actions-right {
        order: 3 !important;
        display: flex !important;
        margin-left: 0 !important;
        gap: 0 !important;
    }

    /* Hide Cart & Login (Moved to bottom nav) */
    .header-actions-right .action-link[href="cart.html"],
    .header-actions-right .login-dropdown-wrapper {
        display: none !important;
    }

    /* Compact Pincode/Location Button */
    .pincode-selector-btn {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        background: transparent !important;
        padding: 6px !important;
        width: 36px !important;
        height: 36px !important;
        border: none !important;
    }

    .pincode-selector-btn .action-text {
        display: none !important;
        /* Hide text, show icon only */
    }

    .pincode-selector-btn svg {
        width: 24px !important;
        height: 24px !important;
        stroke: #2D5016 !important;
    }

    /* Search Autocomplete - perfectly centered on SCREEN on mobile */
    .search-autocomplete {
        position: fixed !important;
        top: 105px !important;
        left: 4% !important;
        right: 4% !important;
        width: 92% !important;
        /* Fixed width percentage for perfect centering */
        max-width: none !important;
        max-height: 75vh !important;
        overflow-y: auto !important;
        z-index: 10005 !important;
        /* Higher z-index */
        background: white !important;
        border-radius: 16px !important;
        /* More rounded for premium feel */
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25) !important;
        /* Deeper shadow */
        transform: none !important;
        margin: 0 !important;
        padding: 15px !important;
    }

    .search-container.active .search-autocomplete,
    .search-container:focus-within .search-autocomplete {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .autocomplete-header {
        padding: 12px 15px !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        background: #f8f9fa !important;
        border-radius: 12px 12px 0 0 !important;
    }

    .autocomplete-item {
        display: flex !important;
        align-items: center !important;
        padding: 10px 15px !important;
        gap: 12px !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }

    .autocomplete-item:active {
        background: #e8f5e9 !important;
    }

    .item-img-wrapper {
        width: 45px !important;
        height: 45px !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        flex-shrink: 0 !important;
    }

    .item-img-wrapper img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    .item-info {
        flex: 1 !important;
    }

    .item-name {
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #333 !important;
        display: block !important;
    }

    .item-category {
        font-size: 12px !important;
        color: #888 !important;
    }

    .item-price {
        font-size: 14px !important;
        font-weight: 700 !important;
        color: #2d5016 !important;
    }

    .keyword-suggestions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px 15px !important;
        background: #f8f9fa !important;
    }

    .keyword-item {
        background: white !important;
        padding: 6px 12px !important;
        border-radius: 20px !important;
        font-size: 12px !important;
        border: 1px solid #ddd !important;
    }

    /* Hero Banner - proper slider for mobile */
    .hero-slider-section {
        overflow: hidden !important;
    }

    .hero-slider-container {
        overflow: hidden !important;
        position: relative !important;
    }

    .hero-slides {
        position: relative !important;
        overflow: hidden !important;
        min-height: 45vw !important;
    }

    /* All slides hidden by default */
    .hero-slide {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 45vw !important;
        opacity: 0 !important;
        visibility: hidden !important;
        background-size: 100% auto !important;
        background-position: top center !important;
        background-repeat: no-repeat !important;
        transition: opacity 0.5s ease !important;
    }

    /* Only active slide visible */
    .hero-slide.active {
        opacity: 1 !important;
        visibility: visible !important;
        z-index: 2 !important;
    }

    /* Slider arrows - hide on mobile */
    .slider-arrow {
        display: none !important;
    }

    /* Slider dots - hide on mobile */
    .slider-dots {
        display: none !important;
    }

    /* Grid items single column on very small screens */
    .footer-links-col,
    .footer-brand-col,
    .footer-newsletter-col {
        min-width: 100% !important;
        width: 100% !important;
    }

    /* Review cards fit screen */
    .review-card,
    .story-card {
        min-width: auto !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* YouTube section responsive */
    .youtube-grid {
        grid-template-columns: 1fr !important;
    }

    .youtube-video iframe {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16/9 !important;
    }

    /* Policy links stack on mobile */
    .policy-links {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* Text sizing for readability */
    h1 {
        font-size: 24px !important;
    }

    h2 {
        font-size: 20px !important;
    }

    h3 {
        font-size: 18px !important;
    }

    /* CRITICAL: Fix account page sidebar layout with 280px grid */
    .account-layout,
    [style*="grid-template-columns: 280px"] {
        display: block !important;
        grid-template-columns: 1fr !important;
    }

    .account-sidebar {
        width: 100% !important;
        margin-bottom: 20px !important;
    }

    .account-content {
        width: 100% !important;
    }

    /* Address grid fix */
    #addressesList {
        grid-template-columns: 1fr !important;
    }

    /* Form inputs full width */
    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Order cards responsive */
    .order-detail-card {
        padding: 15px !important;
    }

    .order-header {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .order-footer {
        flex-direction: column !important;
        gap: 10px !important;
    }

    /* Promise grid on about page */
    .promise-grid {
        grid-template-columns: 1fr !important;
    }

    /* Contact layout */
    .contact-layout {
        display: block !important;
    }

    .contact-form-section,
    .contact-info-section {
        width: 100% !important;
    }

    /* Policy content */
    .policy-content {
        padding: 15px !important;
    }

    /* FAQ page */
    .faq-content {
        padding: 15px !important;
    }
}

/* ============================================
   3. SMALL PHONE FIXES (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {

    .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Product grid 2 columns */
    .products-row,
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* Buttons full width */
    .btn-primary,
    .btn-secondary,
    .add-to-cart-btn {
        width: 100% !important;
        text-align: center !important;
    }

    /* YouTube buttons stack */
    .youtube-buttons {
        flex-direction: column !important;
        gap: 10px !important;
    }

    /* Concern pills compact */
    .concern-flex-wrapper {
        gap: 8px !important;
    }

    .concern-pill {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }

    /* ============================================
       PRODUCT CARD FIX - Prevent Text/Image Cutoff
       ============================================ */

    /* Product section container - proper padding */
    .product-section {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .product-section .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Product grid - no negative margins */
    .products-row,
    .product-grid {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Each product card - must fit properly */
    .product-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    /* Product title - prevent cutoff */
    .product-title {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
    }

    /* Product info section */
    .product-info {
        width: 100% !important;
        max-width: 100% !important;
        padding: 8px !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    /* Product image wrapper */
    .product-image-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    /* Product image */
    .product-image-wrapper img,
    .product-image {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
    }

    /* Price row */
    .price-row,
    .product-price {
        width: 100% !important;
        overflow: hidden !important;
    }

    /* USP and rating text */
    .product-usp,
    .product-rating {
        width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    /* Lightning sale section specific fix */
    .lightning-sale .products-row {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* ============================================
   4. EXTRA SMALL PHONE FIXES (max-width: 375px)
   ============================================ */
@media (max-width: 375px) {

    /* Even smaller padding */
    .container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Smaller product cards */
    .product-card {
        border-radius: 8px !important;
    }

    .product-title {
        font-size: 12px !important;
    }

    .product-price {
        font-size: 14px !important;
    }

    /* Header logo smaller */
    .brand-logo img,
    .logo-img {
        height: 28px !important;
    }
}

/* ============================================
   5. LANDSCAPE MODE FIXES
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {

    .hero-slide,
    .hero-slider-section,
    .hero-banner {
        max-height: 200px !important;
        min-height: 150px !important;
    }
}

/* ============================================
   6. SAFE AREA SUPPORT (iPhone X+)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }

    body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }
}