/* ==========================================================================
   Toplist Header Scoped CSS
   Được đóng gói hoàn toàn dưới selector .tl-header-root
   Đảm bảo 100% không xung đột CSS với Theme & Plugins khác của WordPress
   ========================================================================== */

/* 1. CSS VARIABLES (Hỗ trợ thay đổi màu từ Admin Settings) */
.tl-header-root {
  --tl-brand-blue: #0052cc;
  --tl-brand-hover: #0043aa;
  --tl-brand-light: #eff6ff;
  --tl-brand-subtle: #f0f7ff;
  
  --tl-bg-white: #ffffff;
  --tl-bg-light: #f8fafc;
  --tl-text-dark: #0f295b;
  --tl-text-heading: #1e293b;
  --tl-text-body: #475569;
  --tl-text-muted: #64748b;
  --tl-text-light: #94a3b8;
  
  --tl-border-light: #e2e8f0;
  --tl-border-subtle: #edf2f7;
  
  --tl-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --tl-shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.08);
  --tl-shadow-lg: 0 20px 48px -8px rgba(0, 48, 130, 0.12);
  
  --tl-radius-sm: 6px;
  --tl-radius-md: 10px;
  --tl-radius-lg: 16px;
  --tl-radius-pill: 9999px;
  
  --tl-transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --tl-font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  font-family: var(--tl-font-family);
  color: var(--tl-text-body);
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

/* Reset nội bộ cho root */
.tl-header-root *,
.tl-header-root *::before,
.tl-header-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.tl-header-root a {
  text-decoration: none;
  color: inherit;
  transition: color var(--tl-transition), background-color var(--tl-transition);
}

.tl-header-root button,
.tl-header-root input {
  font-family: inherit;
}

.tl-header-root ul {
  list-style: none;
}

/* Container căn giữa nội dung */
.tl-header-root .tl-container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}


/* ==========================================================================
   2. TOPBAR MÀU XANH DƯƠNG (DESKTOP)
   ========================================================================== */
.tl-header-root .tl-topbar {
  background-color: var(--tl-brand-blue);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  padding: 9px 0;
  transition: all var(--tl-transition);
}

.tl-header-root .tl-topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tl-header-root .tl-topbar-announcement {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tl-header-root .tl-icon-megaphone {
  flex-shrink: 0;
  opacity: 0.95;
}

.tl-header-root .tl-announcement-text {
  letter-spacing: -0.1px;
}

.tl-header-root .tl-topbar-auth {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tl-header-root .tl-auth-link {
  color: #ffffff;
  opacity: 0.92;
}

.tl-header-root .tl-auth-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.tl-header-root .tl-auth-divider {
  opacity: 0.45;
  font-size: 11px;
}


/* ==========================================================================
   3. MAIN HEADER (LOGO, SEARCH, ACTIONS)
   ========================================================================== */
.tl-header-root .tl-main-header {
  background-color: var(--tl-bg-white);
  border-bottom: 1px solid var(--tl-border-subtle);
  padding: 16px 0;
  transition: all var(--tl-transition);
}

.tl-header-root .tl-main-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

/* 3.1 Logo thương hiệu */
.tl-header-root .tl-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--tl-brand-blue);
  flex-shrink: 0;
}

.tl-header-root .tl-logo-svg {
  flex-shrink: 0;
}

.tl-header-root .tl-logo-text {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.6px;
}

/* 3.2 Thanh tìm kiếm Search Bar */
.tl-header-root .tl-search-bar {
  flex: 1;
  max-width: 580px;
}

.tl-header-root .tl-search-input-group {
  display: flex;
  align-items: center;
  position: relative;
  background-color: #ffffff;
  border: 1.5px solid #dce4ee;
  border-radius: var(--tl-radius-pill);
  padding: 3px 4px 3px 18px;
  transition: border-color var(--tl-transition), box-shadow var(--tl-transition);
}

.tl-header-root .tl-search-input-group:focus-within {
  border-color: var(--tl-brand-blue);
  box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.12);
}

.tl-header-root .tl-search-icon {
  color: var(--tl-text-light);
  flex-shrink: 0;
  margin-right: 10px;
}

