/* ============================================================ RESET & TOKENS */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --radius: 16px;
  --radius-sm: 11px;
  --ease: cubic-bezier(.16,.84,.44,1);
  --sidebar-w: 264px;

  /* prioridades (iguais nos dois temas) */
  --p1: #ff5a5a;
  --p2: #ff9f43;
  --p3: #4d9fff;
  --p4: #8a8a99;
}

/* ---------- DARK ---------- */
:root, :root[data-theme="dark"] {
  --bg: #0d0d12;
  --bg-2: #131319;
  --surface: rgba(255,255,255,.045);
  --surface-2: rgba(255,255,255,.06);
  --surface-solid: #1a1b23;
  --border: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.16);
  --text: #ececf2;
  --text-dim: #9797a6;
  --text-faint: #63636f;
  --accent: #ff4d4d;
  --accent-soft: rgba(255,77,77,.14);
  --accent-2: #ff8a3d;
  --shadow: 0 18px 50px rgba(0,0,0,.5);
  --glow: 0 0 40px rgba(255,77,77,.35);
  color-scheme: dark;
}

/* ---------- LIGHT ---------- */
:root[data-theme="light"] {
  --bg: #f4f1ea;
  --bg-2: #eae5da;
  --surface: rgba(255,255,255,.72);
  --surface-2: #ffffff;
  --surface-solid: #ffffff;
  --border: rgba(30,25,20,.10);
  --border-strong: rgba(30,25,20,.18);
  --text: #23201b;
  --text-dim: #6b6459;
  --text-faint: #a49c8e;
  --accent: #c92a2a;
  --accent-soft: rgba(201,42,42,.10);
  --accent-2: #e8590c;
  --shadow: 0 16px 40px rgba(80,60,40,.14);
  --glow: 0 0 30px rgba(201,42,42,.22);
  color-scheme: light;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .4s var(--ease), color .3s var(--ease);
}

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; }

.glass {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border);
}

/* ============================================================ BOTÕES */
.btn-primary {
  font-family: var(--font-body);
  font-weight: 600; font-size: 14px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 20px; cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), filter .2s;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: var(--glow); }
.btn-primary:active { transform: translateY(0); }
.btn-glow { box-shadow: 0 8px 24px -8px var(--accent); }

.btn-ghost {
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 18px; cursor: pointer; transition: all .18s var(--ease);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); background: var(--surface-2); }

.icon-btn {
  background: transparent; border: none; color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
  font-size: 16px; display: grid; place-items: center;
  transition: all .16s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ============================================================ AUTH */
.auth-screen { position: relative; min-height: 100vh; overflow: hidden; }

.auth-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; will-change: transform; }
.orb-1 { width: 480px; height: 480px; background: var(--accent); top: -140px; left: -100px; }
.orb-2 { width: 420px; height: 420px; background: var(--accent-2); bottom: -160px; right: 8%; opacity: .4; }
.orb-3 { width: 300px; height: 300px; background: #6d5cff; top: 40%; left: 45%; opacity: .3; }
.auth-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
  opacity: .5;
}

.auth-split {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.05fr .95fr;
  min-height: 100vh; align-items: center;
  max-width: 1180px; margin: 0 auto; padding: 40px;
}

