/* ============================================================
   KQXS VIỆT NAM — UI v2.0
   Font: Be Vietnam Pro (Google Fonts)
   Design: Mobile-first, dark premium, glassmorphism
   ============================================================ */

/* ---- GOOGLE FONT import ở layout, bên dưới là fallback ---- */
:root {
  /* --- Brand Colors --- */
  --red:        #e8384f;
  --red-2:      #ff5566;
  --red-dim:    rgba(232, 56, 79, 0.18);
  --gold:       #f5c518;
  --gold-2:     #ffd84d;
  --gold-dim:   rgba(245, 197, 24, 0.15);
  --green:      #34d399;
  --blue:       #60a5fa;

  /* --- Backgrounds --- */
  --bg:         #09090f;
  --bg-2:       #111118;
  --bg-card:    rgba(17, 17, 28, 0.88);
  --bg-glass:   rgba(255, 255, 255, 0.04);
  --bg-hover:   rgba(255, 255, 255, 0.06);

  /* --- Borders --- */
  --border:     rgba(255, 255, 255, 0.07);
  --border-2:   rgba(255, 255, 255, 0.12);
  --border-red: rgba(232, 56, 79, 0.35);
  --border-gold:rgba(245, 197, 24, 0.30);

  /* --- Text --- */
  --t1: #f1f5f9;
  --t2: #94a3b8;
  --t3: #64748b;

  /* --- Shadows --- */
  --sh-card: 0 4px 24px rgba(0,0,0,0.5);
  --sh-red:  0 0 24px rgba(232,56,79,0.22);
  --sh-gold: 0 0 28px rgba(245,197,24,0.25);

  /* --- Radius --- */
  --r-sm:  6px;
  --r:     12px;
  --r-lg:  20px;
  --r-xl:  28px;

  /* --- Typography --- */
  --font: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* --- Transitions --- */
  --tr: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ======================== RESET ======================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--t1);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 0; /* Default */
}
@media (max-width: 640px) {
  body { padding-bottom: 70px; /* Space for bottom nav */ }
}

/* ======================== ANIMATED BG ======================== */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.orb {
  position: absolute; border-radius: 50%;
  filter: blur(100px); opacity: 0.08;
  animation: orbFloat 25s ease-in-out infinite;
}
.orb-1 { width: 700px; height: 700px; background: radial-gradient(circle, #e8384f, transparent); top: -250px; left: -150px; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, #f5c518, transparent); top: 50%; right: -200px; animation-delay: -9s; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(circle, #60a5fa, transparent); bottom: -100px; left: 25%; animation-delay: -17s; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -40px) scale(1.06); }
  66% { transform: translate(-25px, 25px) scale(0.94); }
}

/* ======================== HEADER ======================== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(9, 9, 15, 0.92);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 58px;
}

/* Logo */
.logo { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.logo-emoji { font-size: 1.7rem; animation: spinEmoji 6s linear infinite; display: inline-block; }
@keyframes spinEmoji {
  0%,90% { transform: rotate(0deg); }
  95% { transform: rotate(-15deg); }
  100% { transform: rotate(0deg); }
}
.logo-name {
  font-size: 1.15rem; font-weight: 800; letter-spacing: 0.04em;
  background: linear-gradient(90deg, #ff5566, #f5c518 60%, #ff5566);
  background-size: 200% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 4s linear infinite;
  white-space: nowrap;
}
@keyframes shimmer { to { background-position: 200% center; } }
.logo-sub { font-size: 0.68rem; color: var(--t3); letter-spacing: 0.06em; }

/* Clock */
.hd-clock {
  font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--gold-2); letter-spacing: 0.06em;
  background: var(--gold-dim); border: 1px solid var(--border-gold);
  padding: 5px 14px; border-radius: 50px;
}

/* Feature Nav */
.feat-nav {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  -ms-overflow-style: none; padding: 0 2px;
}
.feat-nav::-webkit-scrollbar { display: none; }
.mobile-bottom-nav { display: none; } /* Hide on desktop */

.feat-link {
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 0.82rem; font-weight: 600; text-decoration: none;
  color: var(--t3); padding: 5px 13px;
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: 50px; transition: var(--tr);
  font-family: var(--font);
}
.feat-link:hover { color: var(--t2); background: var(--bg-hover); border-color: var(--border-2); }
.feat-link.active { color: #fff; background: var(--red-dim); border-color: var(--border-red); }

/* ======================== MAIN ======================== */
.main {
  position: relative; z-index: 5;
  max-width: 1180px; margin: 0 auto;
  padding: 20px 12px 64px;
}

/* ======================== TOOLBAR ======================== */
/* Wrapper: date + tabs + search tất cả trong 1 dải */
.toolbar {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 20px;
}

/* DATE NAVIGATOR */
.date-nav-container { display: flex; justify-content: center; width: 100%; }
.date-nav {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 6px 10px;
  backdrop-filter: blur(20px); box-shadow: var(--sh-card);
  width: fit-content; margin: 0 auto;
}

.date-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--bg-glass); color: var(--t2);
  cursor: pointer; transition: var(--tr); flex-shrink: 0;
}
.date-btn:hover { background: var(--red-dim); border-color: var(--border-red); color: var(--red-2); }

.today-btn {
  width: auto; padding: 0 14px; border-radius: 50px;
  font-size: 0.8rem; font-weight: 700; font-family: var(--font);
  color: var(--gold-2); border-color: var(--border-gold); background: var(--gold-dim);
}
.today-btn:hover { background: rgba(245,197,24,0.22); box-shadow: var(--sh-gold); }

.date-display { position: relative; cursor: pointer; }
.date-picker-input {
  position: absolute; opacity: 0; inset: 0;
  width: 100%; height: 100%; cursor: pointer; z-index: 10;
  border: none; background: transparent;
}
.date-label {
  display: flex; flex-direction: column; align-items: center;
  min-width: 160px; padding: 4px 10px;
  border-radius: var(--r-sm); transition: var(--tr);
}
.date-label:hover { background: var(--bg-hover); }
.date-weekday { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.15em; color: var(--red-2); text-transform: uppercase; }
.date-full    { font-size: 1rem;   font-weight: 700; color: var(--t1); }

/* TABS + STATION SEARCH ROW */
.tabs-search-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; justify-content: center;
}

