/* ============================================================
   FinanceCouple — app.css
   CSS complementar ao TailwindCSS 3 (dark theme)
   ============================================================ */

/* ── Google Fonts fallback ───────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ───────────────────────────────────────────── */
:root {
  --fc-bg:          #0f172a;
  --fc-surface:     #1e293b;
  --fc-surface-2:   #334155;
  --fc-border:      #475569;
  --fc-text:        #f1f5f9;
  --fc-muted:       #94a3b8;
  --fc-primary:     #6366f1;
  --fc-primary-hover: #4f46e5;
  --fc-success:     #10b981;
  --fc-warning:     #f59e0b;
  --fc-danger:      #f43f5e;
  --fc-sidebar-w:   280px;
  --fc-topbar-h:    64px;
  --transition:     all 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--fc-bg);
  color: var(--fc-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar Dark ──────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--fc-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--fc-surface-2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fc-border);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--fc-surface-2) var(--fc-bg);
}

/* ── Sidebar custom scrollbar ────────────────────────────── */
#sidebar::-webkit-scrollbar {
  width: 4px;
}
#sidebar::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 2px;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Animation Classes ───────────────────────────────────── */
.animate-fade-in        { animation: fadeIn 0.3s ease forwards; }
.animate-fade-in-up     { animation: fadeInUp 0.4s ease forwards; }
.animate-slide-in-left  { animation: slideInLeft 0.3s ease forwards; }
.animate-slide-in-right { animation: slideInRight 0.3s ease forwards; }
.animate-slide-up       { animation: slideUp 0.3s ease forwards; }
.animate-scale-in       { animation: scaleIn 0.2s ease forwards; }

/* Staggered children animation */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }

/* ── Gradient Text ───────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-amber {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Gradient Backgrounds ────────────────────────────────── */
.gradient-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}
.gradient-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.gradient-danger {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
}
.gradient-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
.gradient-dark {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* ── Card Styles ─────────────────────────────────────────── */
.fc-card {
  background: var(--fc-surface);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 1.5rem;
  transition: var(--transition);
}

.fc-card:hover {
  border-color: #475569;
}

.fc-card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

/* ── Stat Card ───────────────────────────────────────────── */
.stat-card {
  background: var(--fc-surface);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--fc-primary);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* ── Chart.js container ──────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 200px;
}

.chart-container canvas {
  max-width: 100%;
}

/* ── Loading Skeleton ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--fc-surface) 25%,
    #2d3f55 50%,
    var(--fc-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-text.w-3\/4 { width: 75%; }
.skeleton-text.w-1\/2 { width: 50%; }
.skeleton-text.w-1\/4 { width: 25%; }

.skeleton-circle {
  border-radius: 50%;
}

.skeleton-card {
  background: var(--fc-surface);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 1.5rem;
  overflow: hidden;
}

/* ── Toast Notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: 10px;
  border: 1px solid transparent;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.3s ease forwards;
  transition: opacity 0.3s, transform 0.3s;
  font-size: 0.875rem;
  font-weight: 500;
  color: #f1f5f9;
}

.toast.toast-success {
  background: #064e3b;
  border-color: #10b981;
}

.toast.toast-error {
  background: #4c0519;
  border-color: #f43f5e;
}

.toast.toast-warning {
  background: #451a03;
  border-color: #f59e0b;
}

.toast.toast-info {
  background: #1e1b4b;
  border-color: #6366f1;
}

.toast.toast-hide {
  opacity: 0;
  transform: translateX(20px);
}

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.toast-close:hover {
  color: #f1f5f9;
}

/* ── Flash Messages ──────────────────────────────────────── */
.flash-message {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

.flash-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.flash-error {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

.flash-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.flash-info {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--fc-sidebar-w);
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

#sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  margin: 1px 0;
}

#sidebar .nav-link:hover {
  color: #f1f5f9;
  background: rgba(51, 65, 85, 0.5);
}

#sidebar .nav-link.active {
  color: #818cf8;
  background: rgba(99, 102, 241, 0.15);
  border-right: 2px solid #6366f1;
}

#sidebar .nav-link .nav-icon {
  font-size: 1.125rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Topbar ──────────────────────────────────────────────── */
#topbar {
  height: var(--fc-topbar-h);
  flex-shrink: 0;
}

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--fc-surface);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 0.5rem;
  min-width: 200px;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: scaleIn 0.15s ease forwards;
  transform-origin: top right;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #cbd5e1;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  border: none;
  background: none;
  text-align: left;
}

.dropdown-item:hover {
  background: rgba(51, 65, 85, 0.5);
  color: #f1f5f9;
}

.dropdown-item.danger:hover {
  background: rgba(244, 63, 94, 0.1);
  color: #fb7185;
}

.dropdown-separator {
  height: 1px;
  background: #334155;
  margin: 0.375rem 0;
}

/* ── Confirmation Dialog ─────────────────────────────────── */
#confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

