/* =========================================================
   ASSISTENTE PESSOAL — styles.css
   Base copiada do App-Noite Calma (shell, tema, tab-bar), com
   accent trocado para diferenciar visualmente dos outros apps.
   ========================================================= */

:root {
  --paper: #e8e6de;
  --paper-raised: #f2f0e8;
  --ink: #1c1d1b;
  --ink-soft: #55564e;
  --ink-faint: #8b8c81;
  --accent: #4a6fa5;
  --accent-strong: #33517f;
  --accent-soft: #dde4ef;
  --line: #c9c4b8;
  --radius: 12px;
  --serif: ui-serif, Georgia, "Times New Roman", serif;
  --sans: -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161d;
    --paper-raised: #171c25;
    --ink: #e9e8e3;
    --ink-soft: #b2b3ac;
    --ink-faint: #75766f;
    --accent: #7fa0d6;
    --accent-strong: #a8c0e6;
    --accent-soft: #22293a;
    --line: #232a35;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #12161d;
  --paper-raised: #171c25;
  --ink: #e9e8e3;
  --ink-soft: #b2b3ac;
  --ink-faint: #75766f;
  --accent: #7fa0d6;
  --accent-strong: #a8c0e6;
  --accent-soft: #22293a;
  --line: #232a35;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --paper: #e8e6de;
  --paper-raised: #f2f0e8;
  --ink: #1c1d1b;
  --ink-soft: #55564e;
  --ink-faint: #8b8c81;
  --accent: #4a6fa5;
  --accent-strong: #33517f;
  --accent-soft: #dde4ef;
  --line: #c9c4b8;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px calc(80px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* Screens */
.screen { display: none; animation: fadeIn 0.25s ease; }
.screen-active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Barra de abas persistente */
.tab-bar {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 480px);
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper-raised);
  border-top: 1px solid var(--line);
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color .2s;
}

.tab-btn.tab-btn-active { color: var(--accent-strong); }
.tab-icon { font-size: 1.3rem; line-height: 1; }
.tab-label { font-size: .62rem; font-weight: 700; letter-spacing: .03em; }

/* Typography */
.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

h1, h2 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 8px;
}

h1 { font-size: 1.35rem; }
h2 { font-size: 1.4rem; }