/* REGION TABS */
.tabs {
  display: flex; gap: 5px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 5px;
  backdrop-filter: blur(20px);
}

.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--r-lg);
  border: 1px solid transparent; background: transparent;
  color: var(--t3); cursor: pointer;
  font-family: var(--font); font-size: 0.88rem; font-weight: 600;
  transition: var(--tr); white-space: nowrap;
}
.tab:hover { color: var(--t2); background: var(--bg-hover); }
.tab.active {
  background: linear-gradient(135deg, #e8384f, #c02840);
  color: #fff; border-color: rgba(255,255,255,0.12);
  box-shadow: 0 4px 18px rgba(232,56,79,0.4);
}
.tab-icon { font-size: 1rem; }
.tab-badge {
  font-size: 0.63rem; font-weight: 800; letter-spacing: 0.08em;
  background: rgba(255,255,255,0.14); padding: 2px 6px; border-radius: 4px;
}
.tab.active .tab-badge { background: rgba(255,255,255,0.22); }

/* STATION SEARCH — tìm đài */
.station-search-wrap {
  display: flex; align-items: center; gap: 8px;
}
.station-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 50px; padding: 7px 14px;
  backdrop-filter: blur(20px); transition: var(--tr);
}
.station-search:focus-within { border-color: var(--border-red); box-shadow: var(--sh-red); }
.station-search svg { color: var(--t3); flex-shrink: 0; }
.station-search-input {
  background: transparent; border: none; outline: none;
  color: var(--t1); font-family: var(--font); font-size: 0.88rem;
  font-weight: 500; width: 150px;
}
.station-search-input::placeholder { color: var(--t3); }

