/*
Theme Name: MSM Agri Venture
Theme URI: https://msmAgri.com
Author: MSM Agri Venture Team
Description: A fully customizable premium WordPress theme for smart agriculture platforms. Combined with smart reverse-scrolling header and optimized mobile hamburger menu.
Version: 3.0.0
License: GNU General Public License v2 or later
Text Domain: msm-agri
*/

/* ================================================================
   🎨 CSS CUSTOM PROPERTIES (Design Tokens)
   ================================================================ */
:root {
    /* Brand Colors */
    --primary:          #0b9e43;
    --primary-dark:     #087f35;
    --primary-light:    #d1fae5;
    --primary-glow:     rgba(11,158,67,0.15);
    --accent:           #f59e0b;
    --accent-light:     #fef3c7;
    --danger:           #ef4444;

    /* Surfaces */
    --bg:               #f6faf7;
    --surface:          #ffffff;
    --surface-glass:    rgba(255,255,255,0.85);

    /* Text */
    --text-primary:     #0f172a;
    --text-secondary:   #475569;
    --text-muted:       #94a3b8;

    /* Borders & Shadows */
    --border:           rgba(11,158,67,0.15);
    --border-focus:     #0b9e43;
    --shadow-sm:        0 1px 3px rgba(0,0,0,0.04);
    --shadow-md:        0 4px 20px rgba(0,0,0,0.06);
    --shadow-lg:        0 12px 40px rgba(0,0,0,0.08);
    --shadow-green:     0 8px 32px rgba(11,158,67,0.15);

    /* Border Radius */
    --radius-sm:        12px;
    --radius-md:        16px;
    --radius-lg:        24px;
    --radius-xl:        32px;

    /* Typography */
    --font-body:        'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-heading:     'Poppins', sans-serif;
    --font-size-base:   16px;

    /* Transitions */
    --transition-fast:  0.2s cubic-bezier(0.4,0,0.2,1);
    --transition-base:  0.3s cubic-bezier(0.16, 1, 0.3, 1); /* Smoother scrolling transition */
    --transition-slow:  0.5s cubic-bezier(0.4,0,0.2,1);

    /* Layout */
    --nav-height:       68px;
    --nav-height-mobile:60px;
    --logo-height:      48px;
    --logo-height-mobile:38px;
    --navbar-top:       12px;
    --navbar-width:     94%;
    --nav-bg-opacity:   0.92;
    --body-padding-top: 84px;
    --section-padding:  100px;
    --hero-min-height:  92vh;
    --footer-bg:        #0f172a;
}

/* ================================================================
   RESET & BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: var(--font-size-base); }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    padding-top: var(--body-padding-top);
}

@media (max-width: 991px) {
    body { padding-top: calc(var(--nav-height-mobile) + 16px); }
}

a { text-decoration: none; color: inherit; transition: color var(--transition-fast); }
ul, ol { list-style: none; }
img { max-width: 100%; height: auto; display: block; }
button, input, textarea, select { font-family: inherit; }

/* ================================================================
   NAVBAR — SMART REVERSE SCROLLING HEADER
   ================================================================ */
.navbar {
    position: fixed;
    top: var(--navbar-top);
    left: 50%;
    transform: translateX(-50%) translateY(0);
    width: var(--navbar-width);
    max-width: 1480px;
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                top var(--transition-base);
}

/* Scroll Down Hide & Scroll Up Show Logic */
.navbar.scroll-down, 
.navbar.hide-nav { 
    transform: translateX(-50%) translateY(calc(-100% - 20px)); 
    opacity: 0; 
    pointer-events: none;
}

.navbar.scroll-up { 
    transform: translateX(-50%) translateY(0); 
    opacity: 1; 
    pointer-events: all;
}

.navbar-inner {
    background: rgba(255,255,255,var(--nav-bg-opacity));
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: var(--shadow-green), 0 2px 8px rgba(0,0,0,0.04);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.navbar.scrolled .navbar-inner {
    box-shadow: var(--shadow-green), 0 6px 20px rgba(0,0,0,0.08);
    border-color: rgba(11,158,67,0.25);
}

/* Nav Container */
.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: var(--nav-height);
    padding: 0 16px;
}

/* ── Logo ── */
.site-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    transition: transform var(--transition-fast);
    order: 1; /* Always left */
}
.site-logo:hover { transform: scale(1.03); }

.site-logo img, .site-logo .custom-logo {
    height: var(--logo-height) !important;
    max-height: var(--logo-height) !important;
    width: auto;
    display: block;
    object-fit: contain;
    transition: height var(--transition-fast);
}

/* ── Search Bar ── */
.search-bar {
    flex: 1 1 auto;
    max-width: 440px;
    margin: 0 auto;
    position: relative;
    order: 2; /* Center Desktop */
}

.search-form {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border);
    border-radius: 100px;
    background: rgba(255,255,255,0.6);
    transition: all var(--transition-base);
    height: 44px;
    overflow: hidden;
}

.search-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: var(--surface);
}

.search-icon-wrap {
    display: flex;
    align-items: center;
    padding: 0 12px 0 16px;
    color: var(--primary);
    flex-shrink: 0;
}
.search-icon-wrap svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.2; fill: none; }

.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 0 10px 0 0;
    font-size: .9rem;
    color: var(--text-primary);
    min-width: 0;
}
.search-input::placeholder { color: var(--text-muted); }

/* ── Desktop Nav Links & Auth ── */
.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    order: 3; /* Right Desktop */
}

.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-links > li { position: relative; }
.nav-links > li > a {
    display: flex; align-items: center; padding: 8px 14px;
    border-radius: 100px; color: var(--text-secondary);
    font-size: .88rem; font-weight: 500; transition: all var(--transition-fast);
}
.nav-links > li > a:hover { color: var(--primary); background: var(--primary-light); }

