/*
* base.css - variaveis, tema claro/escuro e componentes comuns (botoes, campos, avisos)
* Tema pelo atributo <html data-mode="light|dark"> (guardado em localStorage "zg-theme")
******************************************************************************/

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --border: #e3e8f2;
  --text: #5b6b82;
  --heading: #1f2a44;
  --muted: #8a97ab;
  --primary: #696cff;
  --primary-2: #8b5cf6;
  --primary-soft: rgba(105, 108, 255, 0.1);
  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.12);
  --err: #e11d48;
  --err-soft: rgba(225, 29, 72, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --radius: 14px;
  --shadow: 0 2px 6px rgba(31, 42, 68, 0.05), 0 12px 32px rgba(31, 42, 68, 0.08);
  --shadow-lg: 0 10px 40px rgba(31, 42, 68, 0.25);
  color-scheme: light;
}

html[data-mode="dark"] {
  --bg: #0d1222;
  --surface: #161c32;
  --surface-2: #1c2440;
  --border: #2a3454;
  --text: #a9b4cc;
  --heading: #eef1fa;
  --muted: #7d8aa8;
  --primary: #7c7fff;
  --primary-soft: rgba(124, 127, 255, 0.16);
  --ok-soft: rgba(34, 197, 94, 0.16);
  --err-soft: rgba(251, 113, 133, 0.16);
  --warn-soft: rgba(251, 191, 36, 0.16);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--primary); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5 { color: var(--heading); margin: 0; }
button { font: inherit; }

.ico { width: 1.2em; height: 1.2em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -0.2em; }

/* ---------- Botoes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--heading);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.primary { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 6px 16px rgba(105, 108, 255, 0.3); }
.btn.primary:hover { color: #fff; box-shadow: 0 10px 22px rgba(105, 108, 255, 0.4); }
.btn.danger { color: var(--err); border-color: rgba(225, 29, 72, 0.35); }
.btn.danger:hover { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 40px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--primary-soft); }

/* ---------- Campos ---------- */
.campo, select.campo {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--heading);
  font: inherit; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.campo:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-soft); }
.campo::placeholder { color: var(--muted); opacity: 0.85; }

/* ---------- Avisos (toast) ---------- */
#avisos { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.aviso {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); color: var(--heading); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: aviso-in 0.25s ease both;
}
.aviso.ok { border-left: 4px solid var(--ok); }
.aviso.err { border-left: 4px solid var(--err); }
.aviso .ico { margin-top: 2px; }
.aviso.ok .ico { color: var(--ok); }
.aviso.err .ico { color: var(--err); }
@keyframes aviso-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: giro 0.7s linear infinite; display: inline-block; }
@keyframes giro { to { transform: rotate(360deg); } }

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