/* =====================================================
   LEGISAPP DESIGN SYSTEM v2
   Institucional refinado · dark-first · dourado/azul-petróleo
   ===================================================== */

/* ----- Tokens ----- */
:root {
  /* Cores - paleta institucional */
  --primary:       #1a2f4a;
  --primary-light: #264060;
  --primary-dark:  #0f1d30;
  --accent:        #d4a530;
  --accent-light:  #e0b94d;
  --accent-dark:   #b8901f;
  --accent-soft:   rgba(212, 165, 48, 0.12);

  /* Superfícies */
  --bg-base:       #0a1420;
  --bg-elevated:   #111e2e;
  --bg-card:       #152233;
  --bg-card-hover: #1a2940;
  --bg-input:      #0e1c2c;

  /* Texto */
  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary:  #94a3b8;
  --text-quaternary:#64748b;
  --text-on-accent: #1a1408;

  /* Bordas */
  --border-subtle:   rgba(212, 165, 48, 0.06);
  --border-default:  rgba(212, 165, 48, 0.12);
  --border-strong:   rgba(212, 165, 48, 0.25);
  --border-focus:    rgba(212, 165, 48, 0.5);
  --divider:         rgba(255, 255, 255, 0.06);

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

  /* Raios */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-full: 9999px;

  /* Espaços */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* Tipografia */
  --font-display: 'Fraunces', 'Plus Jakarta Sans', Georgia, serif;
  --font-sans:    'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Sombras */
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--border-subtle);
  --shadow-lg:  0 12px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border-subtle);
  --shadow-glow: 0 0 0 1px var(--border-strong), 0 8px 24px -4px rgba(212, 165, 48, 0.2);

  /* Transições */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;
}

/* ----- Reset & base ----- */
*, *::before, *::after { box-sizing: border-box; }
* { font-family: var(--font-sans); }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----- Background institucional ----- */
.dark body {
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 1200px 800px at 12% -10%, rgba(38, 64, 96, 0.32) 0%, transparent 55%),
    radial-gradient(ellipse 800px 600px at 88% 100%, rgba(184, 144, 31, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 600px 400px at 50% 50%, rgba(15, 29, 48, 0.4) 0%, transparent 70%);
  background-attachment: fixed;
  min-height: 100vh;
}

.light body {
  background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  background-attachment: fixed;
  color: #0f172a;
  min-height: 100vh;
}

/* ----- Scrollbar refinada ----- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); background-clip: padding-box; border: 2px solid transparent; }

/* ----- Tipografia ----- */
h1, h2, h3, h4 { margin: 0; color: var(--text-primary); letter-spacing: -0.01em; }

.t-display-1 { font-family: var(--font-display); font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.t-display-2 { font-family: var(--font-display); font-size: 24px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; }
.t-display-3 { font-family: var(--font-display); font-size: 18px; font-weight: 500; line-height: 1.3; }

.t-section   { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary); }
.t-label     { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); }
.t-body      { font-size: 14px; font-weight: 400; color: var(--text-secondary); }
.t-body-strong { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.t-micro     { font-size: 11px; font-weight: 500; color: var(--text-quaternary); }
.t-mono      { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ----- Superfícies ----- */
.surface {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-subtle);
}

.surface-elevated {
  background: linear-gradient(160deg, rgba(21, 34, 51, 0.95) 0%, rgba(11, 22, 35, 0.95) 100%);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

.surface-glass {
  background: rgba(11, 22, 35, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
}

/* Backwards-compat (HTML existente) */
.glass         { background: rgba(11, 22, 35, 0.85); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border: 1px solid var(--border-default); box-shadow: var(--shadow-md); }
.glass-card    { background: linear-gradient(160deg, rgba(21,34,51,0.95) 0%, rgba(11,22,35,0.95) 100%); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-md); border-radius: var(--r-lg); }

/* ----- Botões ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0 var(--s-5);
  height: 42px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: none;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-in-out);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { height: 34px; padding: 0 var(--s-3); font-size: 13px; }
.btn-lg { height: 50px; padding: 0 var(--s-6); font-size: 15px; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: var(--text-on-accent);
  box-shadow: 0 1px 0 inset rgba(255, 255, 255, 0.2), 0 4px 14px -2px rgba(212, 165, 48, 0.4);
}
.btn-primary:not(:disabled):hover {
  box-shadow: 0 1px 0 inset rgba(255, 255, 255, 0.25), 0 6px 20px -4px rgba(212, 165, 48, 0.5);
  transform: translateY(-1px);
  filter: brightness(1.05);
}
.btn-primary:not(:disabled):active { transform: translateY(0); filter: brightness(0.95); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:not(:disabled):hover { background: var(--bg-card-hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
}
.btn-ghost:not(:disabled):hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:not(:disabled):hover { background: #dc2626; }

/* ----- Inputs ----- */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease-in-out), background var(--dur-fast) var(--ease-in-out);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-quaternary); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-focus);
  background: var(--bg-elevated);
}

