/* Force font-display: swap for FontAwesome & Webfonts (PageSpeed Audit) */
@font-face { font-family: 'FontAwesome'; font-display: swap; }
@font-face { font-family: 'Font Awesome 5 Free'; font-display: swap; }
@font-face { font-family: 'Font Awesome 5 Brands'; font-display: swap; }
@font-face { font-family: 'Font Awesome 6 Free'; font-display: swap; }
@font-face { font-family: 'Font Awesome 6 Brands'; font-display: swap; }

/* MFRural Style Header - Refined Green Theme */

:root {
    --mfr-green: #28a745;
    --mfr-green-dark: #218838;
    --white: #ffffff;
    --text-muted: #e9ecef;
}

.main-header-wrapper {
    background: white !important;
    width: 100%;
    position: relative;
    /* Garantir que o z-index funcione mesmo sem ser sticky */
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}


.main-header-wrapper.sticky {
    position: sticky;
    top: 0;
}

/* TOP BAR */
.top-header-bar {
    padding: 15px 0;
    border-bottom: none;
    /* Removida linha que gerava aparência de margem */
}

.header-flex-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

/* Logo Section - NO BEGE BACKGROUND */
.logo {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.logo img {
    height: 50px !important;
    /* Increased size as requested */
    width: auto !important;
    display: block;
}

.logo-tagline {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: 5px;
    display: block;
    color: var(--white) !important;
}

/* Integrated Search Bar */
.header-search-wrap {
    flex: 1;
    max-width: 500px;
}

.search-inner {
    position: relative;
}

.search-inner input {
    width: 100%;
    height: 48px;
    padding: 0 50px 0 20px;
    border: none;
    border-radius: 50px;
    /* Pill search bar */
    font-size: 15px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    outline: none;
}

.search-btn {
    position: absolute;
    right: 5px;
    top: 5px;
    height: 38px;
    width: 38px;
    background: var(--mfr-green);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

/* Right Meta (Auth & Pill Button) */
.header-right-meta {
    display: flex;
    align-items: center;
    gap: 20px;
}

.auth-links a {
    color: green !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.auth-links a:hover {
    color: black !important;
}

/* PILL BUTTON - WHITE */
.btn-pill-white {
    background-color: var(--mfr-green-dark) !important;
    color: var(--white) !important;
    padding: 10px 25px !important;
    border-radius: 50px !important;
    /* Maximum rounding */
    font-weight: 800 !important;
    font-size: 13px;
    text-decoration: none !important;
    text-transform: uppercase;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-pill-white:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.top-header-bar,
.bottom-header-bar {
    margin: 0 !important;
}

/* BOTTOM BAR */
.bottom-header-bar {
    background: var(--mfr-green-dark);
    /* Slightly darker for contrast */
    padding: 10px 0;
    position: relative;
}

.bottom-inner {
    display: flex;
    align-items: center;
    gap: 50px;
}

/* Mega Menu Toggle */
.mega-menu-item {
    position: static;
    /* Required for 100% width dropdown */
}

.mega-toggle {
    color: var(--white) !important;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    text-decoration: none !important;
    display: flex;
    align-items: center;
}

.mega-menu-dropdown {
    position: absolute !important;
    left: 0 !important;
    top: 100% !important;
    width: 100% !important;
    background: #ffffff !important;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2) !important;
    padding: 25px 0 !important;
    z-index: 9999 !important;
    display: none;
    border-top: 2px solid var(--white) !important;
    height: 50vh !important;
    max-height: 50vh !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    overscroll-behavior-y: contain !important;
    scrollbar-width: thin !important;
    scrollbar-color: #28a745 #f1f1f1 !important;
}

.mega-menu-dropdown::-webkit-scrollbar {
    width: 10px !important;
    display: block !important;
}

.mega-menu-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
    border-radius: 5px !important;
}

.mega-menu-dropdown::-webkit-scrollbar-thumb {
    background: #28a745 !important;
    border-radius: 5px !important;
    border: 2px solid #f1f1f1 !important;
}

.mega-menu-dropdown::-webkit-scrollbar-thumb:hover {
    background: #218838 !important;
}

.mega-menu-dropdown.active {
    display: block !important;
    animation: fadeInDown 0.2s ease;
}

@media (min-width: 992px) {
    .mega-menu-item:hover .mega-menu-dropdown {
        display: block !important;
    }
    .mega-menu-row {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 20px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .col-mega {
        flex: 1 1 0px !important;
        width: 20% !important;
        min-width: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

@media (max-width: 991px) {
    .mega-menu-row {
        display: flex !important;
        flex-wrap: wrap !important;
    }
    .col-mega {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0 10px !important;
    }
}

@media (max-width: 575px) {
    .col-mega {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

.mega-col-title {
    font-weight: 800;
    font-size: 13px;
    color: #2D5A27;
    text-transform: uppercase;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #2D5A27;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mega-col-title:hover {
    color: #1e3d1a;
    padding-left: 3px;
}

.mega-menu-dropdown ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-menu-dropdown ul li {
    margin-bottom: 10px;
}

.mega-menu-dropdown ul li a {
    color: #444;
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s;
}

.mega-menu-dropdown ul li a:hover {
    color: var(--mfr-green);
    padding-left: 5px;
}

/* Secondary Horizontal Nav */
.secondary-nav-horizontal ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 40px;
}

.secondary-nav-horizontal a {
    color: var(--white) !important;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    text-decoration: none !important;
}

.secondary-nav-horizontal a:hover {
    color: #ccffdd !important;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Menu Toggle Button */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 26px;
    color: var(--mfr-green-dark);
    cursor: pointer;
    padding: 5px 10px;
    outline: none;
    margin-left: auto; /* Push to the right */
    transition: transform 0.3s ease;
}

.mobile-menu-btn i {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Mobile Adjustments */
@media (max-width: 991px) {
    .mobile-menu-btn {
        display: block;
    }

    .header-flex-wrapper {
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 0; /* Prevents hidden flex rows from adding whitespace */
    }

    /* Force the button to stay on the right */
    .mobile-menu-btn {
        margin-left: auto;
    }

    /* Hide elements by default with max-height and opacity for smooth animation */
    .header-search-wrap,
    .header-right-meta,
    .bottom-header-bar {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        flex: 0 0 100% !important; /* Force to new line */
        max-width: 100% !important;
    }

    /* When menu is open, expand them */
    .main-header-wrapper.menu-open .header-search-wrap {
        max-height: 100px;
        opacity: 1;
        margin-top: 15px !important;
        order: 3;
    }

    .main-header-wrapper.menu-open .header-right-meta {
        max-height: 200px;
        opacity: 1;
        margin-top: 15px !important;
        padding-bottom: 15px !important;
        border-bottom: 1px solid #eee !important;
        display: flex !important;
        flex-direction: column;
        gap: 15px;
        order: 4;
    }

    .main-header-wrapper.menu-open .bottom-header-bar {
        max-height: 500px;
        opacity: 1;
        padding-top: 15px !important;
        padding-bottom: 15px !important;
        background: transparent !important;
    }

    /* Allow the header to grow smoothly */
    .main-header-wrapper {
        transition: all 0.4s ease;
    }

    .main-header-wrapper.menu-open {
        max-height: 100vh;
        overflow-y: auto;
        box-shadow: 0 15px 30px rgba(0,0,0,0.15);
    }

    .main-header-wrapper.menu-open .bottom-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .main-header-wrapper.menu-open .mega-toggle {
        color: var(--mfr-green-dark) !important;
        font-size: 16px;
    }

    .main-header-wrapper.menu-open .secondary-nav-horizontal ul {
        flex-direction: column;
        gap: 15px;
    }

    .main-header-wrapper.menu-open .secondary-nav-horizontal a {
        color: #333 !important;
        font-size: 15px;
    }

    .auth-links {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }

    .btn-pill-white {
        margin-left: 0 !important;
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 575px) {
    .logo img {
        height: 40px !important;
    }
    
    .search-inner input {
        font-size: 14px;
        padding-left: 15px;
    }
}

/* Fix for white bar on dashboard pages */
.dashboard-area {
    padding-top: 10px !important;
    margin-top: 0 !important;
}

.dashboard-area > .container {
    padding-top: 0 !important;
}

.dashboard-area .section-title {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.dashboard-area .section-title h2 {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Ensure header doesn't push down weirdly */
.main-header-wrapper {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Global fix for the white bar between header and content */
.breadcrumb-area,
.banner-area,
.dashboard-area,
section:first-of-type,
div[style*="background-image"],
div[style*="background: url"] {
    margin-top: 0 !important;
}

/* Home Banner Search Form Fix (Prevents long category names from overlapping text input) */
.banner-area-inner form {
    position: relative !important;
    margin-top: 55px !important;
    display: flex !important;
    align-items: stretch !important;
    background: #ffffff !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08) !important;
    overflow: visible !important;
}

.banner-area-inner form .nice-select {
    position: relative !important;
    height: 80px !important;
    line-height: 80px !important;
    border-radius: 10px 0 0 10px !important;
    font-size: 16px !important;
    color: #565872 !important;
    font-family: var(--body-font) !important;
    font-weight: 500 !important;
    border: 0 !important;
    border-right: 2px solid #e1e1e1 !important;
    padding: 0 45px 0 25px !important;
    flex: 0 0 260px !important;
    max-width: 260px !important;
    width: 260px !important;
    box-sizing: border-box !important;
    float: none !important;
}

.banner-area-inner form .nice-select:after {
    right: 20px !important;
}

.banner-area-inner form .nice-select .current {
    display: block !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 190px !important;
}

.banner-area-inner form .nice-select .list {
    max-height: 320px !important;
    overflow-y: auto !important;
    min-width: 100% !important;
    width: max-content !important;
    max-width: 380px !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15) !important;
    border-radius: 8px !important;
    z-index: 9999 !important;
}

.banner-area-inner form .form-control {
    position: relative !important;
    height: 80px !important;
    line-height: 80px !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 25px !important;
    flex: 1 1 auto !important;
    font-size: 16px !important;
    box-shadow: none !important;
    background: transparent !important;
    width: auto !important;
}

.banner-area-inner form .btn {
    position: relative !important;
    height: 80px !important;
    line-height: 80px !important;
    border-radius: 0 10px 10px 0 !important;
    background: #0b5321 !important;
    padding: 0 35px !important;
    flex: 0 0 auto !important;
    top: auto !important;
    right: auto !important;
}

@media (max-width: 767px) {
    .banner-area-inner form {
        flex-direction: column !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    .banner-area-inner form .nice-select {
        flex: 0 0 auto !important;
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 10px !important;
        border-right: none !important;
        margin-bottom: 12px !important;
        height: 60px !important;
        line-height: 60px !important;
        background: #fff !important;
    }
    .banner-area-inner form .nice-select .current {
        max-width: 85% !important;
    }
    .banner-area-inner form .form-control {
        height: 60px !important;
        line-height: 60px !important;
        border-radius: 10px !important;
        margin-bottom: 12px !important;
        background: #fff !important;
        padding: 0 20px !important;
    }
    .banner-area-inner form .btn {
        height: 60px !important;
        line-height: 60px !important;
        border-radius: 10px !important;
        width: 100% !important;
    }
}