/* Tarefas Perneco — telemóvel primeiro, claro e escuro conforme o sistema. */

:root {
  --accent: #5e35b1;
  --accent-strong: #4527a0;
  --accent-soft: #ede7f6;
  --bg: #f5f4fa;
  --surface: #ffffff;
  --border: #e4e1ee;
  --text: #1b1830;
  --muted: #6c6880;
  --danger: #d32f2f;
  --danger-soft: #fdecea;
  --ok: #2e7d32;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(27 24 48 / 6%), 0 6px 18px rgb(27 24 48 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #9575cd;
    --accent-strong: #b39ddb;
    --accent-soft: #2a2340;
    --bg: #110f1a;
    --surface: #1b1828;
    --border: #2d2940;
    --text: #ece9f5;
    --muted: #9c97b0;
    --danger: #ef6c6c;
    --danger-soft: #3a1d22;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 18px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body.no-scroll { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ───────────────────────────────────────────────────────────── entrada ── */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login__card {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px;
  text-align: center;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.login__logo { font-size: 56px; }
.login__card h1 { margin: 8px 0; font-size: 1.5rem; }
.login__button { display: flex; justify-content: center; margin-top: 20px; min-height: 44px; }

.alert {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  text-align: left;
}

.alert--error { background: var(--danger-soft); color: var(--danger); }

/* ───────────────────────────────────────────────────────────── aplicação ── */

.app {
  min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--accent);
  color: #fff;
}

.topbar__title { flex: 1; margin: 0; font-size: 1.25rem; font-weight: 600; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.3rem;
  cursor: pointer;
}

.icon-btn:active { background: rgb(255 255 255 / 15%); }

.sync--spinning { animation: spin 1s linear infinite; }
.sync--pending::after {
  content: "";
  position: relative;
  top: -12px;
  left: -2px;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffca28;
}

@keyframes spin { to { transform: rotate(360deg); } }

.avatar {
  width: 36px;
  height: 36px;
  padding: 0;
  overflow: hidden;
  border: 2px solid rgb(255 255 255 / 60%);
  border-radius: 50%;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff3cd;
  color: #5d4300;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  .banner { background: #3d3214; color: #ffe08a; }
}

/* Listas (filtros) */
.filters {
  display: flex;
  gap: 8px;
  padding: 12px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
  white-space: nowrap;
  cursor: pointer;
}

.chip--active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip__count { opacity: 0.7; font-size: 0.8rem; }

.content { padding: 0 16px; max-width: 720px; margin: 0 auto; }

.group {
  margin: 18px 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.group--late { color: var(--danger); }

.todo {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.todo__check {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.todo--done .todo__check { background: var(--accent); }
.todo--done .todo__title { color: var(--muted); text-decoration: line-through; }

.todo--pending { opacity: 0.75; }
.todo--pending .todo__check { border: 0; font-size: 1.1rem; }

.todo__main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.todo__title { font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }

.todo__notes {
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo__meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.8rem; color: var(--muted); }

.tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tag--late { background: var(--danger-soft); color: var(--danger); }
.tag--high { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.tag--low { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.empty { padding: 48px 16px; text-align: center; }
.empty__icon { font-size: 48px; }
.empty p { margin: 6px 0; }

.footnote { margin: 20px 0; text-align: center; font-size: 0.8rem; }

/* Barra de baixo: escrever ou ditar */
.addbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}

.addbar input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  font-size: 1rem;
}

.addbar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.mic,
.addbar__send {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  margin-top: -16px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.7rem;
  box-shadow: 0 4px 14px rgb(94 53 177 / 45%);
  cursor: pointer;
}

.addbar__send { width: 48px; height: 48px; margin-top: 0; font-size: 1.2rem; }
.mic:active, .addbar__send:active { transform: scale(0.95); }

/* ───────────────────────────────────────────────────────────── a ouvir ── */

.listen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--accent-strong) 94%, black);
  color: #fff;
  text-align: center;
}

.listen__hint { margin: 0; font-size: 1.05rem; opacity: 0.85; }

.listen__text {
  min-height: 4.5em;
  max-width: 560px;
  margin: 0;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1.4;
}

.listen__mic {
  width: 112px;
  height: 112px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--accent-strong);
  font-size: 3rem;
  cursor: pointer;
}

.listen--active .listen__mic { animation: pulse 1.4s ease-out infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(255 255 255 / 55%); }
  100% { box-shadow: 0 0 0 36px rgb(255 255 255 / 0%); }
}

.listen__help { max-width: 420px; margin: 0; font-size: 0.85rem; color: rgb(255 255 255 / 70%); }

.listen__cancel {
  padding: 10px 24px;
  border: 1px solid rgb(255 255 255 / 50%);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

/* ─────────────────────────────────────────────────────────── folha modal ── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(0 0 0 / 45%);
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
}

.sheet__title { margin: 0 0 12px; font-size: 1.15rem; }
.sheet__body { display: grid; gap: 14px; }

.sheet__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.field { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); min-width: 0; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  resize: vertical;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }

.btn {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--danger { color: var(--danger); margin-right: auto; }
.btn:disabled { opacity: 0.6; }

.facts { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.sheet a { color: var(--accent); }

/* ──────────────────────────────────────────────────────────────── avisos ── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 12px;
  background: #2b2540;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.toast__action {
  margin-left: 8px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d1c4e9;
  font-weight: 700;
  cursor: pointer;
}

.install-btn {
  position: fixed;
  right: 16px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 30;
  padding: 10px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
}