.auth-hero-inner { max-width: 480px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.auth-brand-logo { width: 52px; height: 52px; object-fit: contain; }
.auth-brand-name { font-family: var(--font-display); font-weight: 800; font-size: 26px; }
.auth-headline { font-size: clamp(38px, 5vw, 58px); line-height: 1.02; font-weight: 800; }
.grad-text {
  background: linear-gradient(105deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-sub { color: var(--text-dim); font-size: 17px; line-height: 1.6; margin: 22px 0 34px; }
.auth-features { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.auth-features li { display: flex; align-items: center; gap: 13px; font-size: 15px; color: var(--text); }
.feat-ic {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); font-size: 18px;
}

.auth-panel { display: flex; justify-content: flex-end; }
.auth-card { border-radius: 22px; padding: 34px 30px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }

.tabs { position: relative; display: flex; margin-bottom: 26px; background: var(--surface-2); border-radius: 12px; padding: 5px; }
.tab-btn {
  flex: 1; z-index: 1; background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  color: var(--text-dim); padding: 9px; transition: color .2s var(--ease);
}
.tab-btn.active { color: #fff; }
:root[data-theme="light"] .tab-btn.active { color: #fff; }
.tab-indicator {
  position: absolute; z-index: 0; top: 5px; left: 5px; height: calc(100% - 10px); width: calc(50% - 5px);
  background: var(--accent); border-radius: 9px; transition: transform .28s var(--ease);
  box-shadow: 0 6px 16px -6px var(--accent);
}
.tabs.signup .tab-indicator { transform: translateX(100%); }

.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form label, .stack-form label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); display: flex; flex-direction: column; gap: 7px; }
.auth-form input, .stack-form input, .stack-form select {
  font-family: var(--font-body); font-size: 14px; font-weight: 400; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; transition: border-color .18s, box-shadow .18s;
}
.auth-form input:focus, .stack-form input:focus, .stack-form select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.error { color: var(--accent); font-size: 13px; min-height: 15px; }
.success { color: #2ec27e; font-size: 13px; min-height: 15px; }

/* ============================================================ APP SHELL */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg-2); border-right: 1px solid var(--border);
  padding: 22px 16px;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.sidebar-logo { width: 38px; height: 38px; object-fit: contain; }
.sidebar-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 13px;
  background: none; border: none; cursor: pointer; text-align: left;
  font-family: var(--font-body); font-size: 14.5px; font-weight: 500; color: var(--text-dim);
  padding: 11px 12px; border-radius: 11px; position: relative;
  transition: all .16s var(--ease);
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.nav-ic { width: 22px; text-align: center; font-size: 15px; }
.nav-label { flex: 1; }
.nav-count {
  font-size: 12px; font-weight: 700; color: var(--text-faint);
  min-width: 20px; text-align: center;
}
.nav-item.active .nav-count { color: var(--accent); }

.sidebar-foot { display: flex; flex-direction: column; gap: 4px; }
.side-action {
  display: flex; align-items: center; gap: 11px;
  background: none; border: none; cursor: pointer; text-align: left;
  font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--text-dim);
  padding: 10px 12px; border-radius: 10px; transition: all .16s var(--ease);
}
.side-action:hover { background: var(--surface); color: var(--text); }
.side-action-ic { width: 18px; text-align: center; }

.user-chip {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  padding: 10px; border-radius: 13px; background: var(--surface); border: 1px solid var(--border);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.user-meta { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-faint); }

/* ---------- CONTENT ---------- */
.content { padding: 40px 44px; max-width: 920px; width: 100%; margin: 0 auto; }
.view { animation: viewIn .45s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 26px; gap: 20px; }
.view-title { font-size: 30px; font-weight: 800; }
.view-date { color: var(--text-dim); font-size: 14px; margin-top: 4px; text-transform: capitalize; }

.view-progress {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  padding: 8px 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border);
}

/* ---------- QUICK ADD ---------- */
.quick-add { border-radius: var(--radius); padding: 14px; margin-bottom: 30px; box-shadow: var(--shadow); }
.quick-add-main { display: flex; align-items: center; gap: 12px; }
.qa-check {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  border: 2px dashed var(--border-strong); background: none; cursor: pointer;
  transition: all .16s;
}
.qa-check:hover { border-color: var(--accent); }
#item-titulo {
  flex: 1; background: none; border: none; color: var(--text);
  font-family: var(--font-body); font-size: 16px; padding: 4px 0;
}
#item-titulo:focus { outline: none; }
#item-titulo::placeholder { color: var(--text-faint); }
.btn-add { flex-shrink: 0; }

.quick-add-opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--border); }
.pill-select, .pill-input {
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 11px; transition: border-color .16s;
}
.pill-select:focus, .pill-input:focus { outline: none; border-color: var(--accent); }
.pill-grow { flex: 1; min-width: 160px; }

/* ---------- TASK LIST ---------- */
.list-block { margin-bottom: 26px; }
.list-heading { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 12px; }
.list-heading.dim { color: var(--text-faint); }
.heading-count { color: var(--text-faint); margin-left: 4px; }

