﻿/* ════════ Responsive Breakpoints ════════
   TODO: Distribute @media rules into their respective
         feature CSS files (features/<name>/<name>.css)
         for true co-location.
         Kept as one file for safer incremental refactor.
   ════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════ RESPONSIVE ══ */

/* ── Desktop (≥ 641px): sidebar nav + search bar visible ── */
@media (min-width: 641px) {
  .sidebar        { display: flex; }   /* sidebar visible */
  .nav-search     { display: flex; }   /* search bar visible */
  .nav-bell       { display: flex; }   /* bell visible */
  .nav-user       { display: flex; }   /* user profile visible */
  .nav-tabs       { display: none;  }  /* bottom tabs hidden (sidebar replaces) */
  .vocab-stats-row { grid-template-columns: repeat(4, 1fr); }
}


/* ── Tablet nhỏ: ≤900px ── */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .progress-bottom {
    grid-template-columns: 1fr;
  }

  .pg-stats  { grid-template-columns: repeat(3, 1fr); }
  .pg-mid    { grid-template-columns: 1fr; }
  .pg-bottom { grid-template-columns: repeat(2, 1fr); }
  .ts-layout { grid-template-columns: 1fr; }

  .mode-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .st-data-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .st-row {
    flex-wrap: wrap;
    gap: 12px;
  }

  .st-control {
    flex-wrap: wrap;
  }
}

