/* ===== VARIABLES ===== */
:root {
    --header-h: 70px;
    --nav-h: 44px;
    --search-h: 44px;
    --brand-logo: 48px;
    --avatar: 42px;
    --container-w: 1400px;
    --page-padding: 20px;

    --primary: #8f2c24;
    --primary-hover: #6b1f18;
    --bg: #fffaf3;
    --text: #333;
    --line: #f0e4d7;
}

/* ===== RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    padding-top: var(--header-h);
}

/* ===== HEADER ===== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg);
    border-bottom: 2px solid var(--line);
    height: var(--header-h);
    box-shadow: 0 2px 10px rgba(143, 44, 36, 0.08);
}

.site-header__inner {
    width: 100%;
    max-width: var(--container-w);
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    padding: 0 var(--page-padding);
    height: 100%;
}

/* ===== LEFT CLUSTER ===== */
.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    flex-direction: column;
    gap: 5px;
    justify-content: center;
    cursor: pointer;
}

.menu-toggle span {
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand__logo {
    width: var(--brand-logo);
    height: var(--brand-logo);
    border-radius: 12px;
    object-fit: contain;
}

.brand__name {
    color: var(--primary);
    font-weight: 900;
    font-size: 22px;
}

/* Desktop Nav */
.main-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.main-nav a,
.nav-mega__btn {
    padding: 0 16px;
    height: var(--nav-h);
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
}

.main-nav a:hover,
.nav-mega__btn:hover {
    background: var(--line);
    color: var(--primary);
}

/* Mega Menu */
.nav-mega {
    position: relative;
}

.nav-mega__panel {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    display: none;
    z-index: 1001;
    background: #fff;
    border: 2px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    min-width: 280px;
    box-shadow: 0 12px 40px rgba(143, 44, 36, 0.15);
}

.nav-mega:hover .nav-mega__panel {
    display: block;
}

.nav-mega__title {
    color: var(--primary);
    font-weight: 900;
    font-size: 14px;
    margin: 4px 8px 12px;
}

.mega-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.mega-list a:hover {
    background: var(--line);
    color: var(--primary);
}

/* ===== CENTER: SEARCH ===== */
.header-center {
    display: flex;
    justify-content: center;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 2px solid var(--line);
    border-radius: 999px;
    padding: 0 18px;
    width: 100%;
    max-width: 500px;
    height: var(--search-h);
}

.header-search__icon {
    color: var(--primary);
    font-size: 20px;
}

.header-search__input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
}

/* ===== RIGHT CLUSTER ===== */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 22px;
    cursor: pointer;
}

/* Cart */
.cart {
    position: relative;
    color: var(--text);
    font-size: 24px;
    text-decoration: none;
}

.cart:hover {
    color: var(--primary);
}

.cart__badge {
    position: absolute;
    top: 0;
    right: -2px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    line-height: 22px;
    text-align: center;
}

/* User Menu */
.user {
    position: relative;
}

.avatar {
    width: var(--avatar);
    height: var(--avatar);
    border-radius: 50%;
    border: 2px solid var(--line);
    overflow: hidden;
    cursor: pointer;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 12px);
    background: #fff;
    border: 2px solid var(--line);
    border-radius: 16px;
    width: 300px;
    display: none;
    box-shadow: 0 12px 40px rgba(143, 44, 36, 0.15);
}

.user-menu.show {
    display: block;
}

.user-menu__header {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 2px solid var(--line);
}

.user-menu__avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
}

.user-menu__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-menu__name {
    font-weight: 900;
    color: var(--primary);
}

.user-menu__list {
    padding: 10px;
}

.user-menu__list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.user-menu__list a:hover {
    background: var(--line);
}

.user-menu__list a.danger {
    color: #d32f2f;
}

/* Login Button */
.login-btn {
    padding: 0 24px;
    height: 44px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.login-btn:hover {
    background: var(--primary-hover);
}

/* ===== RESPONSIVE MOBILE SEARCH ===== */
@media (max-width: 992px) {
    .main-nav {
        display: none;
    }

    .menu-toggle {
        display: flex;
    }

    /* ✅ Search bar mobile - ẨN mặc định */
    .header-center {
        position: absolute;
        top: 100%; /* Nằm ngay dưới header */
        left: 0;
        right: 0;
        padding: 15px 20px;
        background: var(--bg);
        border-bottom: 2px solid var(--line);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 999;

        /* ẨN ban đầu */
        display: none;
        opacity: 0;
        transform: translateY(-20px);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* ✅ HIỆN khi có class .show */
    .header-center.show {
        display: flex !important;
        opacity: 1 !important;
        transform: translateY(0) !important;
    }

    /* Search input full width */
    .header-search {
        width: 100%;
        max-width: 100%;
        margin: 0;
        height: 48px;
        padding: 0 20px;
        border: 2px solid var(--line);
        background: #fff;
        box-shadow: 0 2px 8px rgba(143, 44, 36, 0.1);
    }

    .header-search:focus-within {
        border-color: var(--primary);
        box-shadow: 0 4px 12px rgba(143, 44, 36, 0.2);
    }

    .header-search__icon {
        font-size: 22px;
    }

    .header-search__input {
        font-size: 16px;
        color: var(--text);
    }

    .header-search__input::placeholder {
        color: #999;
    }

    /* ✅ HIỆN icon tìm kiếm trên mobile */
    .search-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 8px;
        transition: all 0.3s ease;
    }

    .search-toggle:hover {
        transform: scale(1.1);
    }

    .search-toggle:active {
        transform: scale(0.95);
    }

    /* Responsive brand */
    .brand__name {
        font-size: 18px;
    }

    .brand__logo {
        width: 42px;
        height: 42px;
    }
}

/* ===== MOBILE SMALL ===== */
@media (max-width: 576px) {
    :root {
        --header-h: 60px;
        --page-padding: 15px;
    }

    .site-header__inner {
        gap: 10px;
    }

    .header-left {
        gap: 10px;
    }

    .brand__logo {
        width: 38px;
        height: 38px;
    }

    .brand__name {
        font-size: 16px;
    }

    .login-btn {
        font-size: 12px;
        padding: 0 16px;
        height: 38px;
    }

    .cart {
        font-size: 20px;
    }

    .header-right {
        gap: 8px;
    }

    .search-toggle {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    /* Search bar mobile small */
    .header-center {
        padding: 12px 15px;
    }

    .header-search {
        height: 44px;
        padding: 0 16px;
    }

    .header-search__icon {
        font-size: 20px;
    }

    .header-search__input {
        font-size: 15px;
    }
}

/* ===== MOBILE SMALL ===== */
@media (max-width: 576px) {
    :root {
        --header-h: 60px;
        --page-padding: 15px;
    }

    .site-header__inner {
        gap: 12px;
    }

    .header-left {
        gap: 12px;
    }

    .brand__logo {
        width: 38px;
        height: 38px;
    }

    .brand__name {
        font-size: 16px;
    }

    .login-btn {
        font-size: 12px;
        padding: 0 16px;
        height: 38px;
    }

    .cart {
        font-size: 22px;
    }

    .header-right {
        gap: 10px;
    }

    /* Search bar full width */
    .header-center {
        padding: 10px 12px;
    }

    .header-search {
        max-width: 100%;
    }
}