/* Global Responsive Optimizations for Klarris Pharma */

:root {
    --primary-pink: #c31f7e;
    --primary-pink-light: #fdf2f8;
}

/* 0. Global Layout & Reset */
html, body {
    overflow-x: hidden !important;
    position: relative !important;
    width: 100% !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

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

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

/* 1. Fluid Typography & Global improvements */
:root {
    --primary-pink: #c31f7e;
    --primary-pink-dark: #9d174d;
    --primary-pink-light: rgba(195,31,126,0.1);
}

.mobile-header-text {
    display: none;
}

@media (max-width: 768px) {
    /* Fluid typography using clamp */
    h1 { font-size: clamp(2rem, 8vw, 3rem) !important; line-height: 1.1 !important; letter-spacing: -0.02em !important; }
    h2 { font-size: clamp(1.5rem, 6vw, 2.2rem) !important; line-height: 1.2 !important; }
    h3 { font-size: clamp(1.25rem, 4vw, 1.75rem) !important; }
    p { font-size: 1rem !important; line-height: 1.6 !important; color: #4b5563; }
    
    .hero-gradient-text { 
        font-size: clamp(2.5rem, 10vw, 4rem) !important;
        background: linear-gradient(135deg, #c31f7e 0%, #db2777 50%, #9d174d 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        display: inline-block;
    }
}

.hero-gradient-text {
    background: linear-gradient(135deg, #c31f7e 0%, #db2777 50%, #9d174d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

@media screen and (max-width: 375px) {
    .text-3xl { font-size: 1.4rem !important; }
    .text-4xl { font-size: 1.6rem !important; }
    .text-5xl { font-size: 1.8rem !important; }
}

/* 2. Layout, Spacing & Container optimization */
@media (max-width: 768px) {
    section, .max-w-7xl, .container, .mx-auto {
        padding-left: clamp(1rem, 5vw, 2rem) !important;
        padding-right: clamp(1rem, 5vw, 2rem) !important;
    }
    
    /* Fluid spacing */
    .py-24, .py-28 { padding-top: clamp(4rem, 10vw, 6rem) !important; padding-bottom: clamp(4rem, 10vw, 6rem) !important; }
    .py-20 { padding-top: 3.5rem !important; padding-bottom: 3.5rem !important; }
    .py-12 { padding-top: 2.5rem !important; padding-bottom: 2.5rem !important; }
    
    .gap-12 { gap: 2rem !important; }
    .gap-16 { gap: 2.5rem !important; }
    
    /* Grid Stacking Compensation */
    .grid-cols-2, .grid-cols-3, .grid-cols-4, 
    .md\:grid-cols-2, .md\:grid-cols-3, .md\:grid-cols-4,
    .lg\:grid-cols-2, .lg\:grid-cols-3, .lg\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    
    /* Allow 2 columns on medium small screens for specific items like cards */
    .mobile-grid-2 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    .min-h-screen { min-height: auto !important; }
}

/* 3. Header & Navigation (Premium Overlay) */
@media (max-width: 992px) {
    #klarris-header {
        height: 72px !important;
        display: flex !important;
        align-items: center !important;
        padding: 0 !important; /* Remove outer padding */
    }

    #klarris-header > div {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 0.75rem !important; /* Tighten inner padding */
    }

    #klarris-header > div > div {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        padding: 0 !important;
    }

    #klarris-header .logo-container img,
    #klarris-header img {
        height: 50px !important;
        max-height: 50px !important;
        width: auto !important;
    }

    #klarris-mobile-toggle { 
        display: flex !important; 
        width: 44px !important;
        height: 44px !important;
        background: var(--primary-pink-light) !important;
        border-radius: 10px !important;
        position: relative;
        z-index: 2500 !important;
        align-items: center !important;
        justify-content: center !important;
        pointer-events: auto !important;
        border: none !important;
        box-shadow: none !important;
    }

    #klarris-mobile-toggle svg {
        width: 24px !important;
        height: 24px !important;
    }

    .mobile-header-text {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        font-family: 'Inter', sans-serif !important;
        font-weight: 800 !important;
        color: var(--primary-pink) !important;
        font-size: clamp(1rem, 5vw, 1.25rem) !important;
        letter-spacing: 0.05em !important;
        text-transform: uppercase !important;
        text-align: center !important;
        text-decoration: none !important;
        flex: 1 !important;
        max-width: calc(100% - 130px) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        z-index: 10 !important;
        cursor: pointer !important;
        margin: 0 auto !important;
        padding: 0 5px !important;
        pointer-events: auto !important;
    }

    /* Logo container on mobile */
    #klarris-header a[href*="public_html"],
    #klarris-header a[href*="/shop/"] {
        flex: 0 0 auto !important;
        z-index: 20 !important;
    }

    #klarris-mobile-toggle {
        flex: 0 0 60px !important;
        justify-content: flex-end !important;
    }

    #klarris-mobile-menu {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        width: 85% !important;
        max-width: 360px !important;
        height: 100vh !important;
        background: white !important;
        box-shadow: -10px 0 40px rgba(0,0,0,0.1) !important;
        z-index: 3000 !important;
        padding: 80px 2rem 3rem !important;
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow-y: auto !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
    
    #klarris-mobile-menu.open {
        transform: translateX(0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    #klarris-mobile-menu a {
        font-size: 1.15rem !important;
        font-weight: 600 !important;
        padding: 1.1rem 0 !important;
        color: #1f2937 !important;
        border-bottom: 1px solid rgba(195,31,126,0.08) !important;
        transition: all 0.3s ease !important;
        width: 100% !important;
    }
    
    #klarris-mobile-menu a:active {
        color: var(--primary-pink) !important;
        background: var(--primary-pink-light) !important;
        padding-left: 10px !important;
    }

    body.menu-open {
        overflow: hidden !important;
        height: 100vh !important;
    }
    
    body.menu-open #klarris-mobile-toggle {
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

