/* ==========================================================================
   FinPilot AI — Design System
   Tipografia: Sora (display) + Inter (corpo) + JetBrains Mono (números)
   Paleta: Azul #2563EB · Verde #22C55E · Neutros premium
   Estilo: Glassmorphism sutil, inspirado em Stripe / Linear / Vercel / Apple
   ========================================================================== */

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

:root {
  /* Cores de marca */
  --blue: #2563EB;
  --blue-dark: #1E40AF;
  --blue-light: #60A5FA;
  --green: #22C55E;
  --green-light: #4ADE80;

  /* Neutros — tema claro */
  --bg: #F5F7FB;
  --bg-elevated: #FFFFFF;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #FFFFFF;
  --border: rgba(15, 23, 42, 0.08);
  --text: #0F172A;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  --danger: #EF4444;
  --warning: #F59E0B;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.12);

  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-width: 264px;
  --content-max: 1360px;
  --bottom-nav-height: 64px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #0B1120;
  --bg-elevated: #131B2E;
  --surface: rgba(19, 27, 46, 0.72);
  --surface-solid: #131B2E;
  --border: rgba(255, 255, 255, 0.08);
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --text-faint: #64748B;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

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

h1, h2, h3, h4, h5, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.mono, .amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

a { color: var(--blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--blue-dark); }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ============ Glass surfaces ============ */
.glass {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-flat {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* ============ Buttons ============ */
.btn-fp {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 12px;
  padding: 0.65rem 1.4rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-fp:active { transform: scale(0.97); }
.btn-fp:disabled,
.btn-fp[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary-fp {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.btn-primary-fp:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45); color: #fff; }

.btn-success-fp {
  background: linear-gradient(135deg, var(--green), #16A34A);
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
}
.btn-success-fp:hover:not(:disabled) { color: #fff; box-shadow: 0 6px 20px rgba(34, 197, 94, 0.45); }

.btn-ghost-fp {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost-fp:hover:not(:disabled) { background: var(--bg-elevated); color: var(--text); }

.btn-danger-fp {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger-fp:hover:not(:disabled) { background: rgba(239, 68, 68, 0.18); }

/* ============ Forms ============ */
.form-fp label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: block;
}

.form-fp .form-control,
.form-fp select,
.form-fp textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.92rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-fp textarea { min-height: 110px; resize: vertical; }

.form-fp .form-control::placeholder,
.form-fp textarea::placeholder { color: var(--text-faint); }

.form-fp .form-control:focus,
.form-fp select:focus,
.form-fp textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  outline: none;
}

.form-fp .form-control:disabled,
.form-fp select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-fp input[type='color'] { padding: 0.3rem; cursor: pointer; }

/* ============ Layout: App Shell ============ */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0 0.4rem; }
.sidebar-brand img { width: 34px; height: 34px; }
.sidebar-brand span { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--transition), color var(--transition);
}
.sidebar-link i { width: 18px; text-align: center; }
.sidebar-link:hover { background: var(--bg-elevated); color: var(--text); }
.sidebar-link.active {
  background: linear-gradient(135deg, rgba(37,99,235,0.14), rgba(34,197,94,0.10));
  color: var(--blue);
}

/* Área central: largura confortável de leitura em telas muito grandes,
   sem esticar os cards de ponta a ponta em monitores ultrawide/4K */
.main-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.75rem 2rem 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ============ Rodapé ============ */
.footer-fp {
  text-align: center;
  padding: 2rem 1.25rem 2.5rem;
  color: var(--text-faint);
  font-size: 0.8rem;
  line-height: 1.7;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}
.footer-fp a { color: var(--blue); font-weight: 600; }
.footer-fp a:hover { color: var(--blue-dark); }

/* ============ Mobile bottom nav ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding: 0.5rem 0.25rem calc(0.5rem + env(safe-area-inset-bottom));
}
.bottom-nav-inner { display: flex; justify-content: space-around; align-items: center; }
.bottom-nav-link {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  color: var(--text-faint); font-size: 0.65rem; font-weight: 600; width: 56px;
  padding: 0.3rem 0;
  border-radius: 10px;
  transition: color var(--transition), background var(--transition);
}
.bottom-nav-link i { font-size: 1.15rem; }
.bottom-nav-link:hover { color: var(--text-muted); }
.bottom-nav-link.active { color: var(--blue); background: rgba(37, 99, 235, 0.1); }

.fab {
  position: fixed;
  bottom: calc(78px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.4);
  border: none;
  z-index: 1001;
  transition: transform var(--transition), box-shadow var(--transition);
}
.fab:active { transform: scale(0.94); }

@media (max-width: 991px) {
  .sidebar { display: none; }
  .main-content { padding: 1.1rem 1rem 2.5rem; }
  .bottom-nav { display: block; }
  .fab { display: flex; }

  /* Sem isto, a barra de navegação inferior (position:fixed) fica por cima
     do rodapé quando a página é rolada até o fim, deixando o "Made with ❤️
     by Criatech" coberto/invisível no celular. Este respiro empurra o
     rodapé para cima da barra fixa + área segura do notch/gesto do iOS. */
  .footer-fp {
    padding-bottom: calc(var(--bottom-nav-height) + 1.75rem + env(safe-area-inset-bottom));
  }
}

/* ============ Ajustes finos para telas pequenas ============ */
@media (max-width: 768px) {
  .main-content { padding-left: 0.85rem; padding-right: 0.85rem; }
  .topbar { gap: 0.75rem; }
  .topbar > div:last-child { width: 100%; }
  .topbar .btn-fp { flex: 1; }
}

@media (max-width: 576px) {
  body { font-size: 14px; }
  .card, .card-flat { padding: 1.1rem; }
  .stat-value { font-size: 1.25rem; word-break: break-word; }
  .topbar h2.display { font-size: 1.35rem; }
  .auth-card { padding: 1.5rem; }
  .toast-fp { left: 0.75rem; right: 0.75rem; max-width: none; top: 0.75rem; }
  .score-ring { width: 112px; height: 112px; }
  .modal-body.p-4 { padding: 1.25rem !important; }
  .footer-fp { font-size: 0.75rem; padding-left: 1rem; padding-right: 1rem; }
}

/* ============ Misc components ============ */
.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; }
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.65rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  white-space: nowrap;
}
.pill-green { background: rgba(34,197,94,0.12); color: #16A34A; }
.pill-red { background: rgba(239,68,68,0.12); color: var(--danger); }
.pill-blue { background: rgba(37,99,235,0.12); color: var(--blue); }
.pill-gray { background: rgba(100,116,139,0.12); color: var(--text-muted); }

.progress-fp { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.progress-fp-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), var(--green)); transition: width 0.3s ease; }

.score-ring { position: relative; width: 140px; height: 140px; margin: 0 auto; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring-value { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }

.bank-chip {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem; border-radius: 14px; margin-bottom: 0.6rem;
  background: var(--bg-elevated); border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.bank-chip:hover { border-color: rgba(37, 99, 235, 0.3); }

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty-state i { font-size: 2.4rem; margin-bottom: 0.75rem; color: var(--text-faint); }

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(37,99,235,0.18), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(34,197,94,0.15), transparent 45%),
    var(--bg);
  padding: 1.5rem;
}
.auth-card { width: 100%; max-width: 420px; padding: 2.25rem; }

.toast-fp {
  position: fixed; top: 1rem; right: 1rem; z-index: 2000;
  padding: 0.9rem 1.2rem; border-radius: 12px; font-weight: 600; font-size: 0.88rem;
  box-shadow: var(--shadow-lg); color: #fff; max-width: 320px;
  animation: slideIn 0.25s ease;
}
.toast-success { background: linear-gradient(135deg, var(--green), #16A34A); }
.toast-error { background: linear-gradient(135deg, #F87171, var(--danger)); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
