/* ============================================================
   Assistente Pessoal — estilos (dark, mobile-first)
   ============================================================ */

:root {
  --bg: #0b0f17;
  --bg-2: #121826;
  --bg-3: #1a2236;
  --card: #151c2c;
  --card-hover: #1c2435;
  --border: #232c41;
  --text: #e8edf6;
  --text-dim: #94a0b8;
  --text-faint: #5e6a85;
  --accent: #6c8cff;
  --accent-2: #8b6cff;
  --accent-soft: rgba(108, 140, 255, 0.14);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --tabbar-h: 64px;
  --header-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

.hidden { display: none !important; }

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

input, textarea, select {
  font-family: inherit;
  font-size: 16px; /* evita zoom no iOS */
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

/* ============================ AUTH ============================ */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + var(--safe-top));
  background: radial-gradient(1200px 600px at 50% -10%, #182347 0%, var(--bg) 55%);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(124, 108, 240, 0.35);
}
.auth-logo img { width: 100%; height: 100%; display: block; }
.auth-brand h1 { font-size: 22px; margin: 0; }
.auth-sub { color: var(--text-dim); margin: 4px 0 0; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.auth-message { text-align: center; font-size: 13px; margin-top: 14px; min-height: 18px; }
.auth-message.error { color: var(--danger); }
.auth-message.success { color: var(--success); }
.config-warning {
  background: var(--danger-soft);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.config-warning code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; }

/* ============================ BOTÕES ============================ */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px; font-weight: 600; font-size: 15px;
}
.btn-primary:active { transform: scale(.98); }
.btn-block { width: 100%; }
.btn-ghost {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 18px; font-weight: 600;
}
.btn-link {
  background: none; border: none; color: var(--accent);
  font-size: 13px; padding: 4px; text-align: center;
}
.btn-small {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.icon-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 20px; width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--bg-3); }

