/* ==========================================================================
   app.css — Design system compartilhado do Sistema Integrado NEW Elevadores
   Fonte unica de tokens e componentes. Novos modulos DEVEM usar este arquivo
   em vez de reescrever estilos. Modulos antigos serao migrados por fase.
   ========================================================================== */

:root {
  /* Cores base (extraidas do portal index.html) */
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #13201f;
  --muted: #60706d;
  --line: #d9e0df;
  --brand: #0a7c62;
  --brand-dark: #123230;
  --accent: #c88b22;
  --blue: #2563eb;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #16a34a;
  --warn: #b7791f;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 14px 34px rgba(19, 32, 31, .08);
  --shadow-sm: 0 7px 20px rgba(19, 32, 31, .05);
  --focus: 0 0 0 3px rgba(10, 124, 98, .28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a { color: inherit; }

/* ---------- Tipografia utilitaria ---------- */
.u-muted { color: var(--muted); }
.u-small { font-size: 12px; }
.u-right { text-align: right; }
.u-nowrap { white-space: nowrap; }
.u-mono { font-variant-numeric: tabular-nums; }

/* ---------- Botoes ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: #f3faf7; border-color: #c6d5d2; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0b8b6e; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; justify-content: center; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: 12px; font-weight: 800; color: #314541; text-transform: uppercase; letter-spacing: .02em; }
.field .hint { font-size: 12px; color: var(--muted); }
.field.invalid > label { color: var(--danger); }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--focus); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; font-weight: 600; }

/* ---------- Cards / paineis ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.card-body { padding: 16px; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .02em; border: 1px solid var(--line); background: #f3faf7; color: #314541;
}
.badge.ok { background: #eafaf1; color: #10794f; border-color: #bfe8d4; }
.badge.warn { background: #fdf3e2; color: var(--warn); border-color: #f0dcae; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #f3c4bf; }

/* ---------- Tabela reutilizavel ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafcfb; position: sticky; top: 0; }
table.data tbody tr:hover { background: #f7fbfa; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px; font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 6px; }

/* ---------- Estado vazio / erro ---------- */
.empty-state { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 6px; }
.error-banner {
  border: 1px solid #f3c4bf; background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px; font-weight: 600;
}

/* ---------- Toasts ---------- */
#toast-root {
  position: fixed; right: 16px; bottom: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; max-width: min(92vw, 380px);
}
.toast {
  background: #10201e; color: #eafaf5; border-radius: var(--radius);
  padding: 11px 14px; font-size: 13px; box-shadow: var(--shadow);
  border-left: 4px solid var(--brand); animation: toast-in .16s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Overlay de carregamento ---------- */
#loading-root {
  position: fixed; inset: 0; z-index: 9998; display: none;
  align-items: center; justify-content: center; background: rgba(245, 247, 248, .6); backdrop-filter: blur(1px);
}
#loading-root.show { display: flex; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #cfe3dc; border-top-color: var(--brand); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal reutilizavel ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 9997; display: none;
  align-items: center; justify-content: center; padding: 18px; background: rgba(15, 26, 25, .48);
}
.modal-backdrop.show { display: flex; }
.modal {
  width: min(560px, 100%); background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden; animation: toast-in .16s ease-out;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); background: #fafcfb; }

/* ---------- Acessibilidade ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
