/* ================================================================
   MOBILE.CSS — Responsive cho màn hình nhỏ
   UX/UI principles: readability first, touch-friendly, clear hierarchy
   ================================================================ */

/* ── TABLET (≤ 900px): ẩn desktop elements ── */
@media (max-width: 900px) {
  .hd-right > div:first-child { display: none !important; }
  #search-province             { display: none !important; }
  .feat-nav                    { display: none !important; }
}

/* ── MOBILE (≤ 640px) ── */
@media (max-width: 640px) {
  /* === BASE === */
  body { overflow-x: hidden; }
  * { box-sizing: border-box; }

  /* Chặn bất kỳ element nào tràn ngang */
  html, body { max-width: 100vw; overflow-x: hidden; }
  .main, .toolbar, .header-inner,
  .lottery-card, .prize-table, .results-grid,
  .card-header, .card-date-row, .prize-numbers,
  .do-so-bar, .bottom-section { max-width: 100%; }

  /* Prize numbers không được nowrap trên mobile */
  .prize-numbers { white-space: normal !important; }
  .prize-numbers span { white-space: nowrap; }

  /* Table không tràn */
  table { max-width: 100%; word-break: break-word; }

  /* === HEADER === */
  .header { padding: 0 16px; }
  .header-inner { height: 52px; gap: 10px; }
  .logo-name { font-size: 1.2rem; font-weight: 900; }
  .logo-sub  { display: none; }
  .hd-mode-toggle {
    width: 36px; height: 36px; font-size: 1rem;
    flex-shrink: 0; border-radius: 50%;
  }

  /* === TOOLBAR === */
  .toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 16px 8px;
    margin-bottom: 12px;
  }

  /* Date nav — compact, không tràn 375px */
  .date-nav {
    width: 100%;
    justify-content: space-between;
    padding: 4px 6px;
    border-radius: 12px;
    gap: 0;
  }
  /* Ẩn native date input */
  .date-picker-input,
  #date-picker { display: none !important; }

  .date-label {
    font-size: 0.88rem;
    font-weight: 700;
    padding: 3px 6px;
    flex: 1;
    justify-content: center;
  }
  .date-label svg { width: 13px; height: 13px; }
  .date-btn {
    width: 32px; height: 32px;
    flex-shrink: 0;
  }
  /* Hôm nay button — nhỏ gọn */
  .today-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
    margin-left: 4px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Region tabs */
  .tabs { width: 100%; gap: 6px; }
  .tab {
    flex: 1;
    padding: 9px 4px;
    font-size: 0.8rem;
    font-weight: 700;
    justify-content: center;
    text-align: center;
    border-radius: 10px;
    min-height: 38px;
  }
  .tab .tab-icon { display: none; }

  /* === MAIN CONTENT === */
  .main { padding: 0 12px 140px; }

  /* === RESULTS GRID ===
     1 cột cho lottery cards (cần đọc số rõ ràng)
     Người dùng cần scan từng giải từ trên xuống,
     2 cột làm số quá nhỏ và khó đọc nhanh
  */
  .results-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  /* Cards nhỏ hơn (soi cầu, thống kê) — 2 cột OK */
  .results-grid-2col {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  /* === LOTTERY CARD === */
  .lottery-card { border-radius: 12px; }

  .card-header {
    padding: 12px 14px 6px;
    align-items: center;
  }
  .card-province {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.2;
  }
  .card-actions { gap: 6px; flex-shrink: 0; }
  .card-badge   { font-size: 0.62rem; padding: 2px 6px; }
  .fav-btn, .share-btn {
    font-size: 1rem;
    min-width: 28px; min-height: 28px; /* touch target */
    display: flex; align-items: center; justify-content: center;
  }

  /* Date row với draw badge */
  .card-date-row {
    padding: 2px 14px 10px;
    display: flex; align-items: center;
    justify-content: space-between; gap: 6px;
    font-size: 0.72rem;
    overflow: hidden; /* chặn badge tràn */
  }

  /* Badge giờ: rút ngắn text, không nowrap dài */
  .draw-time-badge {
    font-size: 0.62rem; padding: 2px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px; /* giới hạn chiều rộng badge */
    flex-shrink: 1;
  }

  /* Jackpot — nổi bật, dễ thấy */
  .jackpot-box   { margin: 0 14px 12px; padding: 12px; }
  .jackpot-label { font-size: 0.62rem; letter-spacing: 0.1em; }
  .jackpot-number { font-size: 2rem; font-weight: 900; letter-spacing: 0.04em; }

  /* Prize table — readable */
  .prize-table { font-size: 0.85rem; }
  .prize-name  {
    padding: 5px 10px;
    width: 60px; min-width: 60px;
    font-size: 0.75rem;
    color: var(--t3);
  }
  .prize-numbers {
    padding: 5px 10px;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  /* === NOT-YET UI === */
  .not-yet-wrap     { padding: 36px 20px; gap: 14px; }
  .not-yet-icon     { font-size: 3rem; }
  .not-yet-title    { font-size: 1.15rem; }
  .not-yet-schedule {
    flex-direction: column; gap: 4px;
    padding: 10px 18px; text-align: center;
    border-radius: 16px;
  }
  .schedule-label  { font-size: 0.8rem; }
  .schedule-time   { font-size: 1.05rem; }
  .not-yet-countdown { font-size: 1.6rem; }
  .not-yet-hint    { font-size: 0.82rem; }
  .not-yet-actions { flex-direction: column; width: 100%; gap: 8px; }
  .not-yet-btn, .not-yet-btn-secondary {
    width: 100%; text-align: center;
    padding: 12px 20px; /* touch target >= 44px */
    font-size: 0.92rem;
  }

  /* === DÒ SỐ BAR — fixed bottom, trên bottom-nav === */
  .do-so-bar {
    position: fixed;
    bottom: 56px; left: 0; right: 0;
    z-index: 90;
    background: #fff;
    border-top: 1px solid var(--border);
    border-radius: 0;
    box-shadow: 0 -3px 12px rgba(0,0,0,0.08);
    padding: 8px 14px;
    gap: 8px; flex-wrap: nowrap;
    margin: 0;
    align-items: center;
  }
  [data-theme="dark"] .do-so-bar {
    background: #161b22;
    border-color: rgba(255,255,255,0.1);
  }
  .do-so-label   { display: none; } /* tiết kiệm space */
  .do-so-input   {
    flex: 1; font-size: 0.9rem;
    height: 38px; /* touch target */
  }
  .do-so-btn     {
    flex-shrink: 0; padding: 0 16px;
    height: 38px; font-size: 0.85rem;
  }
  .do-so-clear   { height: 38px; width: 38px; flex-shrink: 0; }
  /* Kết quả dò số — Mobile: panel fixed phía TRÊN bar */
  .do-so-result {
    position: fixed;
    /* bottom = height bar(54px) + bottom-nav(56px) */
    bottom: 110px;
    left: 0; right: 0;
    z-index: 89;
    background: #fff;
    border-top: 2px solid var(--red);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    padding: 10px 16px;
    max-height: 45vh;
    overflow-y: auto;
    /* override PC flex */
    display: none;
    flex: none;
    margin-top: 0;
    border-radius: 16px 16px 0 0;
  }
  .do-so-result.visible { display: block; }
  [data-theme="dark"] .do-so-result {
    background: #161b22;
    border-color: var(--red);
  }
  /* Hit rows trên mobile — compact hơn */
  .do-so-hit { padding: 5px 0; gap: 8px; font-size: 0.82rem; }
  .do-so-prize { width: 52px; font-size: 0.68rem; }
  .do-so-num { font-size: 0.9rem; }
  .do-so-prov { max-width: 100px; font-size: 0.72rem; }
  .do-so-header { font-size: 0.84rem; }



  /* === BOTTOM SECTION === */
  .bottom-section { flex-direction: column; gap: 14px; }
  .quick-utilities {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .util-item { padding: 12px 8px; }
  .util-icon { width: 36px; height: 36px; font-size: 1.1rem; }
  .util-name { font-size: 0.72rem; }

  /* === FOOTER === */
  .footer { padding: 20px 16px 24px; margin-bottom: 0; }
  .footer-content { flex-direction: column; gap: 12px; text-align: center; }
  .footer-links   { justify-content: center; flex-wrap: wrap; gap: 8px; }
}

/* ── EXTRA SMALL (≤ 375px) ── */
@media (max-width: 375px) {
  .tab         { font-size: 0.75rem; padding: 8px 4px; }
  .date-label  { font-size: 0.82rem; }
  .jackpot-number { font-size: 1.7rem; }
  .prize-name  { width: 52px; min-width: 52px; font-size: 0.7rem; }
  .prize-numbers { font-size: 0.84rem; gap: 6px; }
  .card-province { font-size: 0.92rem; }
}

/* ── Dark mode overrides cho do-so-result ── */
[data-theme="dark"] .do-so-result { background: #161b22; }
