/* =============================================================================
   TOMODachi · Pomodoro — estilos
   -----------------------------------------------------------------------------
   PALETA DA MARCA: edite as variáveis abaixo para trocar as cores do app.
   O tema ESCURO é o padrão. O claro está logo abaixo em [data-theme="light"].
   ========================================================================== */

:root {
  /* ---- Cores da marca (troque aqui) ---- */
  --accent:        #f43f5e;  /* cor principal / foco */
  --accent-strong: #e11d48;
  --c-focus:       #f43f5e;  /* anel durante o foco */
  --c-short:       #22c55e;  /* anel na pausa curta */
  --c-long:        #38bdf8;  /* anel na pausa longa */

  /* ---- Tema escuro (padrão) ---- */
  --bg:        #0f1117;
  --bg-elev:   #161922;
  --surface:   #1c2030;
  --surface-2: #232838;
  --border:    #2b3145;
  --text:      #e8eaf0;
  --text-dim:  #9aa3b8;
  --danger:    #ef4444;
  --success:   #22c55e;

  /* ---- Tokens de layout ---- */
  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px rgba(0, 0, 0, .35);
  --maxw:      900px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --t: .25s cubic-bezier(.4, 0, .2, 1);
}

[data-theme="light"] {
  --bg:        #f4f5f9;
  --bg-elev:   #ffffff;
  --surface:   #ffffff;
  --surface-2: #eef1f7;
  --border:    #dde1ec;
  --text:      #1b1f2a;
  --text-dim:  #5b6478;
  --shadow:    0 10px 30px rgba(20, 25, 40, .10);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t), color var(--t);
}

[hidden] { display: none !important; }

button { font-family: inherit; cursor: pointer; }

input, select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .7rem;
  width: 100%;
  transition: border-color var(--t), box-shadow var(--t);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ----------------------------- Botões -------------------------------------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .6rem 1.1rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  transition: transform var(--t), background var(--t), opacity var(--t);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-block { width: 100%; }
.btn-lg { padding: .85rem 2rem; font-size: 1.1rem; }

.icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text); border-radius: 50%;
  width: 38px; height: 38px; font-size: 1.1rem; line-height: 1;
  transition: background var(--t), transform var(--t);
}
.icon-btn:hover { background: var(--surface-2); transform: rotate(20deg); }

/* ============================ TELA DE LOGIN =============================== */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.brand { font-size: 2rem; margin: 0; text-align: center; letter-spacing: -.5px; }
.brand span { color: var(--accent); }
.brand-sub { text-align: center; color: var(--text-dim); margin: .25rem 0 1.5rem; }

