﻿/* ================= HEADER CHUNG ================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #020617;
    border-bottom: 1px solid #020617;
    box-shadow: 0 18px 46px rgba(15, 23, 42, 0.95);
}

.nav {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0;
}

/* ========== MOBILE TOGGLE ========== */

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #020617;
    cursor: pointer;
}

.nav-toggle span {
    height: 2px;
    width: 16px;
    border-radius: 999px;
    background: #e5e7eb;
}

/* ========== CẤU TRÚC 3 CỘT ========== */

.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-left {
    min-width: fit-content;
}

.nav-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.nav-right {
    min-width: fit-content;
    justify-content: flex-end;
}

/* ========== LOGO ========== */

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo-mark {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 0, #38bdf8, #1e40af);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e5f2ff;
    font-weight: 700;
}

.logo-text-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.logo-subtitle {
    font-size: 0.7rem;
    color: #9ca3af;
}

/* ========== NÚT ĐĂNG NHẬP / BẮT ĐẦU ========== */

.nav-link.nav-login {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: #020617;
    font-size: 0.82rem;
    color: #e5e7eb;
    text-decoration: none;
    transition: 0.18s ease;
}

.nav-link.nav-login:hover {
    border-color: var(--accent);
    color: #e5f2ff;
}

.nav-cta.btn-primary {
    padding: 7px 16px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    text-decoration: none;
    background: linear-gradient(135deg, #0ea5e9, #22c55e);
    color: #0b1220;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.18s ease;
}

.nav-cta.btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

/* ========== MENU CHÍNH ========== */

.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.nav-menu a {
    text-decoration: none;
    color: #e5e7eb;
    padding: 6px 8px;
    border-radius: 999px;
    transition: 0.16s ease;
    white-space: nowrap;
}

.nav-menu a:hover {
    background: rgba(15, 23, 42, 0.9);
    color: #e5f2ff;
}

.nav-menu a.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(34, 197, 94, 0.15));
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    font-weight: 600;
}

/* ========== SEARCH BAR TRONG HEADER ========== */

.nav-search-wrap {
    position: relative;
    flex: 1;
    max-width: 320px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #020617;
    border: 1px solid rgba(30, 64, 175, 0.6);
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.9);
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.9rem;
}

.search-input::placeholder {
    color: var(--text-soft);
}

/* Gợi ý tìm kiếm */

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #020617;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    margin-top: 6px;
    padding: 6px 0;
    box-shadow: var(--shadow-soft);
    display: none;
    z-index: 40;
}

.search-suggestions.visible {
    display: block;
}

.search-suggestions button {
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-soft);
    background: transparent;
    border-radius: 10px;
}

.search-suggestions button:hover {
    background: rgba(30, 64, 175, 0.35);
    color: #e5f2ff;
}

/* ========== ICON WISHLIST / CART ========== */

.nav-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: var(--text-soft);
    transition: var(--transition-normal);
}

.nav-icon-btn:hover {
    background: rgba(30, 64, 175, 0.65);
    color: #e5f2ff;
}

.nav-icon-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #f97316;
    color: #fff;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ========== CART DROPDOWN ========== */

.nav-cart-wrap {
    position: relative;
}

.cart-dropdown {
    position: absolute;
    right: 0;
    top: 120%;
    width: 260px;
    background: #020617;
    border-radius: 18px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    padding: 10px;
    display: none;
    z-index: 40;
    font-size: 0.8rem;
}

.cart-dropdown.visible {
    display: block;
}

.cart-items {
    max-height: 230px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
}

.cart-empty {
    color: var(--text-soft);
    font-size: 0.8rem;
}

