/* ==================== ROOT & GLOBAL ==================== */
:root {
    --header-bg: #ffffff;
    --primary-color: #3C2F27;
    --primary-soft: rgba(60, 47, 39, 0.7);
    --hover-color: #5a463a;
    --bg-body: #F9F6F0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Quicksand", sans-serif;
}

body {
    background-color: var(--bg-body);
}

/* ==================== NAVBAR ==================== */
.navbar {
    background: var(--header-bg) !important;
    padding: 12px 0 !important;
    border-bottom: 1px solid #eee;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* LOGO */
.navbar-brand {
    color: var(--primary-color) !important;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 2rem;
    margin-right: 12px;
    color: var(--primary-color);
}

.brand-name {
    font-weight: 700;
    font-size: 1.6rem;
    line-height: 1.1;
}

.slogan {
    font-size: 0.75rem;
    color: var(--primary-soft);
}

/* MENU */
.navbar-nav .nav-link {
    font-weight: 700;
    color: var(--primary-color) !important;
    margin: 0 10px;
    padding: 8px 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    position: relative;
}

.navbar-nav .nav-link::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: 0.3s ease;
    transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after,
.navbar-nav .nav-link.active::after {
    width: 100%;
}

/* ==================== NAV PHONE ==================== */
.nav-phone {
    border-right: 1.5px solid #e8e1d9;
    padding-right: 16px;
    line-height: 1.3;
}

.nav-phone-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary-soft);
}

.nav-phone-number {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s;
}

.nav-phone-number:hover {
    color: var(--hover-color);
}

.nav-phone-number .fa-phone-alt {
    font-size: 0.78rem;
}

/* ==================== ICONS ==================== */
.icon-action {
    color: var(--primary-color) !important;
    background: none;
    border: none;
    font-size: 1.2rem;
    padding: 5px;
    transition: 0.3s;
}

.icon-action:hover {
    color: var(--hover-color) !important;
}

#cart-badge {
    background: var(--primary-color) !important;
    color: white !important;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    transition: transform 0.2s, opacity 0.2s;
}


#cart-badge:empty,
#cart-badge[data-count="0"] {
    display: none !important;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--primary-color);
}

/* ==================== SEARCH DROPDOWN (HOVER EFFECT) ==================== */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #ffffff;
    border-bottom: 3px solid var(--primary-color);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);

    /* Ẩn mặc định */
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
}

/* Khi có class active (thông qua JS hover) */
.search-dropdown.active {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.search-form-full {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-form-full .form-control {
    border: 1.2px solid #ddd;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1rem;
}

.search-form-full .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(60, 47, 39, 0.1);
}

.btn-submit-search {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-weight: 700;
    transition: 0.3s;
    white-space: nowrap;
}

.btn-submit-search:hover {
    background: var(--hover-color);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 991.98px) {
    .navbar-nav {
        margin: 20px 0 !important;
    }

    .search-dropdown {
        position: static; /* Trên mobile cho nằm cố định khi mở menu */
        box-shadow: none;
        border-top: 1px solid #eee;
    }

    #global-toast-container {
        top: auto;
        bottom: 20px; /* tren mobile hien o duoi man hinh cho dep hon */
        right: 10px;
        left: 10px;
    }

    .global-toast {
        min-width: unset;
        max-width: 100%;
    }
}

/* ==================== SEARCH SUGGESTIONS DROPDOWN ==================== */
.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-soft);
    pointer-events: none;
    z-index: 1;
}

.search-input-field {
    padding-left: 42px !important; /* chỗ cho icon */
    border: 1.2px solid #ddd;
    padding-top: 12px;
    padding-bottom: 12px;
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
}

.search-input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(60, 47, 39, 0.1);
    outline: none;
}

/* Hộp gợi ý */
.search-suggestions-box {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e8e1d9;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(60, 47, 39, 0.15);
    z-index: 1050;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;

    /* Ẩn mặc định */
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    scrollbar-width: thin;
    scrollbar-color: #d4c4b5 transparent;
}

.search-suggestions-box.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.search-suggestions-box::-webkit-scrollbar {
    width: 5px;
}

.search-suggestions-box::-webkit-scrollbar-track {
    background: transparent;
}

.search-suggestions-box::-webkit-scrollbar-thumb {
    background: #d4c4b5;
    border-radius: 99px;
}

/* Item gợi ý */
.suggest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f5f0eb;
    transition: background 0.15s ease;
    cursor: pointer;
}

.suggest-item:last-child {
    border-bottom: none;
}

.suggest-item:hover {
    background: #faf6f2;
    text-decoration: none;
}

.suggest-img-wrap {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f5f0eb;
}