.task-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.task-card {
  display: flex; align-items: flex-start; gap: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; transition: all .18s var(--ease);
  animation: cardIn .4s var(--ease) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.task-card:hover { border-color: var(--border-strong); transform: translateX(3px); }
.task-card.prio-1 { border-left: 3px solid var(--p1); }
.task-card.prio-2 { border-left: 3px solid var(--p2); }
.task-card.prio-3 { border-left: 3px solid var(--p3); }

.task-check {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  border: 2px solid var(--border-strong); background: none; cursor: pointer;
  display: grid; place-items: center; color: transparent; font-size: 12px;
  transition: all .18s var(--ease);
}
.task-check.p1 { border-color: var(--p1); }
.task-check.p2 { border-color: var(--p2); }
.task-check.p3 { border-color: var(--p3); }
.task-check:hover { background: var(--accent-soft); }
.task-check.done { background: var(--accent); border-color: var(--accent); color: #fff; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 15px; font-weight: 500; line-height: 1.35; }
.task-list.done .task-title { text-decoration: line-through; color: var(--text-faint); }
.task-desc { font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; align-items: center; }

.chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; display: inline-flex; align-items: center; gap: 4px; }
.chip-tarefa { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.chip-evento { background: rgba(255,159,67,.16); color: var(--accent-2); }
.chip-wa { background: rgba(37,211,102,.16); color: #25d366; }
.chip-time { background: var(--accent-soft); color: var(--accent); }
.chip-owner { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--border); }

.task-del { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 15px; padding: 4px; opacity: 0; transition: all .16s; border-radius: 7px; }
.task-card:hover .task-del { opacity: 1; }
.task-del:hover { color: var(--accent); background: var(--accent-soft); }

.empty-hint { color: var(--text-faint); font-size: 14px; padding: 22px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-sm); }

/* ---------- PRÓXIMOS ---------- */
.upcoming { display: flex; flex-direction: column; gap: 24px; }
.upcoming-group h3 { font-size: 14px; color: var(--accent); margin-bottom: 10px; text-transform: capitalize; }

/* ---------- CALENDÁRIO ---------- */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.cal-grid-wrap { border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; margin-bottom: 10px; }
.cal-weekdays span { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-faint); }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; padding: 7px; cursor: pointer;
  border: 1px solid transparent; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 4px; transition: all .15s var(--ease); position: relative;
}
.cal-cell:hover { border-color: var(--border-strong); }
.cal-cell.other { opacity: .35; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.selected { background: var(--accent-soft); border-color: var(--accent); }
.cal-num { font-size: 13px; font-weight: 600; }
.cal-cell.today .cal-num { color: var(--accent); }
.cal-dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: auto; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-dot.evento { background: var(--accent-2); }

.cal-agenda { border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-height: 300px; }
.cal-agenda h3 { font-size: 15px; margin-bottom: 14px; text-transform: capitalize; }
.agenda-list { display: flex; flex-direction: column; gap: 9px; }
.agenda-item { display: flex; gap: 11px; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.agenda-time { font-size: 12px; font-weight: 700; color: var(--accent); min-width: 42px; }
.agenda-title { font-size: 13.5px; font-weight: 500; }

/* ---------- AUTOMAÇÕES ---------- */
.auto-banner { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 26px; font-size: 13.5px; color: var(--text-dim); }
.auto-banner-ic { font-size: 18px; }
.auto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 14px; }
.auto-card {
  border-radius: var(--radius); padding: 20px; position: relative;
  background: var(--surface); border: 1px solid var(--border);
  transition: all .18s var(--ease); animation: cardIn .4s var(--ease) both;
}
.auto-card:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow); }
.auto-card.on { border-color: var(--accent); background: var(--accent-soft); }
.auto-ic { font-size: 30px; margin-bottom: 12px; }
.auto-name { font-size: 16px; font-weight: 700; font-family: var(--font-display); }
.auto-descr { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin: 6px 0 16px; }
.auto-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auto-config-text { font-size: 12px; color: var(--text-faint); }

/* switch */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; cursor: pointer; transition: background .2s; }
.switch-track::before { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .22s var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

.auto-add-btn { font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: none; border-radius: 9px; padding: 8px 14px; cursor: pointer; transition: filter .15s; }
.auto-add-btn:hover { filter: brightness(1.1); }

/* ============================================================ MODAIS */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px; overflow-y: auto; animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  border-radius: 20px; padding: 30px; width: 100%; max-width: 500px;
  box-shadow: var(--shadow); background: var(--surface-solid);
  animation: modalIn .3s var(--ease);
}
.modal-narrow { max-width: 420px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-card h2 { font-size: 21px; margin-bottom: 6px; }
.modal-sub { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; margin-bottom: 22px; }

.stack-form { display: flex; flex-direction: column; gap: 16px; }
.stack-form fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 16px 16px 6px; display: flex; flex-direction: column; gap: 12px; }
.stack-form legend { font-size: 12px; font-weight: 700; color: var(--accent); padding: 0 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.users-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 14px; }
.users-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); padding: 8px; border-bottom: 1px solid var(--border); }
.users-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.users-table select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13px; }

/* ============================================================ TOAST */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong);
  padding: 13px 22px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); z-index: 200; opacity: 0; transition: all .3s var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================ RESPONSIVO */
@media (max-width: 860px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { justify-content: center; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; height: auto; width: 100%; z-index: 50;
    flex-direction: row; padding: 8px; border-right: none; border-top: 1px solid var(--border);
  }
  .sidebar-brand, .sidebar-foot { display: none; }
  .sidebar-nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav-item { flex-direction: column; gap: 3px; padding: 8px; font-size: 11px; }
  .nav-item.active::before { display: none; }
  .nav-count { display: none; }
  .content { padding: 24px 18px 90px; }
  .cal-layout { grid-template-columns: 1fr; }
}
