/* --- Header Component Styles --- */
:root {
    --color-dark: #292f35;
    --color-red: #1d3557;
    --color-text-light: #ced4da;
    --color-text-dark: #333;
    --color-white: #fff;
    --font-heading: 'Open Sans', sans-serif;
    --font-body: 'Open Sans', sans-serif;
}

/* --- General Link Styles --- */
a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* --- Header container width --- */
header .container {
    max-width: 1340px;
}

/* --- Top Bar --- */
.top-bar {
    background-color: #3b5998;
    color: var(--color-text-light);
    padding: 8px 0;
    font-size: 14px;
}

.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar-social a {
    color: white;
    background-color: #555;
    width: 28px;
    height: 28px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    margin-right: 5px;
    font-size: 14px;
    transition: background-color 0.3s;
}

.top-bar-social a:hover {
    background-color: var(--color-red);
}

.top-bar-contact a {
    margin-left: 20px;
    transition: color 0.3s;
    color: white;
}

.top-bar-contact a:hover {
    color: var(--color-white);
}

.top-bar-contact i {
    margin-right: 8px;
}

/* --- Main Header --- */
.main-header {
    background-color: var(--color-white);
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo img {
    height: 60px;
}

/* Logo + Site Name inline */
.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo-link .site-name {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; /* classic brand font */
    font-weight: 800; /* strong brand presence */
    font-size: 20px;  /* larger than nav */
    text-transform: uppercase;
    color: var(--color-text-dark);
    line-height: 1.1;
    white-space: nowrap;
    transition: color 0.2s ease;
    color: #db650f;
}

.logo-link .tagline {
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
    color: #000;
    line-height: 1;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.main-nav ul {
    display: flex;
    align-items: center;
}

.main-nav li {
    margin-left: 25px;
}

.main-nav a {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-dark);
    text-transform: uppercase;
    padding-bottom: 5px;
    border-bottom: 2px solid transparent;
    transition: color 0.3s, border-bottom-color 0.3s;
}

.main-nav a:hover,
.main-nav a.active {
    color: #db650f;
    border-bottom-color: #db650f;
}

.main-nav .search-icon {
    font-size: 18px;
}

/* --- Dropdown Menu --- */
.dropdown {
    position: relative;
}

.dropdown .fa-chevron-down {
    font-size: 10px;
    margin-left: 5px;
    transition: transform 0.3s ease;
}

.dropdown:hover .fa-chevron-down {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    background-color: var(--color-white);
    border: 1px solid #e9ecef;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -10px);
    transition: all 0.3s ease;
    z-index: 1000;
    width: max-content;
    --colw: 260px; /* column width for vertical rules */
    min-width: calc(var(--colw) * 3);
    padding: 0;
    background-image: repeating-linear-gradient(to right,
        transparent 0,
        transparent calc(var(--colw) - 1px),
        #eceeef calc(var(--colw) - 1px),
        #eceeef var(--colw)
    );
    background-clip: padding-box;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* Grid that fills by rows to create 2-3 columns */
.dropdown-grid {
    display: grid;
    grid-auto-flow: column;
    /* Fixed rows -> number of columns depends on item count */
    --rows: 13; /* large screens → ~3 columns for ~38 items */
    grid-template-rows: repeat(var(--rows), 40px);
    grid-auto-columns: var(--colw);
    gap: 0;
    background: transparent;
}

.dropdown-grid a {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 16px;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 13px;
    text-transform: none; /* undo uppercase inherited from .main-nav a */
    color: #495057; /* similar to screenshot */
    border-top: 1px solid #eceeef; /* list separators like screenshot */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.dropdown-grid a:hover {
    background-color: #f8f9fa;
    color: var(--color-text-dark);
    padding-left: 18px;
}

/* Additional Services dropdown: clean single column */
.dropdown-menu.services-menu {
    --colw: 300px;
    min-width: var(--colw);
    background-image: none;
}

.services-menu .dropdown-grid {
    --rows: 7;
}

/* Products dropdown: single-column list with right-side flyout submenus */
.dropdown-menu.products-menu {
    background-image: none;
    --colw: 240px;
    min-width: var(--colw);
}

.products-menu .dropdown-grid {
    display: block;
    width: var(--colw);
}

.products-menu .menu-group {
    position: relative;
}

.products-menu .menu-group-label {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 13px;
    text-transform: none;
    color: #495057;
    border-top: 1px solid #eceeef;
    white-space: nowrap;
    cursor: default;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.products-menu .menu-group-label .fa-chevron-left {
    font-size: 9px;
    color: #adb5bd;
    transition: color 0.2s ease, transform 0.2s ease;
}

.products-menu .menu-group:hover > .menu-group-label {
    background-color: #f8f9fa;
    color: var(--color-text-dark);
}

.products-menu .menu-group:hover > .menu-group-label .fa-chevron-left {
    color: var(--color-accent);
    transform: translateX(-2px);
}

/* Submenus always open leftward (nav sits at the right edge of the screen) */
.products-menu .flyout {
    position: absolute;
    top: -1px;
    right: 100%;
    min-width: var(--colw);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background-color: var(--color-white);
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateX(6px);
    transition: all 0.25s ease;
    z-index: 1001;
}

.products-menu .menu-group:hover > .flyout {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.products-menu .flyout a:first-child {
    border-top: none;
}

/* Wide flyout for larger groups: two columns */
.products-menu .flyout-wide {
    width: 480px;
    column-count: 2;
    column-gap: 0;
}

.products-menu .flyout-wide a {
    break-inside: avoid;
}

/* Mobile submenu group labels */
.mobile-nav .submenu-group {
    padding: 12px 20px 6px;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-accent);
    border-top: 1px solid #f0f0f0;
    list-style: none;
}

/* 2 columns on medium screens by increasing rows */
@media (max-width: 1100px) {
    .dropdown-grid {
        --rows: 19; /* forces ~2 columns for same item count */
        grid-auto-columns: var(--colw);
    }
    .dropdown-menu { --colw: 240px; min-width: calc(var(--colw) * 2); }
}

.dropdown-column {
    padding: 0 20px;
    border-right: 1px solid #f0f0f0;
}

.dropdown-column:last-child {
    border-right: none;
}

.dropdown-column a {
    display: block;
    padding: 8px 0;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 13px;
    color: var(--color-text-dark);
    text-transform: none;
    border-bottom: none;
    transition: color 0.2s ease, padding-left 0.2s ease;
    line-height: 1.4;
}

.dropdown-column a:hover {
    color: var(--color-red);
    padding-left: 5px;
}

/* --- Mobile Menu Toggle --- */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    gap: 4px;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background-color: var(--color-text-dark);
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* --- Mobile Menu Overlay --- */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.mobile-menu {
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    height: 100vh;
    background-color: var(--color-white);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
}

.mobile-menu-overlay.active .mobile-menu {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background-color: var(--color-white);
    color: var(--color-text-dark);
    position: sticky;
    top: 0;
    z-index: 20;
}

.mobile-menu-header h3 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 18px;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--color-text-dark);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    transition: color 0.3s;
}

.mobile-menu-close:hover {
    color: var(--color-red);
}

.mobile-nav ul {
    padding: 0;
    margin: 0;
}

.mobile-nav li {
    border-bottom: 1px solid #f0f0f0;
}

.mobile-nav a {
    display: block;
    padding: 15px 20px;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 16px;
    color: var(--color-text-dark);
    text-transform: uppercase;
    transition: background-color 0.3s, color 0.3s;
}

.mobile-nav a:hover,
.mobile-nav a.active {
    background-color: var(--color-red);
    color: var(--color-white);
}

/* Mobile submenu for Products */
.mobile-nav .has-submenu .submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 20px;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 16px;
    color: var(--color-text-dark);
    text-transform: uppercase;
    background: none;
    border: none;
    cursor: pointer;
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--color-white);
    border-bottom: 1px solid #f0f0f0;
}

