/* ============================================================
   SICAF — DESIGN SYSTEM
   Fonte única de verdade para tokens visuais e componentes base.
   Cores da identidade original preservadas; tudo o mais (tipografia,
   espaçamento, sombras, raios, componentes) foi reconstruído.
   ============================================================ */

@import url(https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap);

:root {
  /* ---------- Cor: identidade preservada ---------- */
  --primary-rgb: 11, 112, 68;
  --primary: #0b7044;
  --primary-hover: #095c38;
  --primary-dark: #0d5533;
  --on-primary: #ffffff;
  --primary-soft: rgba(var(--primary-rgb), 0.08);
  --primary-soft-strong: rgba(var(--primary-rgb), 0.14);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.1);

  /* ---------- Superfícies (claro) ---------- */
  --bg: #f5f7f9;
  --bg-subtle: #eef1f4;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e5e9ee;
  --border-strong: #d7dde3;
  --text: #14202b;
  --text-muted: #5b6b7a;
  --text-faint: #93a1ae;

  --focus-ring: 0 0 0 4px var(--primary-soft-strong);

  /* ---------- Tipografia ---------- */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --text-xs: 0.75rem;    /* 12 */
  --text-sm: 0.8125rem;  /* 13 */
  --text-base: 0.875rem; /* 14 */
  --text-md: 0.9375rem;  /* 15 */
  --text-lg: 1.125rem;   /* 18 */
  --text-xl: 1.375rem;   /* 22 */
  --text-2xl: 1.75rem;   /* 28 */
  --text-3xl: 2.125rem;  /* 34 */

  --leading-tight: 1.2;
  --leading-snug: 1.4;
  --leading-normal: 1.6;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;

  /* ---------- Espaçamento (escala base 4px) ---------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* ---------- Raios ---------- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* ---------- Sombras (extremamente suaves) ---------- */
  --shadow-xs: 0 1px 2px rgba(16, 24, 32, 0.04);
  --shadow-sm: 0 2px 6px rgba(16, 24, 32, 0.05);
  --shadow-md: 0 8px 24px -6px rgba(16, 24, 32, 0.10), 0 2px 8px -4px rgba(16, 24, 32, 0.06);
  --shadow-lg: 0 20px 45px -14px rgba(16, 24, 32, 0.18);
  --shadow-primary-glow: 0 8px 20px -6px rgba(var(--primary-rgb), 0.35);

  /* ---------- Layout ---------- */
  --sidebar-width: 240px;
  --sidebar-width-rail: 76px;
  --header-height: 64px;
  --content-max: 1320px;

  /* ---------- Movimento ---------- */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 0.12s;
  --duration-base: 0.18s;
  --duration-slow: 0.32s;

  color-scheme: light;
}

/* ---------- Tema escuro: mesma identidade, superfícies invertidas ---------- */
.dark-mode {
  --primary-rgb: 45, 212, 168;
  --primary: #2dd4a8;
  --primary-hover: #22c397;
  --primary-dark: #17a884;
  --on-primary: #04120c;
  --primary-soft: rgba(45, 212, 168, 0.1);
  --primary-soft-strong: rgba(45, 212, 168, 0.18);

  --success: #2dd4a8;
  --success-soft: rgba(45, 212, 168, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.12);

  --bg: #070b10;
  --bg-subtle: #0a0f16;
  --surface: #0d131b;
  --surface-raised: #111925;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #e7edf3;
  --text-muted: #8a99ab;
  --text-faint: #566473;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 50px -16px rgba(0, 0, 0, 0.65);

  color-scheme: dark;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--duration-slow) var(--ease), color var(--duration-slow) var(--ease);
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--weight-semibold); letter-spacing: -0.01em; line-height: var(--leading-tight); color: var(--text); }
p { margin: 0; }
a { color: var(--primary); }
button { font-family: inherit; }
::selection { background: var(--primary-soft-strong); }

*:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(var(--primary-rgb), 0.25); border-radius: var(--radius-full); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--primary-rgb), 0.4); background-clip: padding-box; }

/* ============================================================
   TIPOGRAFIA UTILITÁRIA
   ============================================================ */