.tl-header-root .tl-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  color: var(--tl-text-heading);
}

.tl-header-root .tl-search-input::placeholder {
  color: var(--tl-text-light);
}

.tl-header-root .tl-search-btn {
  background-color: var(--tl-brand-blue);
  color: #ffffff;
  border: none;
  border-radius: var(--tl-radius-pill);
  padding: 8px 22px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--tl-transition);
}

.tl-header-root .tl-search-btn:hover {
  background-color: var(--tl-brand-hover);
}

/* 3.3 Nhóm Actions (Vị trí, Yêu thích, Chuông, Tài khoản) */
.tl-header-root .tl-actions-group {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.tl-header-root .tl-action-item {
  position: relative;
}

.tl-header-root .tl-action-btn,
.tl-header-root .tl-btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--tl-text-heading);
  font-size: 13.5px;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  transition: color var(--tl-transition);
}

.tl-header-root .tl-action-btn:hover,
.tl-header-root .tl-btn-icon-text:hover {
  color: var(--tl-brand-blue);
}

.tl-header-root .tl-chevron {
  color: var(--tl-text-muted);
  transition: transform var(--tl-transition);
}

/* Chuông thông báo */
.tl-header-root .tl-btn-notification {
  background: transparent;
  border: none;
  color: var(--tl-text-heading);
  cursor: pointer;
  position: relative;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--tl-transition);
}

.tl-header-root .tl-btn-notification:hover {
  color: var(--tl-brand-blue);
}

.tl-header-root .tl-badge-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

/* Dropdown chọn vị trí */
.tl-header-root .tl-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 170px;
  background-color: #ffffff;
  border: 1px solid var(--tl-border-light);
  border-radius: var(--tl-radius-md);
  box-shadow: var(--tl-shadow-md);
  padding: 6px 0;
  display: none;
  z-index: 1000;
}

.tl-header-root .tl-location-dropdown.is-active .tl-dropdown-menu {
  display: block;
}

.tl-header-root .tl-location-dropdown.is-active .tl-chevron {
  transform: rotate(180deg);
}

.tl-header-root .tl-dropdown-item {
  display: block;
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--tl-text-body);
}

.tl-header-root .tl-dropdown-item:hover,
.tl-header-root .tl-dropdown-item.active {
  background-color: var(--tl-brand-light);
  color: var(--tl-brand-blue);
}


/* ==========================================================================
   4. NAVBAR & MEGA MENU (DESKTOP)
   ========================================================================== */
.tl-header-root .tl-navbar {
  background-color: var(--tl-bg-white);
  border-bottom: 1px solid var(--tl-border-subtle);
}

.tl-header-root .tl-nav-list {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tl-header-root .tl-nav-item {
  position: relative;
}

.tl-header-root .tl-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--tl-text-heading);
  border-radius: var(--tl-radius-sm);
  transition: all var(--tl-transition);
}

.tl-header-root .tl-nav-link:hover {
  color: var(--tl-brand-blue);
  background-color: var(--tl-brand-light);
}

/* Nút Trang chủ Active */
.tl-header-root .tl-home-link.active {
  color: #ffffff;
  background-color: var(--tl-brand-blue);
}

/* Nút Mega Menu khi Active */
.tl-header-root .tl-has-megamenu.is-active .tl-btn-mega,
.tl-header-root .tl-has-megamenu:hover .tl-btn-mega {
  color: #ffffff;
  background-color: var(--tl-brand-blue);
}

.tl-header-root .tl-has-megamenu.is-active .tl-btn-mega .tl-chevron,
.tl-header-root .tl-has-megamenu:hover .tl-btn-mega .tl-chevron {
  color: #ffffff;
  transform: rotate(180deg);
}

/* 4.1 BẢNG MEGA MENU 4 CỘT (DESKTOP) */
.tl-header-root .tl-megamenu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  width: 960px;
  background-color: var(--tl-bg-white);
  border-radius: 0 0 var(--tl-radius-lg) var(--tl-radius-lg);
  border: 1px solid var(--tl-border-light);
  border-top: none;
  box-shadow: var(--tl-shadow-lg);
  padding: 24px 28px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 999;
}