/* NUMBER SEARCH */
.num-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 50px; padding: 7px 14px;
  backdrop-filter: blur(20px); transition: var(--tr);
  width: 220px; max-width: 100%;
}
.num-search:focus-within { border-color: var(--border-gold); box-shadow: var(--sh-gold); }
.num-search svg { color: var(--t3); flex-shrink: 0; }
.num-search-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--t1); font-family: var(--font); font-size: 0.88rem; font-weight: 500;
}
.num-search-input::placeholder { color: var(--t3); }
.num-search-input::-webkit-inner-spin-button,
.num-search-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.search-clear-btn {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-hover); border: none; color: var(--t3);
  cursor: pointer; display: none; align-items: center; justify-content: center;
  font-size: 0.65rem; transition: var(--tr);
}
.search-clear-btn.show { display: flex; }
.search-clear-btn:hover { background: var(--red); color: #fff; }

/* ======================== LOADING / ERROR ======================== */
.loading-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px; gap: 18px; color: var(--t3);
}
.spinner-ring {
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,0.07);
  border-top-color: var(--red-2);
  border-radius: 50%; animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px; gap: 14px; text-align: center;
}
.error-icon { font-size: 2.8rem; }
.error-state p { color: var(--t2); font-size: 0.95rem; max-width: 360px; }
.retry-btn {
  background: linear-gradient(135deg, #e8384f, #c02840); color: #fff;
  border: none; padding: 10px 28px; border-radius: 50px;
  font-family: var(--font); font-size: 0.88rem; font-weight: 700;
  cursor: pointer; transition: var(--tr);
}
.retry-btn:hover { transform: translateY(-2px); box-shadow: var(--sh-red); }

.hidden { display: none !important; }

/* ======================== MAIN LAYOUT GRID ======================== */
.main-layout-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
  .main-layout-grid.has-sidebar {
    grid-template-columns: 1fr 300px; /* Sidebar right */
    align-items: start;
  }
}
.sidebar-col { display: flex; flex-direction: column; gap: 16px; }
.sidebar-ads { position: sticky; top: 80px; }

/* ======================== RESULTS GRID ======================== */
.results-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

/* Station not found */
.no-station {
  grid-column: 1/-1; text-align: center;
  padding: 48px 20px; color: var(--t3);
  animation: fadeIn 0.3s ease;
}
.no-station-icon { font-size: 2.5rem; margin-bottom: 10px; }
.no-station p { font-size: 0.92rem; }

.no-data {
  grid-column: 1/-1; text-align: center;
  padding: 72px 20px; color: var(--t3); animation: fadeIn 0.3s ease;
}
.no-data-icon { font-size: 3rem; margin-bottom: 12px; }
.no-data h3 { font-size: 1.05rem; font-weight: 700; color: var(--t2); margin-bottom: 8px; }
.no-data p  { font-size: 0.88rem; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ======================== LOTTERY CARD ======================== */
.lottery-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  backdrop-filter: blur(24px); box-shadow: var(--sh-card);
  transition: var(--tr); animation: slideUp 0.35s ease both;
}
.lottery-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-red);
  box-shadow: var(--sh-card), var(--sh-red);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lottery-card:nth-child(1) { animation-delay: 0s; }
.lottery-card:nth-child(2) { animation-delay: 0.06s; }
.lottery-card:nth-child(3) { animation-delay: 0.12s; }
.lottery-card:nth-child(4) { animation-delay: 0.18s; }