.ds-eyebrow { font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.ds-h1 { font-size: var(--text-2xl); font-weight: var(--weight-extrabold); }
.ds-h2 { font-size: var(--text-xl); font-weight: var(--weight-bold); }
.ds-h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.ds-body-muted { color: var(--text-muted); font-size: var(--text-sm); }
.ds-mono { font-family: var(--font-mono); }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--duration-base) var(--ease), border-color var(--duration-base) var(--ease),
              color var(--duration-base) var(--ease), box-shadow var(--duration-base) var(--ease), transform var(--duration-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-icon-only { width: 40px; padding: 0; }
.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { height: 48px; padding: 0 var(--space-6); font-size: var(--text-md); }

.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--shadow-primary-glow); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--primary); color: var(--primary); }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; box-shadow: 0 8px 20px -6px rgba(239, 68, 68, 0.4); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(0.94); }

.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; animation: ds-spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-outline.is-loading::after, .btn-ghost.is-loading::after {
  border-color: var(--primary-soft-strong); border-top-color: var(--primary);
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--duration-base) var(--ease), border-color var(--duration-base) var(--ease), transform var(--duration-base) var(--ease);
}
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-2px); }
.card-header { padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.card-body { padding: var(--space-6); }
.card-title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.card-subtitle { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   INPUTS / FORMULÁRIOS
   ============================================================ */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field-label { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.field-hint { font-size: var(--text-xs); color: var(--text-faint); }
.field-error { font-size: var(--text-xs); color: var(--danger); display: flex; align-items: center; gap: var(--space-1); }

.input, .select, .textarea {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  transition: border-color var(--duration-base) var(--ease), box-shadow var(--duration-base) var(--ease), background-color var(--duration-base) var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: var(--space-3); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-subtle); color: var(--text-faint); cursor: not-allowed; }
.input.has-error, .select.has-error { border-color: var(--danger); }
.input.has-error:focus { box-shadow: 0 0 0 4px var(--danger-soft); }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 2.5rem; }
.input-group-icon { position: absolute; left: var(--space-3); color: var(--text-faint); font-size: var(--text-sm); pointer-events: none; }
.input-group-action { position: absolute; right: var(--space-3); color: var(--text-muted); cursor: pointer; font-size: var(--text-sm); }

/* ============================================================
   BADGES / CHIPS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 24px; padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  line-height: 1; white-space: nowrap;
}
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral { background: var(--bg-subtle); color: var(--text-muted); }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.badge-success { background: var(--success-soft); color: #067a55; }
.badge-warning { background: var(--warning-soft); color: #92600a; }
.badge-danger { background: var(--danger-soft); color: #c62828; }
.badge-info { background: var(--info-soft); color: #1d5fc2; }
.dark-mode .badge-success { color: var(--success); }
.dark-mode .badge-warning { color: var(--warning); }
.dark-mode .badge-danger { color: var(--danger); }
.dark-mode .badge-info { color: var(--info); }
.dark-mode .badge-primary { color: var(--primary); }

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.ds-table thead th {
  text-align: left; padding: var(--space-3) var(--space-4);
  background: var(--bg-subtle); color: var(--text-muted);
  font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
.ds-table tbody td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); color: var(--text); }
.ds-table tbody tr:last-child td { border-bottom: none; }
.ds-table tbody tr { transition: background-color var(--duration-fast) var(--ease); }
.ds-table tbody tr:hover { background: var(--primary-soft); }

/* ============================================================
   ESTADOS: LOADING / VAZIO / ERRO
   ============================================================ */
.skeleton { background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border) 37%, var(--bg-subtle) 63%); background-size: 400% 100%; animation: ds-shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes ds-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.state-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--space-12) var(--space-6); gap: var(--space-3); color: var(--text-muted); }
.state-panel-icon { width: 56px; height: 56px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; background: var(--bg-subtle); font-size: 1.4rem; color: var(--text-faint); }
.state-panel-title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text); }
.state-panel-desc { font-size: var(--text-sm); max-width: 360px; }

/* ============================================================
   ANIMAÇÕES DE ENTRADA (sutis)
   ============================================================ */
@keyframes ds-fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.ds-enter { animation: ds-fade-up var(--duration-slow) var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