.tl-header-root .tl-has-megamenu:hover .tl-megamenu-panel,
.tl-header-root .tl-has-megamenu.is-active .tl-megamenu-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.tl-header-root .tl-megamenu-grid {
  display: grid;
  grid-template-columns: 240px 1.15fr 1fr 1.25fr;
  gap: 28px;
}

/* Cột 1: Hero Card giới thiệu */
.tl-header-root .tl-mega-hero-card {
  background: linear-gradient(180deg, #f0f7ff 0%, #e2efff 100%);
  border-radius: var(--tl-radius-md);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tl-header-root .tl-hero-icon-box {
  width: 52px;
  height: 52px;
  background-color: #ffffff;
  border-radius: var(--tl-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 82, 204, 0.12);
  margin-bottom: 16px;
}

.tl-header-root .tl-hero-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--tl-brand-blue);
  margin-bottom: 8px;
}

.tl-header-root .tl-hero-desc {
  font-size: 13px;
  color: var(--tl-text-body);
  line-height: 1.55;
  margin-bottom: 20px;
}

.tl-header-root .tl-hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: #ffffff;
  color: var(--tl-brand-blue);
  border: 1.5px solid #bfdbfe;
  border-radius: var(--tl-radius-pill);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  transition: all var(--tl-transition);
}

.tl-header-root .tl-hero-btn:hover {
  background-color: var(--tl-brand-blue);
  color: #ffffff;
  border-color: var(--tl-brand-blue);
}

/* Tiêu đề các cột mega menu */
.tl-header-root .tl-mega-col-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--tl-brand-blue);
  margin-bottom: 14px;
}

/* Danh sách link danh mục & tiêu chí */
.tl-header-root .tl-mega-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tl-header-root .tl-mega-links a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  font-size: 13.5px;
  color: var(--tl-text-body);
  border-radius: 6px;
}

.tl-header-root .tl-mega-links a:hover {
  background-color: var(--tl-brand-light);
  color: var(--tl-brand-blue);
}

.tl-header-root .tl-arr {
  color: var(--tl-text-light);
  transition: transform var(--tl-transition);
}

.tl-header-root .tl-mega-links a:hover .tl-arr {
  color: var(--tl-brand-blue);
  transform: translateX(3px);
}

/* Cột Thương hiệu */
.tl-header-root .tl-brand-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tl-header-root .tl-brand-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tl-text-heading);
  background-color: #f8fafc;
  transition: all var(--tl-transition);
}

.tl-header-root .tl-brand-item:hover {
  background-color: var(--tl-brand-light);
  color: var(--tl-brand-blue);
}

.tl-header-root .tl-brand-icon {
  font-size: 15px;
}

.tl-header-root .tl-view-all-brands {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--tl-brand-blue);
}

.tl-header-root .tl-view-all-brands:hover {
  text-decoration: underline;
}


/* ==========================================================================
   5. STICKY COMPACT STATE (KHI CUỘN TRANG)
   ========================================================================== */
.tl-header-root.is-compact {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9999;
  box-shadow: var(--tl-shadow-md);
  animation: tlSlideDown 0.3s ease;
}

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

.tl-header-root.is-compact .tl-topbar {
  display: none !important;
}

.tl-header-root.is-compact .tl-navbar {
  display: none !important;
}

.tl-header-root.is-compact .tl-main-header {
  padding: 10px 0;
  background-color: #ffffff;
}

.tl-header-root.is-compact .tl-logo-text {
  font-size: 23px;
}

.tl-header-root.is-compact .tl-search-input-group {
  padding: 2px 3px 2px 16px;
}

.tl-header-root.is-compact .tl-search-btn {
  padding: 6px 18px;
}


/* ==========================================================================
   6. MOBILE ELEMENTS (ẨN HOÀN TOÀN TRÊN DESKTOP)
   ========================================================================== */
.tl-header-root .tl-mobile-header,
.tl-header-root .tl-drawer-backdrop,
.tl-header-root .tl-drawer-sidebar,
.tl-header-root .tl-mobile-bottom-nav {
  display: none;
}

