/* ============================================================
   Pomodoro MVP — Bảng định kiểu (styles.css)
   Quy ước đặt tên class: BEM
     .block              — khối độc lập (timer, tasks, settings…)
     .block__element     — phần tử con của khối
     .block--modifier    — biến thể / trạng thái của khối
   ============================================================ */

/* ---------- Biến màu & giao diện ---------- */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3ede4;
  --ink: #221d18;
  --ink-2: #6b6156;
  --line: #e5ddd0;
  --accent: #d9481f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e2;
  --break: #1e7a5a;
  --break-soft: #e2f1ea;
  --longbreak: #1f5fa8;
  --longbreak-soft: #e3edf8;
  --ring-track: #eadfd2;
  --shadow: 0 18px 40px -18px rgba(90, 50, 20, 0.25);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171310;
    --surface: #221c17;
    --surface-2: #2b241d;
    --ink: #f2eadf;
    --ink-2: #a89a88;
    --line: #3a3128;
    --accent: #f0643c;
    --accent-soft: #3d241b;
    --break: #4cc493;
    --break-soft: #1d3329;
    --longbreak: #6aa7e8;
    --longbreak-soft: #1d2c40;
    --ring-track: #38302a;
    --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6);
  }
}

/* ---------- Nền tảng ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- Khung trang (.page) ---------- */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.page-header { margin-bottom: 26px; }
.page-header__title {
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.page-header__desc { margin: 0; color: var(--ink-2); font-size: 15px; max-width: 560px; line-height: 1.55; }
.page-footer { margin-top: 30px; font-size: 12.5px; color: var(--ink-2); text-align: center; line-height: 1.6; }

/* ---------- Bố cục 2 cột (.layout) ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.layout > * { min-width: 0; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Thẻ dùng chung (.card) & nút (.btn) ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  padding: 12px 20px; font-size: 15px;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  padding: 13px 38px; font-size: 16px; min-width: 168px;
}
body[data-mode="short"] .btn--primary { background: var(--break); border-color: var(--break); }
body[data-mode="long"] .btn--primary { background: var(--longbreak); border-color: var(--longbreak); }
.btn--icon { padding: 12px 14px; font-size: 16px; line-height: 1; }

/* ---------- Đồng hồ (.timer) ---------- */
.timer { padding: 26px 26px 22px; text-align: center; }
.timer__modes {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.timer__mode-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.timer__mode-btn--active[data-mode="focus"] { background: var(--accent); color: var(--accent-ink); }
.timer__mode-btn--active[data-mode="short"] { background: var(--break); color: #fff; }
.timer__mode-btn--active[data-mode="long"] { background: var(--longbreak); color: #fff; }

.timer__ring { position: relative; width: min(300px, 72vw); margin: 0 auto; }
.timer__ring svg { display: block; width: 100%; height: auto; transform: rotate(-90deg); }
.timer__ring-track { stroke: var(--ring-track); }
.timer__ring-bar { stroke: var(--accent); transition: stroke 0.3s; stroke-linecap: round; }
body[data-mode="short"] .timer__ring-bar { stroke: var(--break); }
body[data-mode="long"] .timer__ring-bar { stroke: var(--longbreak); }
.timer__overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
}
.timer__display {
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(52px, 13vw, 68px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.timer__label { font-size: 13px; color: var(--ink-2); font-weight: 500; }

.timer__dots { display: flex; gap: 7px; justify-content: center; margin: 20px 0 4px; min-height: 12px; }
.timer__dot { width: 11px; height: 11px; border-radius: 50%; background: var(--ring-track); }
.timer__dot--done { background: var(--accent); }
.timer__dot--current { background: transparent; border: 2px solid var(--accent); width: 11px; height: 11px; }

.timer__controls { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.timer__hint { margin-top: 14px; font-size: 12.5px; color: var(--ink-2); }
kbd {
  font-family: "JetBrains Mono", monospace; font-size: 11px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px;
}

.timer__active-task {
  margin-top: 18px; padding: 12px 14px;
  background: var(--accent-soft); border-radius: 12px;
  font-size: 14px; display: none;
}
body[data-mode="short"] .timer__active-task { background: var(--break-soft); }
body[data-mode="long"] .timer__active-task { background: var(--longbreak-soft); }
.timer__active-task--visible { display: block; }
.timer__active-task strong { font-weight: 700; }

/* ---------- Thống kê hôm nay (.stats) ---------- */
.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  margin-top: 22px;
}
.stats__item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; min-width: 0;
}
.stats__value { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stats__label { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; line-height: 1.4; }
@media (max-width: 480px) {
  .timer { padding: 20px 14px 18px; }
  .timer__mode-btn { padding: 8px 11px; font-size: 12.5px; }
  .stats__item { padding: 12px; }
  .stats__value { font-size: 20px; }
  .timer__hint { line-height: 1.9; }
  .page { padding: 22px 14px 40px; }
}

/* ---------- Danh sách việc (.tasks / .task) ---------- */
.tasks { padding: 22px; }
.tasks__title { margin: 0 0 4px; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.tasks__subtitle { margin: 0 0 16px; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.tasks__form { display: flex; gap: 8px; margin-bottom: 14px; }
.tasks__input-name {
  flex: 1; min-width: 0;
  font: inherit; font-size: 14px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px;
}
.tasks__input-est {
  width: 64px;
  font: inherit; font-size: 14px; text-align: center;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 6px;
}
.tasks__form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.tasks__add-btn {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
  padding: 10px 16px; font-size: 14px;
}
.tasks__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tasks__empty { font-size: 13.5px; color: var(--ink-2); padding: 10px 2px; line-height: 1.55; }

.task {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
}
.task:hover { border-color: var(--ink-2); }
.task--active { border-color: var(--accent); background: var(--accent-soft); }
.task__check {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); background: transparent;
  cursor: pointer; display: grid; place-items: center;
  font-size: 12px; color: transparent; padding: 0;
}
.task--done .task__check { background: var(--break); border-color: var(--break); color: #fff; }
.task__name { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.task--done .task__name { color: var(--ink-2); text-decoration: line-through; }
.task__progress {
  flex: none; font-size: 12px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.task__delete {
  flex: none; border: 0; background: transparent; cursor: pointer;
  color: var(--ink-2); font-size: 16px; padding: 2px 4px; line-height: 1;
  border-radius: 6px;
}
.task__delete:hover { color: var(--accent); }

/* ---------- Cài đặt (.settings) ---------- */
.settings { padding: 22px; margin-top: 22px; }
.settings__title { margin: 0 0 14px; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.settings__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 480px) { .settings__grid { grid-template-columns: 1fr 1fr 1fr; gap: 8px; } }
.settings__field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.settings__field-input {
  width: 100%; font: inherit; font-size: 15px; text-align: center;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 6px;
}
.settings__field-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.settings__toggle {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 10px 0; border-top: 1px solid var(--line);
}
.settings__label { font-size: 14px; font-weight: 600; }
.settings__desc { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; line-height: 1.5; }
.settings__status { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }

/* Công tắc bật/tắt (.switch) */
.switch {
  flex: none; width: 48px; height: 27px; border-radius: 999px;
  background: var(--ring-track); border: 0; cursor: pointer;
  position: relative; transition: background 0.18s; padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: left 0.18s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 24px; }

/* ---------- Âm thanh nền có sẵn (.settings__ambient / .ambient-btn) ---------- */
.settings__ambient { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.settings__ambient-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ambient-btn { padding: 9px 15px; font-size: 13.5px; border-radius: 999px; }
.ambient-btn--active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.settings__ambient-volume { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.settings__ambient-volume label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); flex: none; }
.settings__ambient-volume input[type="range"] { flex: 1; min-width: 110px; accent-color: var(--accent); }

/* ---------- Âm thanh nền từ YouTube (.settings__youtube) ---------- */
.settings__youtube { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.settings__youtube-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.settings__youtube-input {
  flex: 1; min-width: 0; font: inherit; font-size: 13.5px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.settings__youtube-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.settings__youtube-row .btn { padding: 10px 16px; font-size: 14px; }
#ytPlayerWrap { position: fixed; right: 0; bottom: 0; width: 4px; height: 4px; overflow: hidden; opacity: 0.02; pointer-events: none; }

/* ---------- Thống kê theo ngày (.history / .chart-bar) ---------- */
.history { padding: 22px; margin-top: 22px; }
.history__title { margin: 0 0 4px; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.history__subtitle { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.history__chart { display: flex; align-items: flex-end; gap: 8px; height: 128px; margin-top: 10px; }
.chart-bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; }
.chart-bar__value { font-size: 11px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; min-height: 14px; }
.chart-bar__fill { width: 100%; max-width: 36px; min-height: 3px; border-radius: 6px 6px 3px 3px; background: var(--accent); }
.chart-bar__fill--zero { background: var(--ring-track); }
.chart-bar__day { font-size: 11px; color: var(--ink-2); font-weight: 600; }
.chart-bar--today .chart-bar__day { color: var(--accent); }
.history__days { list-style: none; margin: 14px 0 0; padding: 0; border-top: 1px solid var(--line); }
.history__days li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.history__days li:last-child { border-bottom: 0; padding-bottom: 0; }
.history__day-name { font-weight: 600; }
.history__day-stats { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Chế độ Zen (body.zen-mode) ---------- */
body.zen-mode { overflow: hidden; }
body.zen-mode .page { max-width: none; min-height: 100vh; padding: 20px; display: flex; align-items: center; justify-content: center; }
body.zen-mode .page-header, body.zen-mode .page-footer, body.zen-mode .stats,
body.zen-mode .layout__side, body.zen-mode .timer__hint { display: none; }
body.zen-mode .layout { display: block; width: 100%; }
body.zen-mode .timer { border: 0; box-shadow: none; background: transparent; }
body.zen-mode .timer__ring { width: min(58vh, 84vw); }
body.zen-mode .timer__display { font-size: clamp(64px, 15vh, 118px); }

/* ---------- Thông báo nổi (.toast) ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 80px);
  background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600;
  padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: transform 0.3s, opacity 0.3s; z-index: 50;
  max-width: calc(100vw - 40px); text-align: center;
}
.toast--visible { transform: translate(-50%, 0); opacity: 1; }
