/* =============================================
   HEADER STYLES
   ============================================= */

/* ---- Topbar Dynamic Menu (wp_nav_menu) ---- */
.topbar-nav {
  display: flex;
  align-items: stretch;
  list-style: none;
  margin: 0; padding: 0;
  height: 34px;
  flex-direction: row;
  flex-wrap: nowrap;
}
.topbar-nav li {
  display: flex;
  align-items: stretch;
  position: relative;
  height: 34px;
}
.topbar-nav li + li::before {
  content: '';
  width: 1px;
  height: 16px;
  background: rgba(255,255,255,0.2);
  align-self: center;
  flex-shrink: 0;
}
.topbar-nav li a {
  color: rgba(255,255,255,0.82);
  font-size: 12px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 34px;
  white-space: nowrap;
  text-decoration: none;
  transition: color var(--trans-fast), background var(--trans-fast);
  line-height: 1;
}
.topbar-nav li a:hover {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}
.topbar-nav li.current-menu-item > a {
  color: var(--white);
  font-weight: 600;
}

/* ---- Top Bar (Shopee-style) ---- */
.header-topbar {
  background: #0a2a6e;          /* สีน้ำเงินเข้มกว่า primary-dark */
  color: rgba(255,255,255,0.82);
  font-size: 12px;
  padding: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.header-topbar .container {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  height: 34px;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 34px;
}
.topbar-link {
  color: rgba(255,255,255,0.82);
  transition: color var(--trans-fast), background var(--trans-fast);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  height: 100%;
  font-size: 12px;
  white-space: nowrap;
  text-decoration: none;
}
.topbar-link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}
/* user link มีไอคอน avatar */
.topbar-link--user { gap: 5px; }
/* notify มีจุดแดง */
.topbar-link--notify svg { color: #FFCC00; }
/* help มีไอคอนส้ม */
.topbar-link--help svg { color: #FF6600; }

.topbar-divider {
  width: 1px;
  height: 16px;
  background: rgba(255,255,255,0.2);
  align-self: center;
  flex-shrink: 0;
}

/* ---- Mobile: ซ่อน topbar ---- */
@media (max-width: 767px) {
  .header-topbar { display: none; }
}

/* ---- Main Header ---- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: box-shadow var(--trans-base);
}
.site-header.scrolled { box-shadow: 0 4px 16px rgba(0,0,0,0.2); }

.header-main { padding: 10px 0; }
.header-main .container {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* ---- Logo ---- */
.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--white);
  flex-shrink: 0;
  text-decoration: none;
}
.site-logo__icon {
  width: 38px; height: 38px;
  background: var(--white);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -1px;
}
.site-logo__text {
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.5px;
}

/* ---- Search Bar ---- */
.header-search {
  flex: 1;
  position: relative;
  max-width: 700px;
}
.header-search__form {
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-search__input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  font-size: 14px;
  outline: none;
  color: var(--black);
  background: var(--white);
}
.header-search__input::placeholder { color: var(--gray-400); }
.header-search__btn {
  background: var(--accent);
  color: var(--white);
  padding: 0 20px;
  border: none;
  cursor: pointer;
  font-size: 18px;
  transition: background var(--trans-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.header-search__btn:hover { background: var(--accent-hover); }

.header-search__dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 600;
  overflow: hidden;
  display: none;
}
.header-search__dropdown.show { display: block; }
.search-suggestion {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--trans-fast);
  font-size: 13px;
}
.search-suggestion:hover { background: var(--gray-50); }
.search-suggestion__thumb {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--gray-100);
  flex-shrink: 0;
}
.search-suggestion__title { flex: 1; color: var(--black); }
.search-suggestion__price { color: var(--accent); font-weight: 600; }

/* ---- Header Actions ---- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.header-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  color: var(--white);
  border-radius: var(--radius-sm);
  transition: background var(--trans-fast);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  text-decoration: none;
}
.header-action-btn:hover { background: rgba(255,255,255,0.15); }
.header-action-btn .icon { font-size: 22px; line-height: 1; }
.header-action-btn .label { font-size: 11px; }

.action-badge {
  position: absolute;
  top: 2px; right: 4px;
  background: var(--accent);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* ---- Category Nav ---- */
.header-categories {
  background: var(--primary-dark);
  border-top: 1px solid rgba(255,255,255,0.1);
}
.categories-nav {
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.categories-nav::-webkit-scrollbar { display: none; }
.category-nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  color: rgba(255,255,255,0.88);
  font-size: 13px;
  white-space: nowrap;
  transition: all var(--trans-fast);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.category-nav-item:hover, .category-nav-item.active {
  color: var(--white);
  border-bottom-color: var(--white);
  background: rgba(255,255,255,0.1);
}
.category-nav-item .cat-icon { font-size: 16px; }

/* ---- Mobile Header ---- */
@media (max-width: 767px) {
  .page-wrapper { padding-top: calc(var(--header-h-mob) + 48px); }

  .header-topbar { display: none; }

  .header-main { padding: 8px 0; }
  .header-main .container {
    flex-wrap: wrap;
    gap: 8px;
  }

  .site-logo__text { font-size: 18px; }
  .site-logo__icon { width: 32px; height: 32px; font-size: 18px; }

  .header-search { order: 3; max-width: 100%; width: 100%; flex: none; }

  .header-action-btn .label { display: none; }
  .header-action-btn { padding: 4px 8px; }

  .header-categories { display: none; }

  /* Mobile category bar below header */
  .mobile-category-bar {
    display: flex !important;
    background: var(--white);
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--gray-200);
    position: fixed;
    top: var(--header-h-mob);
    left: 0; right: 0;
    z-index: 499;
  }
  .mobile-category-bar::-webkit-scrollbar { display: none; }
  .mobile-cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    font-size: 11px;
    color: var(--gray-800);
    white-space: nowrap;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--trans-fast);
  }
  .mobile-cat-item.active { color: var(--primary); border-bottom-color: var(--primary); }
  .mobile-cat-item .icon { font-size: 18px; }
}

@media (min-width: 768px) {
  .mobile-category-bar { display: none; }
  .page-wrapper { padding-top: var(--header-h); }
}