/* ==========================================================================
   7. CHẾ ĐỘ MOBILE (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Ẩn Header desktop trên mobile */
  .tl-header-root .tl-topbar,
  .tl-header-root .tl-main-header,
  .tl-header-root .tl-navbar {
    display: none !important;
  }

  /* Kích hoạt Mobile Header */
  .tl-header-root .tl-mobile-header {
    display: block;
    background-color: #ffffff;
    border-bottom: 1px solid var(--tl-border-subtle);
  }

  .tl-header-root .tl-mobile-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
  }

  .tl-header-root .tl-btn-mobile-menu,
  .tl-header-root .tl-btn-mobile-search {
    background: transparent;
    border: none;
    color: var(--tl-brand-blue);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
  }

  .tl-header-root .tl-logo-mobile .tl-logo-text {
    font-size: 22px;
  }

  /* Ô tìm kiếm mobile */
  .tl-header-root .tl-mobile-search-container {
    padding: 0 16px 12px 16px;
  }

  .tl-header-root .tl-mobile-search-form {
    display: flex;
    align-items: center;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--tl-radius-md);
    padding: 8px 14px;
    gap: 8px;
  }

  .tl-header-root .tl-mobile-search-form input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-size: 13.5px;
    color: var(--tl-text-heading);
  }

  /* 7.1 DRAWER SIDEBAR (MENU TRƯỢT TỪ TRÁI) */
  .tl-header-root .tl-drawer-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.5);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
  }

  .tl-header-root .tl-drawer-backdrop.is-open {
    opacity: 1;
    visibility: visible;
  }

  .tl-header-root .tl-drawer-sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 330px;
    height: 100%;
    background-color: #ffffff;
    z-index: 10001;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--tl-shadow-lg);
  }

  .tl-header-root .tl-drawer-sidebar.is-open {
    transform: translateX(0);
  }

  .tl-header-root .tl-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid #f1f5f9;
  }

  .tl-header-root .tl-drawer-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--tl-text-muted);
  }

  .tl-header-root .tl-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
  }

  .tl-header-root .tl-drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .tl-header-root .tl-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--tl-radius-md);
    font-size: 14.5px;
    font-weight: 600;
    color: var(--tl-text-heading);
  }

  .tl-header-root .tl-drawer-link.active {
    background-color: var(--tl-brand-light);
    color: var(--tl-brand-blue);
  }

  .tl-header-root .tl-drawer-link .tl-chevron-r {
    margin-left: auto;
    color: var(--tl-text-light);
  }

  .tl-header-root .tl-drawer-foot {
    padding: 18px 20px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .tl-header-root .tl-drawer-location {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--tl-text-heading);
  }

  .tl-header-root .tl-drawer-location .tl-chevron {
    margin-left: auto;
  }

  .tl-header-root .tl-drawer-auth-btns {
    display: flex;
    gap: 10px;
  }

  .tl-header-root .tl-btn-outline-login {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 0;
    border: 1.5px solid var(--tl-brand-blue);
    border-radius: var(--tl-radius-md);
    font-size: 13.5px;
    font-weight: 700;
    color: var(--tl-brand-blue);
  }

  .tl-header-root .tl-btn-fill-register {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 0;
    background-color: var(--tl-brand-blue);
    border: 1.5px solid var(--tl-brand-blue);
    border-radius: var(--tl-radius-md);
    font-size: 13.5px;
    font-weight: 700;
    color: #ffffff;
  }

  /* 7.2 MOBILE BOTTOM NAVIGATION BAR (APP STYLE) */
  .tl-header-root .tl-mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 62px;
    background-color: #ffffff;
    border-top: 1px solid #edf2f7;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
    justify-content: space-around;
    align-items: center;
    z-index: 9998;
  }

  .tl-header-root .tl-bottom-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--tl-text-muted);
    font-size: 11px;
    font-weight: 600;
    background: transparent;
    border: none;
    cursor: pointer;
    flex: 1;
    height: 100%;
  }

  .tl-header-root .tl-bottom-tab.active {
    color: var(--tl-brand-blue);
  }

  .tl-header-root .tl-bottom-tab.active .tl-tab-icon-wrap {
    color: var(--tl-brand-blue);
  }
}