#klarris-drawer-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(17, 24, 39, 0.46) !important;
    z-index: 2990 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease !important;
}

#klarris-drawer-overlay.open {
    opacity: 1 !important;
    pointer-events: auto !important;
}

@media (min-width: 993px) {
    #klarris-mobile-menu,
    #klarris-drawer-overlay {
        display: none !important;
    }
}

/* 4. Products & Cards Compensation */
@media (max-width: 640px) {
    .product-grid-fix {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .product-card-fix {
        padding: 0.75rem !important;
    }
    
    .product-card-fix h4 {
        font-size: 0.9rem !important;
    }
    
    /* Search bar focus improvement */
    input:focus {
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
    }
}

/* 5. Footer & Stats Compensation */
@media (max-width: 480px) {
    .stats-grid-fix {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1.5rem !important;
    }
    
    .stats-grid-fix > div:last-child {
        grid-column: span 2 !important;
    }
}

/* 6. Premium Touch Feedback */
@media (hover: none) {
    .hover\:scale-105:active { transform: scale(1.02); }
    .hover\:bg-pink-700:active { background-color: var(--primary-pink-dark) !important; }
    a:active, button:active { opacity: 0.7; }
}

/* 7. Safe Area Insets */
body {
    padding-bottom: env(safe-area-inset-bottom);
}

#klarris-header {
    padding-top: env(safe-area-inset-top);
}

/* 8. Filter Drawer for Mobile (Utility) */
.filter-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80vh;
    background: white;
    z-index: 2100;
    border-radius: 30px 30px 0 0;
    padding: 2rem;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
}

.filter-drawer.open {
    transform: translateY(0);
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* 9. Tablet & Desktop Fine-tuning */
@media (min-width: 768px) and (max-width: 1024px) {
    .grid-cols-3, .md\:grid-cols-3 { grid-template-columns: repeat(2, 1fr) !important; }
    .lg\:grid-cols-4 { grid-template-columns: repeat(3, 1fr) !important; }
    .max-w-7xl { padding-left: 2rem !important; padding-right: 2rem !important; }
}

@media (min-width: 1536px) {
    .max-w-7xl { max-width: 1440px !important; }
}

/* 10. Premium UI Elements */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
    background: #c31f7e55;
    border-radius: 10px;
    border: 2px solid #f1f1f1;
}
::-webkit-scrollbar-thumb:hover {
    background: #c31f7e;
}

/* 11. Interactive Element Compensation */
.klarris-dropdown-menu {
    border: 1px solid rgba(195,31,126,0.1);
    animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 12. Utility Classes */
.text-balance { text-wrap: balance !important; }
.glass { background: rgba(255,255,255,0.7) !important; backdrop-filter: blur(10px) !important; }
.touch-target { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }

/* 13. Mobile Only Elements */

/* 14. Notice Bar Fixes */
#notice-bar {
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    padding: 0.6rem 0 !important;
    background: var(--primary-pink) !important;
    color: white !important;
}

#notice-bar p {
    display: inline-flex !important;
    animation: noticeMarquee 30s linear infinite;
    padding-left: 20px;
    gap: 3rem !important;
    margin: 0 !important;
    font-weight: 500 !important;
    font-size: 0.85rem !important;
    color: white !important;
    white-space: nowrap !important;
    align-items: center !important;
}

#notice-bar p span {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
}

#notice-bar p span svg {
    flex-shrink: 0 !important;
}

@keyframes noticeMarquee {
    0% { transform: translateX(50vw); }
    100% { transform: translateX(-100%); }
}

@media (min-width: 992px) {
    #notice-bar p {
        animation: none;
        padding-left: 0;
        width: 100%;
        justify-content: center;
        gap: 2rem !important;
    }
}

/* 15. Button Grouping Fix */
.hero-ctas, .flex.gap-4, .btn-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 1rem !important;
}

@media (max-width: 480px) {
    .hero-ctas a, .hero-ctas button,
    .btn-group a, .btn-group button {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* 16. MHT Page Specific Tweaks */
.hero-eyebrow {
    font-size: 0.75rem !important;
    padding: 0.5rem 1rem !important;
    line-height: 1 !important;
    background: rgba(195,31,126,0.1) !important;
    color: var(--primary-pink) !important;
    border-radius: 50px !important;
    border: 1px solid rgba(195,31,126,0.2) !important;
}

@media (max-width: 768px) {
    #hero {
        padding-top: 2rem !important;
        padding-bottom: 3rem !important;
    }
    #hero h1 {
        font-size: clamp(2.2rem, 10vw, 3.2rem) !important;
        margin-bottom: 1.25rem !important;
    }
    .hero-sub {
        font-size: 1.1rem !important;
        margin-bottom: 2rem !important;
        line-height: 1.5 !important;
    }
    .hero-ctas {
        flex-direction: column !important;
        width: 100% !important;
    }
    .hero-ctas a {
        width: 100% !important;
        text-align: center !important;
        padding: 1rem !important;
    }
}

/* 13. Focus States for Accessibility */
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--primary-pink);
    outline-offset: 2px;
}