/* ── Mobile lớn: ≤640px ── */
@media (max-width: 640px) {

  /* Layout — thêm padding-bottom để tránh bị che bởi bottom nav */
  .main {
    padding: 16px 12px calc(74px + env(safe-area-inset-bottom, 0px));
  }

  .pg-stats  { grid-template-columns: repeat(2, 1fr); }
  .pg-bottom { grid-template-columns: 1fr; }
  .pg-hero   { flex-direction: column; }
  .pg-hero-banner { min-width: unset; width: 100%; }

  .page-title {
    font-size: 1.35rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  /* Hide sidebar + desktop nav elements */
  .sidebar    { display: none; }
  .nav-search { display: none; }
  .nav-bell   { display: none; }
  .nav-user   { display: none; }

  /* Navbar → bottom navigation bar */
  .navbar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(58px + env(safe-area-inset-bottom, 0px));
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    gap: 0;
    border-bottom: none;
    border-top: 1px solid var(--border);
  }

  .brand { display: none; }
  .nav-end { display: none; }

  .nav-tabs {
    display: flex;
    justify-content: space-around;
    overflow: visible;
  }

  .nav-tab {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 2px;
    font-size: 0.62rem;
    border-radius: var(--radius-sm);
    min-height: 48px;
  }

  .nav-tab svg {
    width: 20px;
    height: 20px;
  }

  .nav-tab span {
    display: block;
    font-size: 0.62rem;
  }

  /* Dashboard */
  .hero-cta {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 16px;
    gap: 12px;
  }

  .hero-cta-icon {
    font-size: 2.2rem;
  }

  .hero-cta-title {
    font-size: 1.05rem;
  }

  .hero-cta-btn {
    width: 100%;
    text-align: center;
    padding: 14px;
    font-size: 1rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  /* Flashcard */
  .fc-word {
    font-size: 1.9rem;
  }

  .fc-meaning {
    font-size: 1.4rem;
  }

  .setup-grid3 {
    grid-template-columns: 1fr;
  }

  .setup-row {
    grid-template-columns: 1fr;
  }

  .rating-btns {
    gap: 6px;
  }

  .rating-btn {
    padding: 8px 6px;
    font-size: 0.75rem;
  }

  /* MCQ */
  .quiz-card {
    padding: 18px 14px;
  }

  .quiz-options {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .quiz-prompt {
    font-size: 1.1rem;
    margin-bottom: 18px;
  }

  /* Result */
  .result-card {
    padding: 28px 20px;
  }

  .result-score-big {
    font-size: 2.6rem;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Practice mode grid */
  .mode-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .mode-card {
    padding: 12px 10px;
  }

  .mode-icon-bg {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .mode-name {
    font-size: 0.8rem;
  }

  .mode-desc {
    font-size: 0.7rem;
  }

  /* Setup card */
  .setup-card {
    padding: 24px 16px;
  }

  .setup-card .btn-lg {
    width: 100%;
    justify-content: center;
    margin-top: 24px;
  }

  .topic-selector {
    gap: 8px 6px;
  }

  .count-btns {
    gap: 8px;
  }

  .count-btn {
    padding: 6px 14px;
  }

  .qtype-pills {
    gap: 6px;
  }

  .qtype-pill {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  /* Typing */
  .typing-card {
    padding: 18px 12px;
  }

  .typing-prompt {
    font-size: 1.2rem;
  }

  .typing-input-wrap {
    flex-direction: column;
  }

  .typing-input-wrap .btn {
    width: 100%;
  }

  /* Review */
  .rv-modes {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .rv-pair {
    gap: 8px;
  }

  .rv-card {
    padding: 12px 8px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 6px;
  }

  .rv-card-icon {
    font-size: 1.4rem;
  }

  .rv-cta {
    padding: 16px 14px;
  }

  .schedule-row {
    gap: 5px;
  }

  .schedule-day {
    padding: 8px 3px;
  }

  .sched-count {
    font-size: 0.95rem;
  }

  /* Progress */
  .badges-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Topics & Words */
  .topic-cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .word-grid {
    grid-template-columns: 1fr;
  }

  .tw-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 8px 12px;
    flex-wrap: unset;
  }

  .tw-back-btn {
    grid-column: 1;
    grid-row: 1;
  }

  .tw-study-btn {
    grid-column: 3;
    grid-row: 1;
  }

  .tw-title-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  /* Settings */
  .st-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .st-control {
    flex-wrap: wrap;
    gap: 6px;
  }

  .st-data-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .st-action-row {
    flex-direction: column;
    padding: 14px;
    gap: 8px;
  }

  .st-action-row .btn {
    width: 100%;
    justify-content: center;
  }

  .st-about {
    padding: 24px 16px;
  }


  /* Touch targets */
  .btn {
    min-height: 44px;
  }

  .wc-learn-btn {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .tc-btn-study,
  .tc-btn-view {
    min-height: 44px;
  }

  .topic-btn {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .count-btn {
    min-height: 40px;
  }

  .qtype-pill {
    min-height: 40px;
  }
}

/* ── Mobile nhỏ: ≤480px ── */
@media (max-width: 480px) {

  /* Bottom nav — giảm font label cho vừa 5 tab */
  .nav-tab span {
    font-size: 0.58rem;
  }

  .nav-tab svg {
    width: 19px;
    height: 19px;
  }

  /* Mode grid 1 cột */
  .mode-grid {
    grid-template-columns: 1fr;
  }

  .mode-card {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .mode-info {
    flex: 1;
  }

  /* Stats 2 cột */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  /* Quiz full-width options */
  .quiz-options {
    grid-template-columns: 1fr;
  }

  /* Settings buttons wrap */
  .st-theme-btn,
  .st-goal-btn,
  .st-count-btn,
  .st-rate-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  /* Flashcard — smaller word, tighter card padding */
  .fc-word {
    font-size: 1.75rem;
  }

  .flashcard-front,
  .flashcard-back {
    padding: 20px 14px;
  }

  .fc-meaning {
    font-size: 1.4rem;
  }

  /* Rating buttons — allow smaller min-width to avoid wrapping at 375px */
  .rating-btn {
    min-width: 60px;
  }

  /* Schedule row — tighter at small screens */
  .schedule-row {
    gap: 3px;
  }

  .sched-label {
    font-size: 0.58rem;
  }

  .sched-count {
    font-size: 0.9rem;
  }

  /* Activity chart bars */
  .chart-bars {
    gap: 5px;
  }

}

/* ── Very small phones: ≤375px ── */
@media (max-width: 375px) {

  /* Tighter main padding */
  .main {
    padding-left: 10px;
    padding-right: 10px;
  }

  /* Typography scale-down */
  .page-title {
    font-size: 1.2rem;
  }

  .fc-word {
    font-size: 1.5rem;
  }

  .fc-meaning {
    font-size: 1.25rem;
  }


  /* Schedule — very compact */
  .sched-label {
    font-size: 0.52rem;
  }

  .sched-count {
    font-size: 0.8rem;
  }

  .sched-sub {
    display: none;
  }

  .schedule-day {
    padding: 6px 2px;
    gap: 2px;
  }


  /* Stat cards tighter */
  .stat-card {
    padding: 14px;
    gap: 10px;
  }

  .stat-value {
    font-size: 1.3rem;
  }