.support-copy, .guide-copy, .safety-copy {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.safety-copy {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 24px;
}

/* Buttons */
.primary-action, .secondary-action, .ghost-action {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.15s, opacity 0.15s;
}

.primary-action {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}
.primary-action:hover { background: var(--accent-strong); }
.primary-action:disabled { opacity: 0.4; cursor: not-allowed; }

.secondary-action {
  background: var(--accent-soft);
  color: var(--ink);
}

.ghost-action {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.ghost-action.wide { margin-top: 8px; }

/* Brand */
.brand-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 1rem;
  flex-shrink: 0;
}
.brand-bar .ghost-action {
  width: auto;
  margin: 0 0 0 auto;
  padding: 8px 12px;
  font-size: 1.1rem;
}
.brand-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.brand-actions .ghost-action { margin: 0; }
.brand-bar button[data-back] {
  width: auto;
  margin: 0;
  padding: 8px 12px;
  font-size: 1.1rem;
}

/* Configurações */
.config-secao-titulo {
  font-size: 0.95rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 24px 0 10px;
}
.config-secao-titulo:first-of-type { margin-top: 8px; }
.config-opcoes {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.config-opcao {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.config-opcao.ativo {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}
.secondary-action.wide { width: 100%; }

/* Sub-navegação (Tarefas: Tarefas / Planejador / Longo prazo) */
.subtab-bar {
  display: flex;
  gap: 6px;
  margin: 12px 0 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.subtab-btn {
  flex: 0 0 auto;
  padding: 10px 10px;
  white-space: nowrap;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtab-btn-active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.subtab-panel { display: none; }
.subtab-panel-active { display: block; }
.subtab-bar-inner {
  margin: 4px 0 14px;
  border-bottom-color: var(--line);
}
.subtab-bar-inner .subtab-btn {
  padding: 6px 8px;
  font-size: 0.78rem;
}

/* Lembretes de saúde (Configurações) */
.lembrete-row { align-items: center; }
.lembrete-check {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  font-size: 0.9rem;
}
.lembrete-row input[type="time"] { flex: 0 0 auto; }

/* Botões de dia (Planejador) — mesma grade visual do .week-days,
   mas com <button> em vez de <label><input>, pra seleção única. */
.week-days button {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-faint);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.week-days button.ativo {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}

.empty-state .ghost-action { margin-top: 12px; }
.task-por-hoje { display: block; color: var(--accent-strong); font-weight: 600; }

/* Metas — dias restantes / vencida */
.meta-prazo { font-size: 0.8rem; }
.meta-prazo-vencida { color: #c65b4a; font-weight: 600; }

/* Hoje — lista do dia */
.hoje-evento { opacity: 0.85; background: var(--paper); }
.hoje-evento-local { opacity: 1; }
.hoje-arrastando {
  color: #c65b4a;
  font-weight: 600;
}
.salvar-evento-row { align-items: center; }
.salvar-evento-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-faint);
  flex: 1;
}
.salvar-evento-check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Cards */
.state-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}
.state-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  text-align: left;
  transition: border-color 0.15s;
}
.state-card:hover { border-color: var(--accent); }
.state-icon { font-size: 1.4rem; }
.state-card small { color: var(--ink-faint); font-size: 0.8rem; }

/* Placeholder de tela vazia (Fase 0 — sem lógica ainda) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 48px 12px;
  color: var(--ink-faint);
}
.empty-state .empty-icon { font-size: 2.2rem; }

/* Formulário de tarefas */
.task-form {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0 20px;
}
.task-form input, .task-form select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  margin-bottom: 10px;
}
.task-form-row {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 8px;
}
.task-form-row input, .task-form-row select { margin-bottom: 0; }
.task-form .primary-action { margin-top: 10px; }

.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.task-item.done { opacity: 0.55; }
.task-item.done .task-title { text-decoration: line-through; }
.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
}
.task-item.done .task-check {
  background: var(--accent);
}
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 0.95rem; }
.task-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--ink-faint);
}
.task-priority-alta { color: #c65b4a; }
.task-priority-baixa { color: var(--ink-faint); }
.task-delete {
  background: transparent;
  border: none;
  color: var(--ink-faint);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
}

.habito-form-row { grid-template-columns: 1fr 1fr; }
.treino-form-row { grid-template-columns: 1fr 1fr 80px; }
.pressao-form-row { grid-template-columns: 1fr 1fr 80px; }
.pesoForm-row { grid-template-columns: 1fr 1fr; }
.alimentacao-form-row { grid-template-columns: 140px 1fr; }
.task-form textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  margin-bottom: 10px;
  resize: vertical;
}
.task-notes {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--ink-faint);
  white-space: pre-wrap;
}

.import-csv-label {
  display: block;
  text-align: center;
  cursor: pointer;
}
.financas-summary {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 0.92rem;
}
.financas-summary strong { font-size: 1.1rem; }
.transacao-valor-pos { color: #3a8f5c; }
.transacao-valor-neg { color: #c65b4a; }

.habito-item { align-items: center; }
.habito-score {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-strong);
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--line) 0);
}
.habito-score span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--paper-raised);
  display: flex;
  align-items: center;
  justify-content: center;
}
.habito-meta-trigger { font-size: 0.8rem; color: var(--ink-faint); margin-top: 2px; }
.habito-check-today {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-strong);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.habito-check-today.done {
  background: var(--accent);
  color: #fff;
}

/* Toggles de dia da semana (Tarefas recorrentes + Hábitos) */
.week-days {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.week-days label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.8rem;
  color: var(--ink-faint);
  cursor: pointer;
  position: relative;
}
.week-days input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.week-days label:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}