.auth-form h2 { margin: 0 0 1rem; font-size: 1.2rem; }
.auth-form label {
  display: block; margin-bottom: .9rem;
  font-size: .85rem; color: var(--text-dim);
}
.auth-form label input { margin-top: .35rem; }
.auth-form .hint { color: var(--text-dim); font-weight: 400; }
.auth-switch { text-align: center; margin: 1rem 0 0; font-size: .9rem; color: var(--text-dim); }
.auth-switch a { color: var(--accent); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.form-error { color: var(--danger); font-size: .85rem; min-height: 1.1em; margin: .25rem 0; }

/* ============================== TOPBAR ==================================== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.5px; }
.topbar-brand span { color: var(--accent); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.user-name { color: var(--text-dim); font-size: .9rem; }

.tabs { display: flex; gap: .25rem; }
.tab {
  background: transparent; border: none; color: var(--text-dim);
  padding: .5rem .9rem; border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 600;
  transition: background var(--t), color var(--t);
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-current="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* ============================== CONTEÚDO ================================== */
.content { max-width: var(--maxw); margin: 0 auto; padding: clamp(1rem, 4vw, 2rem); }
.view { animation: fade .3s var(--t); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------- TIMER ----------------------------------- */
.timer-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem 2.5rem;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
}
.phase-label {
  text-transform: uppercase; letter-spacing: 2px; font-size: .8rem; font-weight: 700;
  color: var(--phase-color, var(--accent));
  padding: .35rem 1rem; border-radius: 999px;
  background: color-mix(in srgb, var(--phase-color, var(--accent)) 14%, transparent);
  transition: color var(--t), background var(--t);
}

.ring-wrap { position: relative; width: min(70vw, 300px); aspect-ratio: 1; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track  { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring-progress {
  fill: none; stroke: var(--phase-color, var(--accent)); stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 691.15;          /* 2π·110 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke var(--t);
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.time { font-size: clamp(3rem, 12vw, 4.5rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -2px; }
.cycle-info { color: var(--text-dim); font-size: .9rem; margin-top: .25rem; }

.current-task { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.current-task .muted { color: var(--text-dim); font-size: .9rem; }
.current-task select { width: auto; min-width: 180px; }

.timer-controls { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }

/* phase color helper — definido via data-phase no .timer-card */
.timer-card[data-phase="focus"]       { --phase-color: var(--c-focus); }
.timer-card[data-phase="short_break"] { --phase-color: var(--c-short); }
.timer-card[data-phase="long_break"]  { --phase-color: var(--c-long); }

/* ------------------------------ TAREFAS ---------------------------------- */
.task-form { display: flex; gap: .6rem; margin-bottom: 1.25rem; }
.task-form #task-title { flex: 1; }
.task-form #task-est { width: 80px; flex: none; text-align: center; }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.task-item {
  display: flex; align-items: center; gap: .8rem;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .8rem 1rem;
  transition: border-color var(--t), opacity var(--t);
}
.task-item.is-done { opacity: .55; }
.task-item.is-done .task-name { text-decoration: line-through; }
.task-item .task-check { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.task-item .task-name { flex: 1; border: none; background: transparent; padding: .2rem; border-radius: 6px; }
.task-item .task-name:focus { background: var(--surface-2); }
.task-pomos { color: var(--text-dim); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.task-del { background: transparent; border: none; color: var(--text-dim); font-size: 1.1rem; padding: .2rem .4rem; border-radius: 6px; }
.task-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }

.empty { text-align: center; color: var(--text-dim); padding: 2rem 0; }

/* ---------------------------- ESTATÍSTICAS ------------------------------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .8rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1.1rem 1rem; text-align: center;
  display: flex; flex-direction: column; gap: .25rem;
}
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-lbl { color: var(--text-dim); font-size: .8rem; }

.panel {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem;
}
.panel h3 { margin: 0 0 1rem; font-size: 1rem; }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history-item {
  display: flex; align-items: center; gap: .8rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.history-item:last-child { border-bottom: none; }
.history-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.history-dot.focus { background: var(--c-focus); }
.history-dot.short_break { background: var(--c-short); }
.history-dot.long_break { background: var(--c-long); }
.history-when { margin-left: auto; color: var(--text-dim); }

/* ---------------------------- CONFIGURAÇÕES ------------------------------ */
.settings-form { display: flex; flex-direction: column; gap: 1.25rem; }
.settings-form fieldset {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.settings-form legend { padding: 0 .5rem; color: var(--text-dim); font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.settings-form label { font-size: .9rem; color: var(--text-dim); display: flex; flex-direction: column; gap: .35rem; }
.settings-form label.switch { flex-direction: row; align-items: center; gap: .6rem; grid-column: 1 / -1; color: var(--text); }
.settings-form label.switch input { width: auto; }
.settings-actions { display: flex; align-items: center; gap: 1rem; }
.saved-flash { color: var(--success); font-weight: 600; }

/* ------------------------------- TOAST ----------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .7rem 1.2rem; box-shadow: var(--shadow); z-index: 100;
  animation: toastIn .3s var(--t);
}
.toast.error { border-color: var(--danger); color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ----------------------------- RESPONSIVO -------------------------------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .topbar-actions { margin-left: auto; }
  .settings-form fieldset { grid-template-columns: 1fr; }
  .task-form { flex-wrap: wrap; }
  .task-form #task-title { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