/* Neutralizar autofill do Chrome/Edge que sobrescreve com fundo amarelo */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  caret-color: var(--text-primary);
  transition: background-color 9999s ease-in-out 0s;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2394a3b8' stroke-width='1.5' d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-4) center;
  padding-right: var(--s-10);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }

/* ----- Badges & chips ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-2);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent-light); }
.badge-neutral { background: rgba(255,255,255,0.06); color: var(--text-tertiary); }
.badge-atas         { background: var(--info-soft); color: #60a5fa; }
.badge-pautas       { background: var(--warning-soft); color: #fbbf24; }
.badge-publicacoes  { background: rgba(168, 85, 247, 0.12); color: #c084fc; }
.badge-legislativa  { background: var(--accent-soft); color: var(--accent-light); }

/* ----- Stat cards ----- */
.stat-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  overflow: hidden;
}
.stat-card-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); }
.stat-card-value { font-size: 28px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-card-icon  { position: absolute; top: var(--s-3); right: var(--s-3); opacity: 0.4; font-size: 16px; }

/* ----- Tabs (linha inferior) ----- */
.tabbar {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--divider);
  padding: 0;
  margin-bottom: var(--s-6);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-in-out);
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab i { font-size: 13px; opacity: 0.7; transition: opacity var(--dur-fast); }
.tab:hover { color: var(--text-secondary); }
.tab:hover i { opacity: 1; }
.tab.is-active { color: var(--accent); }
.tab.is-active i { opacity: 1; color: var(--accent); }
.tab.is-active::after {
  content: '';
  position: absolute;
  left: var(--s-3);
  right: var(--s-3);
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: var(--r-full) var(--r-full) 0 0;
  animation: tab-slide var(--dur-base) var(--ease-out);
}
@keyframes tab-slide {
  from { transform: scaleX(0.3); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}

/* ----- Stepper ----- */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: nowrap;
}
.step {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  transition: all var(--dur-base) var(--ease-out);
}
.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-quaternary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  border: 1.5px solid var(--divider);
  transition: all var(--dur-base) var(--ease-out);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-quaternary);
  letter-spacing: 0.02em;
  transition: color var(--dur-base) var(--ease-out);
  white-space: nowrap;
}
.step.active .step-num {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.step.active .step-label { color: var(--accent); }
.step.completed .step-num {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}
.step.completed .step-label { color: var(--text-tertiary); }
.step-line {
  width: 36px;
  height: 1.5px;
  background: var(--divider);
  border-radius: 1px;
  transition: background var(--dur-base) var(--ease-out);
  margin: 0 4px;
}
.step-line.active { background: var(--accent); }

/* ----- Animações ----- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.fade-in { animation: fadeIn var(--dur-base) var(--ease-out); }
.slide-up { animation: slideUp var(--dur-slow) var(--ease-out); }

/* ----- Spinner ----- */
.spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ----- Utilitários ----- */
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.divider-h { height: 1px; background: var(--divider); margin: var(--s-4) 0; }

/* Garantir que .hidden sempre esconda, mesmo contra display:flex de outras classes */
.hidden { display: none !important; }

/* Utility: stack vertical (flex column) com gap */
.stack-y { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-y-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.stack-y-lg { display: flex; flex-direction: column; gap: var(--s-6); }

/* Light theme overrides */
.light .surface, .light .glass-card { background: white; border-color: rgba(15, 23, 42, 0.08); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04); }
.light .glass { background: rgba(255, 255, 255, 0.95); border-color: rgba(15, 23, 42, 0.08); }
.light .text-white { color: #0f172a !important; }
.light .text-gray-300, .light .text-gray-400 { color: #334155 !important; }
.light .text-gray-500, .light .text-gray-600 { color: #64748b !important; }
.light .border-gray-700 { border-color: #e2e8f0 !important; }
.light .input, .light .select, .light .textarea { background: white; border-color: #e2e8f0; color: #0f172a; }