/* ============================ HEADER ============================ */
.app { min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
.app-header {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(11,15,23,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-left h2 { margin: 0; font-size: 20px; }
.header-date { font-size: 12px; color: var(--text-dim); }
.header-right { display: flex; align-items: center; gap: 6px; }
.sync-badge { font-size: 12px; color: var(--success); transition: color .2s; }
.sync-badge.syncing { color: var(--warning); }
.sync-badge.offline { color: var(--text-faint); }

.offline-banner {
  background: var(--warning); color: #1a1300;
  font-size: 13px; font-weight: 600; text-align: center;
  padding: 8px 12px;
}

/* ============================ VIEWS ============================ */
.app-main { padding: 14px 16px 24px; }
.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-toolbar { margin-bottom: 14px; }
.seg-control {
  display: flex; gap: 4px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 4px;
}
.seg {
  flex: 1; background: none; border: none; color: var(--text-dim);
  padding: 9px 8px; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.seg.active { background: var(--accent-soft); color: var(--accent); }

/* ============================ LISTAS / CARDS ============================ */
.list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; gap: 12px; align-items: flex-start;
}
.card.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.card.is-done { opacity: .55; }
.card-check {
  width: 26px; height: 26px; min-width: 26px; margin-top: 2px;
  border-radius: 50%; border: 2px solid var(--text-faint);
  display: grid; place-items: center; background: none; color: transparent;
  font-size: 14px; transition: all .15s;
}
.card-check.checked { background: var(--success); border-color: var(--success); color: #06281c; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.card-title.struck { text-decoration: line-through; color: var(--text-dim); }
.card-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.card-note { font-size: 13.5px; color: var(--text-dim); margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.card-actions { display: flex; gap: 2px; }
.chip {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.chip.cat-trabalho { background: rgba(108,140,255,.16); color: #93acff; }
.chip.cat-pessoal { background: rgba(52,211,153,.16); color: #4ade80; }
.chip.cat-saude { background: rgba(248,113,113,.16); color: #fca5a5; }
.chip.cat-financeiro { background: rgba(251,191,36,.16); color: #fcd34d; }
.chip.recur { background: var(--bg-3); color: var(--text-dim); }
.chip.tag { background: var(--bg-3); color: var(--text-dim); }
.badge-today { color: var(--accent); font-weight: 700; }
.badge-late { color: var(--danger); font-weight: 700; }

.date-group-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); margin: 16px 2px 4px;
}
.date-group-label:first-child { margin-top: 0; }

/* ============================ EMPTY ============================ */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-dim); }
.empty-emoji { font-size: 44px; margin-bottom: 8px; }

/* Mini-calendário com a data REAL de hoje (aba Agenda vazia) */
.empty-cal {
  width: 64px;
  margin: 0 auto 12px;
  border-radius: 14px;
  overflow: hidden;
  background: #f5f5f7;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}
.empty-cal-month {
  display: block;
  background: #e0483e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 0 3px;
}
.empty-cal-day {
  display: block;
  color: #1c1c1e;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  padding: 2px 0 6px;
}

/* Versão mini do calendário para o ícone da aba Agenda */
.tab-cal {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  overflow: hidden;
  background: #f5f5f7;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
}
.tab-cal-month {
  display: block;
  background: #e0483e;
  color: #fff;
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1;
  padding: 2px 0 1px;
}
.tab-cal-day {
  display: block;
  color: #1c1c1e;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}
.empty-state p { font-weight: 600; margin: 0 0 4px; color: var(--text); }
.empty-state span { font-size: 13px; }

/* ============================ FAB ============================ */
.fab {
  position: fixed; right: 18px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; font-size: 30px; font-weight: 300;
  box-shadow: 0 8px 24px rgba(108,140,255,.4); z-index: 30;
  display: grid; place-items: center; line-height: 1;
}
.fab:active { transform: scale(.92); }
.fab.hidden { display: none !important; }

/* ============================ TABBAR ============================ */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 25;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; background: rgba(15,20,32,.92);
  backdrop-filter: blur(14px); border-top: 1px solid var(--border);
}
.tab {
  flex: 1; background: none; border: none; color: var(--text-faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; gap: 3px;
}
.tab-icon { font-size: 22px; filter: grayscale(1) opacity(.7); transition: filter .15s; }
.tab.active { color: var(--accent); }
.tab.active .tab-icon { filter: none; }

/* ============================ IDEIAS / RECORDER ============================ */
.ideias-recorder { text-align: center; margin-bottom: 18px; }
.record-btn {
  width: 100%; max-width: 320px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 26px; display: flex; flex-direction: column;
  align-items: center; gap: 10px; color: var(--text); transition: all .15s;
}
.record-btn:active { transform: scale(.98); }
.record-icon {
  width: 76px; height: 76px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 34px;
  box-shadow: 0 8px 24px rgba(108,140,255,.35);
}
.record-label { font-weight: 600; font-size: 15px; }
.record-btn.recording .record-icon { animation: pulse 1.2s infinite; background: linear-gradient(135deg, var(--danger), #ff7a7a); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,.5);} 50% { box-shadow: 0 0 0 16px rgba(248,113,113,0);} }

.record-live {
  background: var(--card); border: 1px solid var(--accent);
  border-radius: 20px; padding: 22px; max-width: 360px; margin: 0 auto;
}
.record-wave { display: flex; gap: 4px; justify-content: center; align-items: flex-end; height: 32px; margin-bottom: 14px; }
.record-wave span { width: 5px; height: 100%; background: var(--accent); border-radius: 3px; animation: wave 1s infinite ease-in-out; }
.record-wave span:nth-child(2){animation-delay:.1s} .record-wave span:nth-child(3){animation-delay:.2s}
.record-wave span:nth-child(4){animation-delay:.3s} .record-wave span:nth-child(5){animation-delay:.4s}
@keyframes wave { 0%,100%{transform:scaleY(.3)} 50%{transform:scaleY(1)} }
.record-transcript { min-height: 50px; font-size: 16px; color: var(--text); text-align: left; white-space: pre-wrap; }
.record-transcript.placeholder { color: var(--text-faint); }
.record-actions { display: flex; gap: 10px; margin-top: 16px; }
.record-actions > * { flex: 1; }
.record-hint { font-size: 12.5px; color: var(--text-faint); margin-top: 10px; }
.record-hint.warn { color: var(--warning); }

.ideias-search { margin-bottom: 14px; }

.notif-cta {
  background: var(--accent-soft); border: 1px solid rgba(108,140,255,.3);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px;
}

/* ============================ MODAL ============================ */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); animation: fade .2s; }
.modal-sheet {
  position: relative; width: 100%; max-width: 520px; margin: 0 auto;
  background: var(--bg-2); border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--border);
  padding: 8px 18px calc(20px + var(--safe-bottom));
  max-height: 92dvh; overflow-y: auto;
  animation: slideup .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 999px; margin: 8px auto 14px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.form-row { display: flex; gap: 10px; }
.form-row > label { flex: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions > * { flex: 1; }
.btn-delete {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid rgba(248,113,113,.3); border-radius: var(--radius-sm);
  padding: 13px; font-weight: 600;
}

/* ============================ TOAST ============================ */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 80px);
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 18px; font-size: 14px; z-index: 60;
  box-shadow: var(--shadow); animation: fade .2s; max-width: 90%;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* ============================ DESKTOP ============================ */
@media (min-width: 720px) {
  .app-main { max-width: 640px; margin: 0 auto; }
  .app-header { max-width: 640px; margin: 0 auto; }
  .fab { right: calc(50% - 320px + 18px); }
}
@media (min-width: 720px) and (max-width: 720px) {}