.cart-item-row {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.cart-item-row span:first-child {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-summary {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-weight: 500;
}

.cart-dropdown .btn-primary {
    width: 100%;
    justify-content: center;
    font-size: 0.8rem;
    padding: 7px 0;
}

/* ========== RESPONSIVE HEADER ========== */

@media (max-width: 900px) {
    .nav {
        gap: 10px;
    }

    .nav-toggle {
        display: flex;
    }

    .nav-center {
        display: none;
        /* ẩn menu desktop, sau này nếu muốn mở menu mobile thì dùng JS thêm class */
    }

    .nav-right {
        flex: 1;
        justify-content: flex-end;
    }

    .nav-search-wrap {
        display: none;
        /* cho đỡ chật ở mobile, sau này cần thì bật lại */
    }
}

/* (Đã xóa: page-index nav-search/wishlist/cart — không còn dùng) */

/* =========================================
   USER + WALLET Ở BÊN TRÁI HEADER
========================================= */

.nav-left-auth {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* User chip */

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: radial-gradient(circle at top left,
            rgba(148, 163, 184, 0.25),
            rgba(15, 23, 42, 0.98));
    color: var(--text-main, #e5e7eb);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease,
        border-color 0.18s ease, background 0.18s ease;
}

.user-chip:hover {
    transform: translateY(-1px);
    border-color: rgba(129, 140, 248, 0.7);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.8);
}

.user-chip-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
    background: radial-gradient(circle at top,
            #38bdf8,
            #1d4ed8);
    border: 2px solid rgba(15, 23, 42, 0.9);
}

.user-chip-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.user-chip-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-chip-role {
    font-size: 0.7rem;
    color: var(--text-soft, #9ca3af);
}

/* Wallet pill */

.wallet-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: radial-gradient(circle at top right,
            rgba(56, 189, 248, 0.3),
            rgba(15, 23, 42, 0.98));
    color: #e5f4ff;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease,
        border-color 0.18s ease, background 0.18s ease;
}

.wallet-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 30px rgba(8, 47, 73, 0.9);
    border-color: rgba(56, 189, 248, 0.8);
}

.wallet-pill-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.wallet-pill-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.9;
}

.wallet-pill-sub {
    font-size: 0.7rem;
    color: rgba(226, 232, 240, 0.7);
}

.wallet-pill-amount {
    display: flex;
    align-items: center;
    justify-content: center;
}

.wallet-pill-balance {
    font-size: 0.95rem;
    font-weight: 700;
    text-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
}

/* Mobile tạm thu nhỏ lại, sau này mình tối ưu tiếp */
@media (max-width: 768px) {
    .nav-left-auth {
        gap: 8px;
    }

    .user-chip {
        padding: 4px 8px;
    }

    .user-chip-role {
        display: none;
    }

    .wallet-pill-sub {
        display: none;
    }
}

@media (max-width: 480px) {
    .nav {
        gap: 8px;
    }

    .nav-right {
        gap: 8px;
    }

    /* Ẩn tên logo, chỉ giữ chữ K để tiết kiệm chỗ */
    .logo-title {
        display: none;
    }

    /* Nav-left khi chưa đăng nhập */
    .nav-link.nav-login {
        padding-inline: 8px;
        font-size: 0.78rem;
    }

    .nav-cta.btn-primary {
        padding: 6px 12px;
        font-size: 0.78rem;
    }

    /* Nav-left khi đã đăng nhập */
    .nav-left-auth {
        gap: 6px;
    }

    .user-chip-name {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .wallet-pill {
        padding: 6px 10px;
        gap: 6px;
    }

    .wallet-pill-label {
        display: none;
    }

    .wallet-pill-balance {
        font-size: 0.85rem;
    }

    /* Cart dropdown không tràn màn hình */
    .cart-dropdown {
        width: calc(100vw - 28px);
        right: -8px;
    }
}

/* NAV RIGHT – logo + nút 3 gạch đứng cùng hàng */
.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Nút 3 gạch trong header */
.sidebar-toggle-btn {
    margin-left: 4px;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.9);
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.sidebar-toggle-btn span {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: #e5e7eb;
}

.sidebar-toggle-btn:hover {
    background: rgba(37, 99, 235, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.7);
}

/* (Đã xóa: sidebar-toggle-btn fixed — nút 3 gạch nằm trong header flow trên mọi trang) */

/* ============ MENU 3 GẠCH DASHBOARD ============ */

.dash-flyout {
    position: fixed;
    top: 0;
    right: -320px;
    /* ẩn ban đầu */
    width: 300px;
    height: 100vh;
    padding: 18px 18px 20px;
    background: radial-gradient(circle at top left, #1e293b, #020617);
    box-shadow: -24px 0 60px rgba(15, 23, 42, 0.95);
    border-left: 1px solid rgba(148, 163, 184, 0.4);
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: right 0.28s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.28s ease;
    opacity: 0;
}

.dash-flyout.is-open {
    right: 0;
    opacity: 1;
}

/* overlay click ra ngoài để tắt */
.dash-flyout-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    opacity: 0;
    pointer-events: none;
    z-index: 49;
    transition: opacity 0.25s ease;
}

.dash-flyout-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Header trong panel */
.dash-flyout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
}