/* Subtarefas */
.task-subtask-badge {
  font-size: 0.76rem;
  color: var(--ink-faint);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 8px;
}
.subtask-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.subtask-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.subtask-row.done .subtask-text { text-decoration: line-through; color: var(--ink-faint); }
.subtask-row input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.subtask-add-row { display: flex; gap: 6px; margin-top: 8px; }
.subtask-add-row input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
}
.subtask-add-row button {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-strong);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.task-toggle-subtasks {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  margin-top: 4px;
  text-align: left;
}

/* 3 estados do hábito: Feito / Pulei / Falhei */
.habito-status-btns { display: flex; gap: 4px; flex-shrink: 0; }
.habito-status-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--ink-faint);
}
.habito-status-btn[data-status="feito"].active { background: #3a8f5c; border-color: #3a8f5c; color: #fff; }
.habito-status-btn[data-status="pulei"].active { background: #c9a86a; border-color: #c9a86a; color: #fff; }
.habito-status-btn[data-status="falhei"].active { background: #c65b4a; border-color: #c65b4a; color: #fff; }
.habito-status-btn[data-status="minimo"].active { background: #7a8fa6; border-color: #7a8fa6; color: #fff; }
.habito-status-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Obstáculo (motivo da falha) */
.obstaculo-painel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.obstaculo-opcao {
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-faint);
  font-family: inherit;
  font-size: 0.76rem;
  cursor: pointer;
}

/* Finanças — categoria, orçamento, assinaturas */
.transacao-categoria {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.78rem;
}
.orcamento-barra-fundo {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin-top: 6px;
}
.orcamento-barra {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.orcamento-barra.aviso { background: #c9a86a; }
.orcamento-barra.excedido { background: #c65b4a; }

/* ---- Grade do dia (aba Hoje) ---- */
.grade { margin: 16px 0; }
.grade-faixa {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 16px 0 6px;
}
.grade-faixa:first-child { margin-top: 0; }

.grade-linha {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  align-items: center;
  gap: 8px;
  min-height: calc(var(--slots, 1) * 30px);
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.grade-hora {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  align-self: start;
  padding-top: 4px;
}
.grade-corpo { min-width: 0; }
.grade-titulo { font-size: 0.9rem; }
.grade-periodo { font-size: 0.72rem; color: var(--ink-faint); }

.grade-buraco { opacity: 0.6; }
.grade-buraco-txt {
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-style: italic;
}

.grade-item.grade-evento { background: var(--paper-raised); border-radius: 8px; padding-left: 8px; }
.grade-item.grade-rotina { padding-left: 8px; }
.grade-item.grade-bloco { background: var(--accent-soft); border-radius: 8px; padding-left: 8px; }
.grade-item.feito .grade-titulo { text-decoration: line-through; color: var(--ink-faint); }

.grade-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  flex-shrink: 0;
  cursor: pointer;
}
.grade-check.feito { background: var(--accent); }

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

.grade-buraco-btn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.encaixe-painel {
  margin-top: 8px;
  padding: 10px;
  background: var(--paper-raised);
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.encaixe-label {
  font-size: 0.72rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 6px 0 4px;
}
.encaixe-opcao {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}
.encaixe-opcao:hover { border-color: var(--accent); }
.encaixe-duracao { font-size: 0.75rem; color: var(--ink-faint); }

.meta-item { flex-direction: column; align-items: stretch; }
.meta-progresso {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin: 6px 0 4px;
}
.meta-progresso-barra {
  height: 100%;
  width: calc(var(--pct, 0) * 1%);
  background: var(--accent);
  transition: width 0.2s;
}
.meta-item .subtask-text em { color: var(--ink-faint); font-style: italic; }
.meta-item .secondary-action { margin: 8px 0 4px; }

.settings-block {
  margin: 24px 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.settings-block h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.1rem;
  margin-bottom: 6px;
}
