/* ==========================================================================
   CSS HEADER FINAL FIX - XANH TIKI HIỆN ĐẠI & CHUẨN KHUNG
   ========================================================================== */

/* --- 0. KHAI BÁO BIẾN MÀU --- */
:root {
    --primary-color: #0B74E5; /* Xanh Tiki chuẩn */
    --primary-hover: #085cb8; /* Xanh đậm khi di chuột */
    --text-color: #333;
    --border-radius: 8px; /* Bo góc mềm mại */
}

/* --- 1. CẤU TRÚC HEADER CHUNG --- */
.site-header {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100 !important;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.header-main {
    padding: 15px 0;
}

.header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

/* Logo */
.site-branding { flex-shrink: 0; }
.site-logo {
    height: 45px;
    width: auto;
    object-fit: contain;
    display: block;
}

/* --- 2. KHUNG TÌM KIẾM (ĐÃ FIX LỖI TRỜN KHUNG) --- */
.header-search-wrapper {
    flex-grow: 1;
    max-width: 750px;
    /* QUAN TRỌNG: Làm điểm tựa cho gợi ý bám vào */
    position: relative !important; 
    z-index: 10000;
    margin: 0 20px;
}

/* Form tìm kiếm chính */
form.shopee-search-form {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    height: 44px !important;
    background: #fff !important;
    border: 2px solid var(--primary-color) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: 0 2px 6px rgba(11, 116, 229, 0.15);
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 2;
}

/* Ô nhập liệu */
.search-input-box {
    flex-grow: 1;
    height: 100%;
    position: relative;
}

.search-field, 
input.search-field, 
input[type="search"] {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    padding: 0 15px !important;
    font-size: 15px !important;
    color: #333 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: var(--border-radius) 0 0 var(--border-radius) !important;
}

/* Nút tìm kiếm */
button.search-submit {
    width: 85px !important;
    height: 100% !important;
    background-color: var(--primary-color) !important;
    border: none !important;
    border-radius: 0 6px 6px 0 !important; /* Bo góc phải khớp border */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    transition: background 0.2s;
}

button.search-submit:hover {
    background-color: var(--primary-hover) !important;
}

button.search-submit i, 
button.search-submit svg {
    color: #fff !important;
    font-size: 18px !important;
}

/* --- 3. GỢI Ý TỪ KHÓA TĨNH (Dưới thanh search) --- */
.search-keywords {
    margin-top: 8px;
    padding-left: 2px;
    display: flex;
    gap: 15px;
}
.search-keywords a {
    color: #777;
    font-size: 13px;
    text-decoration: none;
    transition: 0.2s;
}
.search-keywords a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* --- 4. KHUNG LIVE SEARCH (GỢI Ý THẢ XUỐNG) --- */
/* Đây là phần sửa lỗi bị trờn ra ngoài */
#datafetch {
    display: none;
    position: absolute !important;
    top: 100% !important; /* Đẩy xuống đáy form */
    margin-top: 6px !important; /* Cách ra 6px cho đẹp */
    left: 0 !important; /* Căn trái 0 */
    width: 100% !important; /* Rộng bằng đúng 100% khung search */
    background: #fff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
    z-index: 99999 !important;
    max-height: 400px;
    overflow-y: auto;
}

/* Mũi tên tam giác nhỏ chỉ lên (Trang trí) */
#datafetch::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 30px;
    border-width: 0 6px 6px 6px;
    border-style: solid;
    border-color: transparent transparent #fff transparent;
}

.live-search-item {
    display: flex !important;
    align-items: center !important;
    padding: 12px 15px !important;
    border-bottom: 1px solid #f2f2f2 !important;
    color: #333 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    transition: all 0.2s !important;
}

.live-search-item:hover {
    background-color: #f5faff !important;
    color: var(--primary-color) !important;
    padding-left: 20px !important;
}

/* Label Danh mục/Sản phẩm */
.search-type-label {
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    background: #eff0f5 !important;
    color: #666 !important;
    padding: 3px 6px !important;
    border-radius: 4px;
    margin-right: 10px !important;
    min-width: 70px;
    text-align: center;
}

/* --- 5. ICONS (Cart/User) --- */
.header-actions {
    display: flex;
    gap: 30px;
    flex-shrink: 0;
}
.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #555;
    font-size: 13px;
    transition: 0.2s;
}
.action-item i {
    font-size: 22px;
    margin-bottom: 5px;
    color: #555;
}
.action-item:hover i, .action-item:hover .action-text {
    color: var(--primary-color);
    transform: translateY(-2px);
}
.icon-wrap { position: relative; }
.cart-count {
    position: absolute;
    top: -6px; right: -8px;
    background: #ff4757;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid #fff;
    font-weight: 700;
}

/* --- 6. MENU NGANG & MOBILE --- */
.header-bottom-nav {
    border-top: 1px solid #eee;
    margin-top: 5px;
    background: #fff;
}
.nav-menu {
    display: flex; list-style: none; margin: 0; padding: 0; gap: 40px;
}
.nav-menu li a {
    display: block; padding: 12px 0; 
    color: #333; text-decoration: none; 
    font-weight: 600; font-size: 15px; 
    text-transform: uppercase;
    position: relative;
}
.nav-menu li a:after {
    content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 3px;
    background: var(--primary-color); transition: 0.3s;
}
.nav-menu li a:hover:after { width: 100%; }
.nav-menu li a:hover { color: var(--primary-color); }

@media (max-width: 768px) {
    .header-flex { flex-wrap: wrap; gap: 15px; }
    .site-branding { order: 1; margin-right: auto; }
    .header-actions { order: 2; gap: 20px; }
    .action-text { display: none; }
    .header-search-wrapper { order: 3; width: 100%; max-width: 100%; margin: 10px 0; }
    .search-keywords { display: none; }
    .nav-menu { overflow-x: auto; white-space: nowrap; padding-bottom: 5px; }
    .nav-menu li a { padding: 10px 0; margin-right: 20px; font-size: 14px; }
}