/* =============================================
   AquaChem - Header Styles
   ============================================= */

/* ===== HEADER TOPBAR ===== */
.header-topbar {
    background: white;
    color: rgba(255,255,255,0.9);
    font-size: 0.8rem;
    padding: 6px 0;
}
.header-topbar .container { display: flex; justify-content: space-between; align-items: center; }
.header-topbar a { color: rgba(255,255,255,0.9); font-size: 0.8rem; }
.header-topbar a:hover { color: #fff; }
.header-topbar .topbar-left { display: flex; gap: 20px; align-items: center; }
.header-topbar .topbar-right { display: flex; gap: 15px; align-items: center; }
.header-topbar i { margin-right: 4px; }

/* ===== HEADER MAIN ===== */
.header-main {
    background: var(--white);
    padding: 16px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.header-main .container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
}

/* Logo — left */
.header-logo { justify-self: start; }
.header-logo a { display: flex; align-items: center; }
.header-logo img { height: 48px; width: auto; }

/* Search — center */
.header-search {
    width: 100%;
    max-width: 760px;
    position: relative;
}
.header-search input {
    width: 400px;
    padding: 11px 48px 11px 18px;
    border: 2px solid var(--gray-300);
    border-radius: 25px;
    font-size: 0.9rem;
    font-family: var(--font-family);
    color: var(--gray-700);
    outline: none;
    transition: var(--transition);
}
.header-search input::placeholder { color: var(--gray-500); }
.header-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.1);
}
.header-search button {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: var(--primary); color: var(--white); border: none;
    border-radius: 50%; width: 36px; height: 36px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition); font-size: 0.85rem;
}
.header-search button:hover { background: var(--primary-dark); }

/* Icons — right */
.header-icons {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 6px;
}
.header-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: var(--gray-700);
    font-size: 1.1rem;
    transition: var(--transition);
    text-decoration: none;
}
.header-icon-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}
.header-icon-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--secondary);
    color: var(--white);
    border-radius: 50%;
    width: 17px; height: 17px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.62rem; font-weight: 700;
    pointer-events: none;
}
.mobile-menu-toggle {
    display: none; background: none; border: none;
    font-size: 1.4rem; color: var(--gray-700); cursor: pointer; padding: 8px;
    border-radius: 50%; transition: var(--transition);
}
.mobile-menu-toggle:hover { background: var(--gray-100); }

/* ===== NAV BAR ===== */
.header-nav {
    background: #006BB7;
    border-top: 1px solid #006BB7;
    position: sticky; top: 0; z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    padding: 10px;
}

.header-nav .container {
    /* max-width: 75%; */
}

.header-nav-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 48px;
    width: 100%;
}
.header-nav-inner::after {
    content: '';
    grid-column: 3;
}

.header-nav ul {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 5px;
}

/* All categories toggle button */
.all-categories-btn {
    grid-column: 1;
    justify-self: start;
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
}
.all-categories-btn a {
    display: flex; align-items: center; gap: 8px;
    padding: 0 20px;
    color: #fff;
    font-size: 0.875rem; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: background 0.2s, transform 0.2s;
    border-bottom: none;
    min-height: 48px;
}
.all-categories-btn a:hover,
.all-categories-btn a.open {
    color: white;
    transform: scale(1.06);
}
#categoriesToggle .cat-btn-close { display: none; }
#categoriesToggle.open .cat-btn-open { display: none; }
#categoriesToggle.open .cat-btn-close { display: flex; align-items: center; gap: 8px; }

/* Nav links list */
.nav-links {
    grid-column: 2;
    display: flex;
    align-items: center;
    list-style: none;
}
.nav-links li { position: relative; }
.nav-links a {
    display: flex; align-items: center;
    padding: 4px 14px;
    padding-bottom:4px; /* extra bottom padding for border */
    color: #fff; font-size: 0.875rem; font-weight: 500;
    white-space: nowrap; transition: var(--transition);
    border-bottom: 2px solid transparent;
}
.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    border-bottom-color: rgba(255,255,255,0.8);
    
}

/* ===== CATEGORIES MEGA MENU ===== */
.categories-mega {
    position: absolute;
    left: 0; right: 0;
    top: 100%;
    background: var(--white);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    border-top: 3px solid rgba(0,0,0,0.15);
    display: none;
    z-index: 999;
    max-height: 520px;
    overflow: hidden;
}
.categories-mega.open {
    display: block;
}
.mega-layout {
    display: flex;
    min-height: 400px;
    max-height: 520px;
}

/* Sidebar — left column */
.mega-sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--gray-100);
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    padding: 8px 0;
}
.mega-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 10px 18px;
    cursor: pointer;
    transition: background 0.15s;
}
.mega-sidebar-item span {
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 500;
    flex: 1;
    cursor: pointer;
}
.mega-sidebar-item:hover span,
.mega-sidebar-item.active span {
    color: var(--primary);
}
.mega-sidebar-item i {
    color: var(--gray-400);
    font-size: 0.65rem;
    flex-shrink: 0;
}
.mega-sidebar-item:hover,
.mega-sidebar-item.active {
    background: var(--white);
}
.mega-no-children {
    font-size: 0.875rem;
    color: var(--gray-500);
    padding: 20px 0 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}
.mega-sidebar-item.active i {
    color: var(--primary);
}

/* Content — right panel */
.mega-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
}
.mega-panel {
    display: none;
}
.mega-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.mega-panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px 32px;
    margin-bottom: 20px;
}
.mega-subcat-group {
    margin-bottom: 10px;
}
.mega-subcat-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--dark);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding-bottom: 6px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--gray-200);
}
.mega-subcat-title:hover {
    color: var(--primary);
}
.mega-sub-item {
    display: block;
    font-size: 0.84rem;
    color: var(--gray-600);
    padding: 4px 0;
    transition: color 0.15s;
}
.mega-sub-item:hover {
    background-color: none !important;
}
.mega-view-all {
    display: inline-block;
    width: 100%;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--primary);
    padding-top: 14px;
    margin-top: auto;
    border-top: 1px solid var(--gray-200);
}
.mega-view-all:hover {
    color: var(--primary-dark);
}

/* Backdrop — disabled */
.mega-backdrop { display: none !important; }

/* ===== HEADER RESPONSIVE ===== */
@media (max-width: 768px) {
    .header-topbar { display: none; }
    .header-main .container { flex-wrap: wrap; }
    .header-search { order: 3; max-width: 100%; flex-basis: 100%; }
    .all-categories-btn { display: none; }
    .nav-links { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .nav-links a { padding: 12px 10px; font-size: 0.8rem; }
    .mobile-menu-toggle { display: block; }
}