/* Card Header */
.card-header {
  background: linear-gradient(135deg, rgba(232,56,79,0.12), rgba(245,197,24,0.04));
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-province { font-size: 1rem; font-weight: 800; color: var(--t1); }
.card-badge {
  font-size: 0.65rem; font-weight: 800; letter-spacing: 0.1em;
  color: var(--red-2); background: var(--red-dim);
  border: 1px solid var(--border-red); padding: 2px 9px; border-radius: 50px;
}

/* Prize Table */
.prize-table { width: 100%; border-collapse: collapse; }
.prize-row { border-bottom: 1px solid rgba(255,255,255,0.035); transition: background 0.18s; }
.prize-row:last-child { border-bottom: none; }
.prize-row:hover { background: var(--bg-hover); }

.prize-name {
  font-size: 0.75rem; font-weight: 600; color: var(--t3);
  padding: 8px 14px; white-space: nowrap;
  vertical-align: middle; text-align: left;
  width: 82px; border-right: 1px solid rgba(255,255,255,0.035);
}
.prize-numbers {
  padding: 8px 14px; display: flex; flex-wrap: wrap;
  gap: 5px; align-items: center; vertical-align: middle;
}

/* Special (ĐB) */
.prize-row.special .prize-name { color: var(--gold-2); font-size: 0.78rem; }
.prize-row.special .prize-numbers { padding: 11px 14px; }

/* Number Badges */
.num-badge {
  font-size: 0.88rem; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: 0.03em;
  padding: 3px 9px; border-radius: var(--r-sm);
  background: var(--bg-glass); color: var(--t1);
  border: 1px solid var(--border); transition: var(--tr);
  cursor: default; position: relative;
}
.prize-row.special .num-badge {
  font-size: 1.45rem; font-weight: 900;
  padding: 7px 16px; color: var(--gold-2);
  background: linear-gradient(135deg, rgba(232,56,79,0.18), rgba(245,197,24,0.10));
  border-color: rgba(245,197,24,0.25);
  box-shadow: 0 2px 14px rgba(232,56,79,0.15);
}
.num-badge.highlight {
  background: linear-gradient(135deg, #f5c518, #e8a000) !important;
  color: #0a0a0f !important;
  border-color: var(--gold) !important;
  box-shadow: var(--sh-gold) !important;
  transform: scale(1.1);
}
.prize-row.special .num-badge.highlight { transform: scale(1.12); }

/* MB full width card */
.mb-full-card { grid-column: 1 / -1; }

/* ======================== STATS BAR ======================== */
.stats-bar {
  margin-top: 24px; display: flex;
  gap: 10px; flex-wrap: wrap; justify-content: center;
}
.stat-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 50px; padding: 7px 14px;
  font-size: 0.8rem; font-weight: 500; color: var(--t2);
  backdrop-filter: blur(12px);
}
.stat-dot { width: 7px; height: 7px; border-radius: 50%; }
.stat-dot.red  { background: var(--red-2);  box-shadow: 0 0 7px var(--red); }
.stat-dot.gold { background: var(--gold);   box-shadow: 0 0 7px var(--gold); }
.stat-dot.blue { background: var(--blue);   box-shadow: 0 0 7px var(--blue); }

/* ======================== FOOTER ======================== */
.footer {
  position: relative; z-index: 5; text-align: center;
  padding: 20px 16px; color: var(--t3); font-size: 0.78rem;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--red-2); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ============================================================
   RESPONSIVE — MOBILE FIRST
   ============================================================ */

/* ─── ≤ 900px: Hide feature nav text labels ─── */
@media (max-width: 900px) {
  .feat-link span:not([aria-hidden]) { display: none; }
  .feat-link { padding: 5px 10px; }
}

/* ─── ≤ 640px: Full mobile layout ─── */
@media (max-width: 640px) {
  /* Header: logo + clock, hide feat-nav */
  .header-inner { height: 50px; }
  .feat-nav     { display: none; }
  .logo-name    { font-size: 0.95rem; }
  .logo-emoji   { font-size: 1.4rem; }
  .logo-sub     { display: none; }
  .hd-clock     { font-size: 0.8rem; padding: 4px 10px; }

  /* Mobile Bottom Nav Bar */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 64px; background: rgba(17, 17, 28, 0.96);
    backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    z-index: 1000;
    justify-content: space-around; align-items: center;
    padding: 0 4px;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
  }
  .mobile-bottom-nav .nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 4px; text-decoration: none;
    color: var(--t3); transition: var(--tr);
  }
  .mobile-bottom-nav .nav-item.active { color: var(--red-2); }
  .mobile-bottom-nav .nav-icon { font-size: 1.25rem; transition: transform 0.2s; }
  .mobile-bottom-nav .nav-item.active .nav-icon { transform: translateY(-4px); }
  .mobile-bottom-nav .nav-label { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

  /* Toolbar: Sticky on scroll */
  .toolbar {
    position: sticky; top: 49px; z-index: 100;
    background: var(--bg); padding-top: 8px; padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .date-nav { width: 100%; border-radius: var(--r-lg); }
  .date-label { min-width: 120px; flex: 1; }
  .date-btn { width: 42px; height: 42px; }

  /* Tabs + search: stacked column */
  .tabs-search-row { flex-direction: column; align-items: stretch; gap: 8px; }

  /* Tabs: scrollable row */
  .tabs {
    width: 100%; overflow-x: auto; scrollbar-width: none;
    justify-content: flex-start; padding: 4px; gap: 4px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 1; min-width: 95px; padding: 10px 8px; font-size: 0.8rem; justify-content: center; }
  .tab-text { display: inline; }
  .tab-badge { display: none; }

  /* Search boxes: side by side */
  .station-search-wrap { display: flex; gap: 8px; }
  .station-search, .num-search { flex: 1; min-width: 0; padding: 9px 14px; }
  .station-search-input, .num-search-input { width: auto; flex: 1; font-size: 0.82rem; }

  /* Grid: 1 column */
  .results-grid { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 480px) {
  .main { padding: 8px 8px 48px; }
  .num-badge { font-size: 0.8rem; padding: 3px 6px; }
  .prize-row.special .num-badge { font-size: 1.1rem; padding: 5px 10px; }
  .prize-name { width: 62px; font-size: 0.65rem; padding: 6px 8px; }
  .prize-numbers { padding: 6px 8px; gap: 3px; }
  .card-header { padding: 10px 14px; }
  .card-province { font-size: 0.92rem; }
}

/* ======================== SCROLLBAR ======================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }
