/* =======================================
   0. PERFORMANCE & BASE STYLES
   (Crucial for fixing LCP 8s delay)
   ======================================= */

/* 1. System Font Stack: ensures text is visible 
   IMMEDIATELY while web fonts load. 
*/
body, .nav-text-link, .mobile-link, h1, h2, h3, h4 {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

/* 2. Content Visibility: Tells browser to skip rendering 
   off-screen menus during initial page load. 
*/
.mobile-menu, .dropdown-menu {
    content-visibility: auto; 
    contain-intrinsic-size: 0 500px; /* Estimated height to prevent scrollbar jumps */
}

/* =======================================
   1. HEADER WRAPPER & RESET
   ======================================= */

.site-header {
    background-color: #ffffff;
    border-bottom: 1.25px solid rgba(35, 146, 88, 0.18);
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    position: relative;
    z-index: 900;
    top: 0;
}

.navbar {
    background: #ffffff;
    box-shadow: none;
    margin: 0;
    padding: 0;
    min-height: 80px;
}

.navbar-bg {
    width: 100%;
    background: #ffffff;
    border-bottom: none;
    margin: 0;
    padding: 0;
}

/* =======================================
   2. TOP NAV (Logo, Links, CTA, Hamburger)
   ======================================= */

.top-nav {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo img {
    height: 35px;
    width: auto;
    display: block;
    /* Prevent layout shift on logo load */
    aspect-ratio: auto; 
}

/* Logo theme switching */
.logo-dark {
    display: none;
}

/* Right Side Container */
.top-nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

/* Desktop Links */
.desktop-nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-right: 8px;
}

.nav-text-link {
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    color: #333;
    transition: color 0.25s ease;
    white-space: nowrap;
}

.nav-text-link:hover {
    color: #239258;
}

/* CTA Button */
.nav-cta {
    padding: 10px 18px;
    background: #059669;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
}

.nav-cta:hover {
    background: #1f7f4c;
    transform: translateY(-1px);
}

/* Hamburger Icon */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(5, 150, 105, 0.08);
    border: 1px solid rgba(5, 150, 105, 0.15);
    cursor: pointer;
    z-index: 10001;
}

.hamburger span {
    width: 20px;
    height: 2px;
    background: #059669;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger:hover {
    background: rgba(5, 150, 105, 0.15);
}

.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Hamburger Label (Mobile Text) */
.hamburger-label {
    display: none;
    margin-left: 10px;
    font-size: 17px;
    font-weight: 600;
    color: #239258;
    letter-spacing: 0.01em;
    vertical-align: middle;
}
@media (max-width: 1024px) {
    .hamburger-label { display: inline-block; }
}

/* =======================================
   3. BOTTOM NAV (Categories, Deals, Trending)
   ======================================= */

.nav-bottom {
    position: relative;
    max-width: 1280px;
    margin: 0 auto;
    border-top: 1px solid #f0f2f0;
    padding: 0 24px;
}

.nav-bottom-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 46px;
}