.dash-flyout-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dash-flyout-title {
    font-size: 1rem;
    font-weight: 600;
    color: #e5e7eb;
}

.dash-flyout-subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* nút X đóng */
.dash-flyout-close {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.dash-flyout-close:hover {
    background: rgba(37, 99, 235, 0.95);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.7);
    transform: translateY(-1px);
}

/* Danh sách menu */
.dash-flyout-nav {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.dash-flyout-footer {
    border-top: 1px solid rgba(148, 163, 184, 0.3);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* item chung (dùng cho cả <a> và <button>) */
.dash-flyout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 12px;
    text-decoration: none;
    color: #e5e7eb;
    font-size: 0.9rem;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.dash-flyout-link:hover {
    background: radial-gradient(circle at top left,
            rgba(59, 130, 246, 0.28),
            rgba(15, 23, 42, 0.98));
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.9);
    transform: translateY(-1px);
}

.dash-flyout-icon {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}



.dash-flyout-link.is-active .dash-flyout-icon {
    background: rgba(15, 23, 42, 0.95);
}

.dash-flyout-link-danger {
    color: #fecaca;
}

.dash-flyout-link-danger:hover {
    background: radial-gradient(circle at top left,
            rgba(248, 113, 113, 0.25),
            rgba(15, 23, 42, 1));
}

/* Cho mobile nếu muốn panel rộng hơn chút */
@media (max-width: 768px) {
    .dash-flyout {
        width: 280px;
    }
}

/* ========== CHAT ICON BUTTON ========== */

.nav-chat-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    color: #9ca3af;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s, color 0.2s;
    flex-shrink: 0;
}

.nav-chat-btn:hover {
    background: rgba(37, 99, 235, 0.9);
    color: #e5f2ff;
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.7);
}

.nav-chat-btn svg {
    width: 18px;
    height: 18px;
}

.chat-unread-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #020617;
    display: none;
    animation: chatDotPulse 1.8s ease-in-out infinite;
}

.chat-unread-dot.visible {
    display: block;
}

@keyframes chatDotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.25); opacity: 0.8; }
}

/* ========== USER DROPDOWN ========== */

.nav-user-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-chip-arrow {
    font-size: 0.7rem;
    color: var(--text-soft, #9ca3af);
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.user-chip[aria-expanded="true"] .user-chip-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 220px;
    background: #1e1f20;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: none;
    animation: dropdownIn 0.18s ease;
}

.user-dropdown.is-open {
    display: block;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 10px;
}

.user-dropdown-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(56, 189, 248, 0.4);
    flex-shrink: 0;
}

.user-dropdown-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e5e7eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.user-dropdown-email {
    font-size: 0.75rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.user-dropdown-divider {
    height: 1px;
    background: rgba(148, 163, 184, 0.12);
    margin: 4px 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 10px;
    font-size: 0.875rem;
    color: #d1d5db;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.user-dropdown-item:hover {
    background: rgba(30, 64, 175, 0.35);
    color: #e5f2ff;
}

.user-dropdown-logout {
    color: #fca5a5;
}

.user-dropdown-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}