.header-auth-buttons {
    display: flex; gap: 8px; align-items: center; margin-left: 8px;
    padding-left: 12px; border-left: 1px solid var(--border); flex-shrink: 0;
}

.btn-user-login {
    background: var(--primary); color: #fff !important; padding: 9px 18px;
    border-radius: 100px; font-weight: 600; font-size: .84rem; cursor: pointer;
}
.btn-office-login {
    background: transparent; color: var(--primary) !important;
    border: 1.5px solid rgba(11,158,67,0.4); padding: 9px 16px;
    border-radius: 100px; font-weight: 600; font-size: .84rem; cursor: pointer;
}

/* ── Mobile Hamburger Button ── */
.mobile-menu-btn {
    display: none; /* Hidden on Desktop */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 38px;
    height: 38px;
    background: var(--primary-light);
    border: 1.5px solid rgba(11,158,67,0.3);
    border-radius: 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    z-index: 1010;
}
.mobile-menu-btn span {
    display: block; width: 18px; height: 2px;
    background: var(--primary); border-radius: 3px;
    transition: all var(--transition-base); transform-origin: center;
}

.mobile-menu-btn.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.mobile-menu-btn.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ================================================================
   MOBILE MENU DROPDOWN
   ================================================================ */
.mobile-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0; right: 0;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transition: all var(--transition-base);
    z-index: 9999;
    border: 1px solid var(--border);
    max-height: 70vh;
    overflow-y: auto;
}
.mobile-menu.active { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.mobile-nav-links { padding: 4px; list-style: none; }
.mobile-nav-links li a {
    display: flex; padding: 10px 14px; border-radius: 8px;
    color: var(--text-primary); font-weight: 500; font-size: .9rem;
}
.mobile-nav-links li a:hover { background: var(--primary-light); color: var(--primary); }

/* ================================================================
   RESPONSIVE DESIGN (PERFECT MOBILE ALIGNMENT)
   ================================================================ */
@media (max-width: 991px) {
    /* Hide Desktop Links */
    .nav-right { display: none !important; }
    
    /* Perfect Flex Ordering */
    .nav-container { 
        padding: 0 12px; 
        flex-wrap: nowrap; 
        justify-content: space-between; 
        gap: 10px;
    }
    
    .site-logo { 
        order: 1; /* Left */
        flex-shrink: 0; 
    }
    
    .search-bar { 
        order: 2; /* Center */
        flex: 1 1 0; 
        max-width: none !important; 
        margin: 0; 
    }
    
    .mobile-menu-btn { 
        order: 3; /* Right */
        display: flex !important; 
        margin-left: auto;
    }

    .navbar { width: 96%; top: calc(var(--navbar-top) - 4px); }
    
    .hero-container { grid-template-columns: 1fr; text-align: center; gap: 40px; }
    .hero-content { align-items: center; }
}

@media (max-width: 768px) {
    :root { --section-padding: 70px; }
    
    .nav-container { height: var(--nav-height-mobile); }
    .site-logo img { height: var(--logo-height-mobile) !important; max-height: var(--logo-height-mobile) !important; }
    
    .search-form { height: 38px !important; }
    .search-input { font-size: 0.85rem; padding: 0 5px 0 0; }
    
    /* Features & Footer */
    .features-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; gap: 24px; }
    .footer-bottom { flex-direction: column; text-align: center; }
}

.live-search-container {
    position: relative; /* Crucial for absolute positioning of results */
}

#live-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #ffffff;
    border: 1px solid #ddd;
    border-top: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 9999;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.live-search-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.live-search-list li {
    border-bottom: 1px solid #f0f0f0;
}

.live-search-list li a {
    display: block;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
}

.live-search-list li a:hover {
    background: #f9f9f9;
    color: var(--primary-green);
}

#live-search-results .view-all,
#live-search-results .no-results,
#live-search-results .loading {
    padding: 12px 15px;
    text-align: center;
    font-size: 14px;
    background: #f8f9fa;
    color: #666;
}

#live-search-results .view-all a {
    color: var(--primary-green);
    font-weight: 600;
    text-decoration: none;
}


/* ================================================================
   HERO & SECTIONS (Re-used Core Elements)
   ================================================================ */
.hero {
    position: relative;
    min-height: var(--hero-min-height);
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 30%, #a7f3d0 60%, #6ee7b7 100%);
}
.hero-container { max-width: 1280px; margin: 0 auto; padding: var(--section-padding) 5% 120px; display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; }
.hero-title { font-family: var(--font-heading); font-size: clamp(2.4rem, 5vw, 3.8rem); font-weight: 800; color: var(--text-primary); margin-bottom: 16px; }
.hero-description { font-size: 1.05rem; color: var(--text-secondary); margin-bottom: 28px; }
.hero-image { width: 100%; border-radius: var(--radius-xl); box-shadow: var(--shadow-md); }

/* Buttons */
.btn-hero-primary  { background: var(--primary); color: #fff; padding: 13px 26px; border-radius: 100px; font-weight: 600; }
.btn-hero-outline  { background: rgba(255,255,255,.65); color: var(--text-primary); border: 2px solid rgba(11,158,67,.3); padding: 11px 26px; border-radius: 100px; font-weight: 600; }

/* Features & Cards */
.features { padding: var(--section-padding) 5%; background: var(--bg); }
.features-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 24px; }
.feature-card-inner { background: var(--surface); padding: 32px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: transform var(--transition-fast); }
.feature-card-inner:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }

/* Footer */
.site-footer { background: var(--footer-bg); color: rgba(255,255,255,.85); padding: 80px 5% 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.5fr; gap: 48px; margin-bottom: 48px; }