.nav-categories-wrapper {
    position: static;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-categories {
    padding: 6px 12px;
    margin-left: -12px;
    border-radius: 8px;
    background: transparent;
    color: #414141;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, color 0.2s;
}

.nav-categories:hover {
    background: #f5f7f5;
    color: #239258;
}

.cat-arrow {
    font-size: 10px;
    transition: transform 0.25s ease;
}

.nav-categories:hover .cat-arrow {
    transform: rotate(180deg);
}

.bottom-nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.bottom-link {
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s ease;
}

.bottom-link i {
    color: #999;
    font-size: 13px;
    transition: color 0.2s ease;
}

.bottom-link:hover, .bottom-link:hover i {
    color: #239258;
}

/* =======================================
   4. MEGA MENU 
   ======================================= */

.dropdown-menu {
    position: absolute;
    left: 0;
    top: 100%;
    width: 100%;
    background: #fff;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.06), 0 1px 0 rgba(0,0,0,0.02);
    padding: 32px 40px;
    box-sizing: border-box;
    z-index: 1000;
    
    /* Animation State */
    display: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.2s cubic-bezier(0.165, 0.84, 0.44, 1), visibility 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    
    /* Optimization: Improves paint performance during animation */
    will-change: opacity, transform;
}

.dropdown-menu.open {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px; 
    width: 100%;
}

@media (min-width: 1100px) {
    .dropdown-grid { grid-template-columns: repeat(4, 1fr); }
}

.dropdown-column {
    display: flex;
    flex-direction: column;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.category-icon-fa {
    font-size: 16px;
    color: #059669;
}

.category-title {
    font-size: 15px;
    font-weight: 700;
    color: #239258;
    margin: 0;
}

.subitem { margin-bottom: 14px; }

.subitem-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-decoration: none;
    margin-bottom: 2px;
    transition: color 0.2s;
}

.subitem-title:hover { color: #239258; }

.subitem-desc {
    font-size: 12px;
    color: #777;
    margin: 0;
    line-height: 1.4;
}

.dropdown-footer {
    width: 100%;
    border-top: 1px solid #f0f0f0;
    margin-top: 30px;
    padding-top: 20px;
    text-align: center;
}

.explore-link {
    font-size: 14px;
    color: #239258;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.explore-link:hover .arrow { transform: translateX(4px); transition: transform 0.2s; }

/* =======================================
   5. MOBILE MENU & GLITCH FIXES
   ======================================= */

/* Backdrop Overlay */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.mobile-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Off-canvas Drawer */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 380px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px); 
    box-shadow: -5px 0 25px rgba(0,0,0,0.1);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: right;
}

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

.mobile-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mobile-header-row {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.mobile-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #174c33;
    margin: 0;
}

.mobile-menu-title {
    font-size: 20px;
    font-weight: 700;
    color: #239258;
    letter-spacing: 0.01em;
    margin-left: 2px;
}

/* CLOSE BUTTON FIX (The "Double X" Glitch Solver) 
   Removes phantom icons from external libraries
*/
.mobile-close-btn::before,
.mobile-close-btn::after {
    content: none !important;
    display: none !important;
    background: none !important;
}

.mobile-close-btn {
    width: 48px; /* Google Standard: Minimum Touch Target */
    height: 48px;
    border-radius: 12px;
    background: #e6f7ee !important; /* Force green background */
    background-image: none !important; /* Remove any ghost icons */
    border: 1.5px solid #8be0c0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    margin-right: 0;
    box-shadow: none;
    cursor: pointer;
    font-size: 32px;
    font-weight: 700;
    color: #239258;
    line-height: 1;
    transition: background 0.18s, border 0.18s;
}

.mobile-close-btn:hover {
    background: #d2f3e3 !important;
    border-color: #239258;
    color: #174c33;
}

/* Mobile Scroll Content */
.mobile-scroll-area {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Big Mobile Links */
.main-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
}

.mobile-login-btn, .mobile-link {
    display: block;
    width: 100%;
    background: none;
    color: #239258;
    font-size: 17px;
    font-weight: 400;
    border-radius: 0;
    padding: 0 0 16px 0;
    margin-bottom: 0;
    text-align: left;
    text-decoration: none;
    border: none;
    box-shadow: none;
    transition: color 0.18s;
}

.mobile-login-btn { font-weight: 700; padding-bottom: 16px; }
.mobile-login-btn:hover, .mobile-link:hover { color: #174c33; text-decoration: underline; }

.services-links {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    text-decoration: none;
    padding: 14px;
    background: #f9fbf9;
    border-radius: 10px;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.services-links:hover {
    background: #059669;
    color: white;
    transform: translateX(4px);
}

.mobile-section {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    font-weight: 700;
    margin-bottom: 12px;
}

/* Mobile Accordion */
.hamburger-category {
    background: transparent;
    border: none;
    margin-bottom: 0;
}

.hamburger-category-header {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 14px 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.icon-wrap {
    width: 32px;
    height: 32px;
    background: #e6f4ea;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: #059669;
}

.hamburger-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.chevron {
    margin-left: auto;
    color: #999;
    font-size: 12px;
    transition: transform 0.3s;
}

.hamburger-category.open .chevron { transform: rotate(180deg); }

.hamburger-subitems {
    max-height: 0;
    overflow: hidden;
    padding-left: 48px;
    transition: max-height 0.3s ease;
    border-left: 2px solid #f0f0f0;
    margin-left: 20px;
}

.hamburger-category.open .hamburger-subitems {
    max-height: 500px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.hamburger-subitem {
    display: block;
    padding: 8px 0;
    font-size: 14px;
    color: #666;
    text-decoration: none;
}

.hamburger-subitem:hover { color: #059669; }

/* =======================================
   6. RESPONSIVE UTILS
   ======================================= */

@media (max-width: 1024px) {
    .desktop-nav-links,
    .nav-bottom {
        display: none;
    }
    .hamburger { display: flex; }
    .top-nav { padding: 12px 16px; }
    .nav-cta { padding: 8px 14px; font-size: 12px; }
}

@media (max-width: 480px) {
    .mobile-menu { width: 100%; max-width: none; }
}

/* =======================================
   7. DARK MODE OVERRIDES
   ======================================= */

html.dark .logo-light { display: none !important; }
html.dark .logo-dark { display: block !important; }

html.dark .site-header,
html.dark .navbar,
html.dark .navbar-bg {
    background: #141414;
    border-color: rgba(255,255,255,0.05);
}

html.dark .nav-bottom { border-top-color: #222; }

html.dark .nav-text-link { color: #e0e0e0; }
html.dark .nav-text-link:hover { color: #239258; }

html.dark .nav-categories { color: #e0e0e0; }
html.dark .nav-categories:hover { background: #222; color: #239258; }

html.dark .bottom-link { color: #b0b0b0; }
html.dark .bottom-link i { color: #666; }
html.dark .bottom-link:hover { color: #239258; }

html.dark .nav-cta { background: #239258; color: #fff; }

html.dark .hamburger { background: #1f1f1f; border-color: #333; }
html.dark .hamburger span { background: #e0e0e0; }

html.dark .dropdown-menu {
    background: #181818;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
html.dark .category-header { border-bottom-color: #333; }
html.dark .category-title { color: #fff; }
html.dark .subitem-title { color: #e0e0e0; }
html.dark .subitem-title:hover { color: #239258; }
html.dark .subitem-desc { color: #888; }
html.dark .dropdown-footer { border-top-color: #333; }

html.dark .mobile-overlay { background: rgba(0,0,0,0.7); }
html.dark .mobile-menu { background: rgba(20,20,20,0.98); }
html.dark .mobile-logo-text { color: #fff; }
html.dark .mobile-close-btn { background: #333; color: #fff; }
html.dark .mobile-header-row { border-bottom-color: rgba(255,255,255,0.05); }

html.dark .services-links { background: #2a2a2a; color: #ddd; }
html.dark .services-links:hover { background: #059669; color: #fff; }

html.dark .icon-wrap { background: #1f2f26; color: #239258; }
html.dark .hamburger-title { color: #e0e0e0; }
html.dark .hamburger-category-header { border-bottom-color: rgba(255,255,255,0.05); }
html.dark .hamburger-subitems { border-left-color: #333; }
html.dark .hamburger-subitem { color: #aaa; }
html.dark .hamburger-subitem:hover { color: #239258; }
