/* ==========================================================================
   VANCEC FINANCE — global.css
   Tokens de design, reset, tipografia, componentes base (botões, inputs,
   cards, badges, alertas) e utilitários.
   ========================================================================== */

@import url("../assets/fonts/inter.css");

/* ------------------------------- Tokens --------------------------------- */
:root {
  /* Cores da marca (Dark Premium + dourado Vancec) */
  --bg: #0B1120;
  --bg-soft: #0E1626;
  --surface: #172338;
  --surface-2: #1C2A44;
  --surface-3: #223252;

  --primary: #C9A24A;
  --primary-hover: #B08C3C;
  --primary-soft: rgba(201, 162, 74, 0.15);
  --primary-bright: #E8C87E;  /* dourado claro: texto/ícone sobre fundo escuro */
  --on-primary: #0B1120;      /* texto sobre botões e elementos dourados */

  --income: #22C55E;
  --income-soft: rgba(34, 197, 94, 0.14);
  --expense: #F87171;
  --expense-soft: rgba(248, 113, 113, 0.14);
  --warning: #FBBF24;
  --warning-soft: rgba(251, 191, 36, 0.14);

  --text: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;

  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.26);

  /* Medidas */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.4);
  --shadow: 0 10px 30px -12px rgba(2, 6, 23, 0.8);
  --shadow-lg: 0 30px 60px -25px rgba(2, 6, 23, 0.9);

  --container: 1160px;
  --header-h: 68px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* -------------------------------- Reset --------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

p { margin: 0; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--primary-bright); }

img, svg, canvas { display: block; max-width: 100%; }

ul, ol { margin: 0; padding: 0; list-style: none; }

/* Garante que o atributo [hidden] sempre vença os display dos componentes */
[hidden] { display: none !important; }

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

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

::selection {
  background: rgba(201, 162, 74, 0.4);
  color: #fff;
}

/* Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  border: 3px solid var(--bg);
}

/* ------------------------------ Estrutura ------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 20px;
}

.section {
  padding-block: 88px;
}

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.grow { flex: 1 1 auto; }

/* ----------------------------- Tipografia ------------------------------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-income { color: var(--income); }
.text-expense { color: var(--expense); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.mono-num { font-variant-numeric: tabular-nums; }

/* ------------------------------- Botões --------------------------------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-border: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition),
    border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--on-primary);
  --btn-border: transparent;
  box-shadow: 0 8px 20px -10px rgba(201, 162, 74, 0.9);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
  --btn-bg: transparent;
  --btn-border: var(--border-strong);
}

.btn-subtle {
  --btn-bg: rgba(148, 163, 184, 0.08);
  --btn-border: transparent;
}

.btn-danger {
  --btn-bg: rgba(248, 113, 113, 0.12);
  --btn-fg: var(--expense);
  --btn-border: rgba(248, 113, 113, 0.3);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-lg { padding: 14px 26px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon {
  padding: 0;
  width: 38px;
  height: 38px;
  flex: none;
}
.btn[disabled],
.btn.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* -------------------------------- Cards --------------------------------- */
.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

/* ------------------------------- Formulários ---------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition),
    background var(--transition);
}

.input::placeholder,
.textarea::placeholder { color: var(--text-dim); }

.input:hover,
.select:hover,
.textarea:hover { border-color: rgba(148, 163, 184, 0.4); }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input[type="date"],
.input[type="month"] { color-scheme: dark; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.select option { background: var(--surface); color: var(--text); }

.textarea { resize: vertical; min-height: 84px; }

.field-hint { font-size: 12px; color: var(--text-dim); }
.field-error { font-size: 12px; color: var(--expense); }

.input-money {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --------------------------------- Badges ------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-income { background: var(--income-soft); color: var(--income); }
.badge-expense { background: var(--expense-soft); color: var(--expense); }
.badge-primary { background: var(--primary-soft); color: var(--primary-bright); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-no-dot::before { display: none; }

/* -------------------------------- Alertas ------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.alert[hidden] { display: none; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-info { border-color: rgba(201, 162, 74, 0.35); background: var(--primary-soft); }
.alert-success { border-color: rgba(34, 197, 94, 0.35); background: var(--income-soft); }
.alert-error { border-color: rgba(248, 113, 113, 0.35); background: var(--expense-soft); }
.alert-warning { border-color: rgba(251, 191, 36, 0.35); background: var(--warning-soft); }
.alert a { font-weight: 600; text-decoration: underline; }

/* -------------------------------- Avatar -------------------------------- */
.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #E8C87E, #BE9542);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* --------------------------------- Modal -------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  animation: fade-in 140ms ease-out;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modal-in 180ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.modal-title { font-size: 18px; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------- Utilitários ---------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 20px 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(248, 250, 252, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
}
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg {
  width: 34px;
  height: 34px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.empty-state strong { color: var(--text); font-size: 15px; }
.empty-state p { font-size: 13.5px; max-width: 320px; }

/* Marca — logo oficial (ouro #BE9542 sobre o fundo escuro) */
.logo {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  line-height: 0;
  transition: opacity var(--transition);
}
.logo img {
  display: block;
  height: 34px;
  width: auto;
}
.logo:hover { opacity: 0.88; }
.logo:focus-visible { outline-offset: 4px; border-radius: 4px; }

/* ------------------------------ Responsivo ------------------------------ */
@media (max-width: 720px) {
  .section { padding-block: 64px; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 18px; }
}

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