#confirm-dialog {
  background: var(--fc-surface);
  border: 1px solid #475569;
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: scaleIn 0.2s ease;
}

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-danger  { background: rgba(244,63,94,0.15);  color: #fb7185; }
.badge-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-info    { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-muted   { background: rgba(148,163,184,0.1); color: #94a3b8; }

/* Notification dot badge */
.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #f43f5e;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #1e293b;
}

/* ── Form Styles ─────────────────────────────────────────── */
.fc-input {
  width: 100%;
  background: #334155;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 0.625rem 0.875rem;
  color: #f1f5f9;
  font-size: 0.875rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.fc-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.fc-input::placeholder {
  color: #64748b;
}

.fc-input.error {
  border-color: #f43f5e;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.15);
}

.fc-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #94a3b8;
  margin-bottom: 0.375rem;
}

.fc-error-msg {
  font-size: 0.75rem;
  color: #fb7185;
  margin-top: 0.25rem;
}

/* ── Password Strength Bar ───────────────────────────────── */
.pwd-strength-bar {
  height: 4px;
  border-radius: 2px;
  background: #334155;
  overflow: hidden;
  margin-top: 0.5rem;
}

.pwd-strength-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: #6366f1;
  color: white;
}
.btn-primary:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
}

.btn-secondary {
  background: #334155;
  color: #f1f5f9;
  border: 1px solid #475569;
}
.btn-secondary:hover {
  background: #3d4f65;
}

.btn-danger {
  background: #f43f5e;
  color: white;
}
.btn-danger:hover {
  background: #e11d48;
}

.btn-ghost {
  background: transparent;
  color: #94a3b8;
}
.btn-ghost:hover {
  background: rgba(51,65,85,0.5);
  color: #f1f5f9;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Tables ──────────────────────────────────────────────── */
.fc-table {
  width: 100%;
  border-collapse: collapse;
}

.fc-table th {
  background: #1e293b;
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #334155;
}

.fc-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #1e293b;
  font-size: 0.875rem;
  color: #cbd5e1;
  transition: background 0.15s;
}

.fc-table tr:hover td {
  background: rgba(51,65,85,0.3);
}

.fc-table tr:last-child td {
  border-bottom: none;
}

/* ── Auth Layout ─────────────────────────────────────────── */
.auth-bg {
  background: var(--fc-bg);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.auth-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 40%, rgba(99,102,241,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(139,92,246,0.1) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 60% 80%, rgba(16,185,129,0.07) 0%, transparent 60%);
  pointer-events: none;
}

.auth-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(99,102,241,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.auth-card {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow:
    0 0 0 1px rgba(99,102,241,0.1),
    0 24px 64px rgba(0,0,0,0.4);
  animation: fadeInUp 0.5s ease;
}

/* ── Progress / Steps ────────────────────────────────────── */
.steps-container {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  border: 2px solid #334155;
  background: #1e293b;
  color: #64748b;
  position: relative;
  z-index: 1;
  transition: var(--transition);
}

.step-circle.active {
  border-color: #6366f1;
  background: #6366f1;
  color: white;
  box-shadow: 0 0 0 4px rgba(99,102,241,0.2);
}

.step-circle.completed {
  border-color: #10b981;
  background: #10b981;
  color: white;
}

.step-label {
  font-size: 0.7rem;
  margin-top: 0.375rem;
  color: #64748b;
  white-space: nowrap;
}

.step-connector {
  height: 2px;
  background: #334155;
  flex: 1;
  margin: 0 -2px;
  margin-top: -1.5rem;
}

.step-connector.completed {
  background: #10b981;
}

/* ── Avatar ──────────────────────────────────────────────── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  text-transform: uppercase;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 1.125rem;
}

/* ── Search Results ──────────────────────────────────────── */
#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--fc-surface);
  border: 1px solid #334155;
  border-radius: 12px;
  overflow: hidden;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: scaleIn 0.15s ease forwards;
  transform-origin: top center;
}

.search-result-item {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #cbd5e1;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.875rem;
  text-decoration: none;
}

.search-result-item:hover {
  background: rgba(51,65,85,0.5);
  color: #f1f5f9;
}

/* ── Mobile Sidebar Overlay ──────────────────────────────── */
#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 40;
  display: none;
}

#sidebar-overlay.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }
}

/* ── Auto-logout warning ─────────────────────────────────── */
#auto-logout-warning {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #451a03;
  border: 1px solid #f59e0b;
  border-radius: 12px;
  padding: 1rem 1.5rem;
  color: #fbbf24;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9998;
  display: none;
  animation: slideUp 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* ── PWA safe-area ───────────────────────────────────────── */
@supports (padding: max(0px)) {
  body {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }

  #topbar {
    padding-top: max(0px, env(safe-area-inset-top));
  }
}

/* ── Transitions globais ─────────────────────────────────── */
a,
button,
input,
select,
textarea {
  transition: var(--transition);
}

/* ── Select dark ─────────────────────────────────────────── */
select.fc-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%2394a3b8' viewBox='0 0 20 20'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 011.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* ── Textarea dark ───────────────────────────────────────── */
textarea.fc-input {
  resize: vertical;
  min-height: 100px;
}

/* ── Number currency mask ────────────────────────────────── */
.currency-input {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