.suggest-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.suggest-item:hover .suggest-img {
    transform: scale(1.05);
}

.suggest-info {
    flex: 1;
    min-width: 0; /* fix text overflow */
}

.suggest-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggest-price-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.suggest-price {
    font-size: 0.88rem;
    font-weight: 700;
    color: #c0392b;
}

.suggest-price-original {
    font-size: 0.78rem;
    color: #aaa;
    text-decoration: line-through;
}

.suggest-arrow {
    font-size: 0.7rem;
    color: #ccc;
    flex-shrink: 0;
}

/* Loading */
.suggest-loading, .suggest-empty {
    padding: 16px 20px;
    font-size: 0.88rem;
    color: var(--primary-soft);
    text-align: center;
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #e0d6cc;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

#global-toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.global-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 380px;
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(.22, 1, .36, 1), opacity 0.35s;
    border-left: 4px solid #8B4513;
    font-family: 'Quicksand', sans-serif;
}

.global-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.global-toast.success {
    border-left-color: #2e9e5b;
}

.global-toast.error {
    border-left-color: #e04040;
}

.global-toast .gt-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.global-toast.success .gt-icon {
    color: #2e9e5b;
}

.global-toast.error .gt-icon {
    color: #e04040;
}

.global-toast .gt-msg {
    font-size: 14px;
    font-weight: 600;
    color: #3c2f27;
    flex: 1;
}

.global-toast .gt-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 16px;
    padding: 0;
    line-height: 1;
}

.global-toast .gt-close:hover {
    color: #555;
}

.global-toast .gt-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 0 10px;
    background: #8B4513;
    animation: gtBarAnim 3.5s linear forwards;
}

.global-toast.success .gt-bar {
    background: #2e9e5b;
}

.global-toast.error .gt-bar {
    background: #e04040;
}

@keyframes gtBarAnim {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== RESPONSIVE SEARCH SUGGESTIONS & DROPDOWN ==================== */

/* ==================== CATEGORY DROPDOWN ====================
   Phân tích màu Header:
   --primary-color: #3C2F27 | --hover-color: #5a463a
   --header-bg: #ffffff    | hover-bg: #faf6f2
   border/divider: #e8e1d9 | font: Quicksand
   ========================================================== */

/* --- WRAPPER NAV ITEM --- */
.nav-item-dropdown {
    position: relative;
}

/* Chevron icon quay khi mở */
.nav-chevron {
    font-size: 0.58rem;
    margin-left: 5px;
    vertical-align: middle;
    transition: transform 0.25s ease;
    display: inline-block;
}

/* --- DROPDOWN PANEL (Desktop: absolute) --- */
.category-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    transform: translateY(-6px);
    width: 230px;
    background: #ffffff;
    border: 1px solid #e8e1d9;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(60, 47, 39, 0.13);

    /* Hidden by default */
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
    z-index: 998;
}

.category-dropdown.active {
    visibility: visible;
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0s;
}

/* --- LIST --- */
.category-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

.category-dropdown-item {
    border-bottom: none;
}

/* --- LINK ITEM --- */
.category-dropdown-link {
    display: block;
    padding: 9px 16px;
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Quicksand', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-dropdown-link span {
    position: relative;
    display: inline-block;
}

/* Gạch chân chạy từ trái qua phải */
.category-dropdown-link span::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.category-dropdown-link:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.category-dropdown-link:hover span::after {
    width: 100%;
}

/* --- SKELETON LOADING --- */
.category-dropdown-item.skeleton {
    height: 34px;
    margin: 5px 14px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f5f0eb 25%, #ede8e2 50%, #f5f0eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}

/* --- MOBILE (≤ 991px): expand/collapse in-place --- */
@media (max-width: 991.98px) {
    .category-dropdown {
        position: static;
        width: 100%;
        transform: none !important;
        box-shadow: none;
        border-top: none;
        border-radius: 0;
        margin: 4px 0 4px 8px;
        background: #ffffff;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.28s ease, opacity 0.22s ease, visibility 0s linear 0.22s;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .category-dropdown.active {
        max-height: 600px;
        opacity: 1;
        visibility: visible;
        pointer-events: all;
        transition: max-height 0.28s ease, opacity 0.22s ease, visibility 0s linear 0s;
    }

    .category-dropdown-link {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    .category-dropdown-divider {
        margin: 2px 10px;
    }
}
/* ==================== KEYFRAMES (giữ lại) ==================== */
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==================== RESPONSIVE SEARCH / SUGGEST (mobile ≤ 991px) ==================== */
@media (max-width: 991.98px) {
    .search-suggestions-box {
        border-radius: 8px;
        max-height: 320px;
    }

    .suggest-img-wrap {
        width: 44px;
        height: 44px;
    }
}