.mobile-nav .has-submenu .submenu-toggle i {
    transition: transform 0.25s ease;
}

.mobile-nav .has-submenu.open .submenu-toggle i {
    transform: rotate(180deg);
}

.mobile-nav .has-submenu .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: #fff;
    overflow-y: auto; /* allow scrolling when opened */
    -webkit-overflow-scrolling: touch; /* smooth momentum on iOS */
    overscroll-behavior: contain;
}

.mobile-nav .has-submenu .submenu a {
    padding: 12px 20px 12px 36px;
    font-size: 15px;
    text-transform: none;
    border-top: 1px solid #f0f0f0;
}

.mobile-contact {
    padding: 20px;
    border-top: 1px solid #eee;
    background-color: #f8f9fa;
}

.mobile-contact a {
    display: block;
    padding: 10px 0;
    color: var(--color-text-dark);
    font-size: 14px;
    transition: color 0.3s;
}

.mobile-contact a:hover {
    color: var(--color-red);
}

.mobile-contact i {
    margin-right: 8px;
    width: 16px;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    .top-bar {
        display: none;
    }
    
    .main-nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .logo img {
        height: 50px;
    }
    
    .logo-link .tagline {
        font-size: 9px;
    }
    
    .main-header {
        padding: 10px 0;
    }
    
    .dropdown-menu {
        display: none;
    }
}

@media (max-width: 480px) {
    .mobile-menu {
        width: 280px;
    }
    
    .logo img {
        height: 45px;
    }
    
    .logo-link .site-name {
        font-size: 16px;
    }
    
    .logo-link .tagline {
        font-size: 8px;
    }
}

/* --- Sticky Header State --- */
.main-header.sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    background-color: var(--color-white);
    border-bottom: 1px solid #eee;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}
