/* ==========================================================================
   LuminaIA — Design System (theme.css)
   Fonte única de verdade para cores, tipografia e componentes reutilizados
   em todas as telas. Antes cada .html tinha seu próprio :root e componentes
   duplicados (topbar, icon-btn, card, btn, tabbar...) — isso gerava
   inconsistência (ex: profile.html e settings.html tinham paletas levemente
   diferentes) e retrabalho a cada ajuste visual. Agora é um arquivo só.
   ========================================================================== */

:root {
  /* Cores base */
  --primary: #6366F1;
  --primary-dark: #4F46E5;
  --primary-light: #818CF8;
  --accent: #22D3EE;
  --accent-dark: #0891B2;
  --bg: #0B1120;
  --surface: #1E293B;
  --surface-light: #334155;
  --surface-glass: rgba(30, 41, 59, 0.72);
  --border: rgba(148, 163, 184, 0.14);
  --text: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;
  --success: #22C55E;
  --warning: #F59E0B;
  --error: #EF4444;

  /* Gradientes */
  --grad-primary: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  --grad-surface: linear-gradient(160deg, rgba(99,102,241,0.14), rgba(15,23,42,0) 60%);

  /* Espaçamento (escala 4px) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;

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

  /* Sombras */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.24);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.32);
  --shadow-glow: 0 0 24px rgba(99,102,241,0.35);

  /* Transições */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 150ms var(--ease);
  --t-med: 260ms var(--ease);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Foco visível para acessibilidade e teclado — antes nenhuma tela tinha isso */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--primary); color: #fff; }

/* Scrollbar discreta */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--surface-light); border-radius: var(--r-full); }
::-webkit-scrollbar-track { background: transparent; }

/* Shell padrão do app */
.app {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 90% 50% at 50% 0%, rgba(99,102,241,0.32), transparent 60%),
    radial-gradient(ellipse 70% 40% at 20% 30%, rgba(34,211,238,0.10), transparent 60%),
    var(--bg);
}

.statusbar { height: env(safe-area-inset-top, 24px); flex-shrink: 0; }

/* Topo / navegação */
.topnav, .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 0;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px 2px rgba(34,211,238,0.7); }
.brand .ia { color: var(--accent); }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-glass);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-light); border-color: rgba(99,102,241,0.4); }
.icon-btn:active { transform: scale(0.92); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med);
}
.card:hover { border-color: rgba(99,102,241,0.35); box-shadow: var(--shadow-md); }
.card-interactive { cursor: pointer; }
.card-interactive:active { transform: scale(0.98); }

/* Botões */
.btn, .cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; border: none; cursor: pointer;
  border-radius: var(--r-md); padding: 14px 20px;
  transition: transform var(--t-fast), box-shadow var(--t-med), filter var(--t-fast);
}
.btn-primary, .cta {
  background: var(--grad-primary); color: #fff;
  box-shadow: 0 6px 20px rgba(99,102,241,0.35);
}
.btn-primary:hover, .cta:hover { filter: brightness(1.08); box-shadow: 0 8px 26px rgba(99,102,241,0.45); }
.btn-primary:active, .cta:active { transform: scale(0.97); }
.btn-secondary { background: var(--surface-light); color: var(--text); }
.btn-secondary:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

/* Tabbar / navegação inferior */
.tabbar, .bottom-nav {
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--text-tertiary); font-size: 11px; font-weight: 500;
  padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer;
  transition: color var(--t-fast), transform var(--t-fast);
  background: none; border: none;
}
.tab.active { color: var(--accent); }
.tab:active { transform: scale(0.92); }

/* Toast / mensagens */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 12px 18px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: opacity var(--t-med), transform var(--t-med);
  z-index: 999; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.error { border-color: rgba(239,68,68,0.5); }
.toast.success { border-color: rgba(34,197,94,0.5); }

/* Skeleton loading — antes as telas ficavam em branco/piscando durante fetch */
.skeleton {
  position: relative; overflow: hidden; background: var(--surface-light);
  border-radius: var(--r-md);
}
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(248,250,252,0.08), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Empty state padrão */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--sp-3); padding: var(--sp-8) var(--sp-5); color: var(--text-secondary);
}
.empty-state .icon { width: 56px; height: 56px; opacity: 0.5; }
.empty-state h3 { color: var(--text); font-size: 16px; font-weight: 600; }
.empty-state p { font-size: 14px; line-height: 1.5; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field input, .field textarea, .field select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 13px 14px; border-radius: var(--r-md); font-size: 15px; font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

/* Utilidades de entrada/transição de página */
.fade-in { animation: fadeIn var(--t-med) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.pulse { animation: pulseGlow 2s ease-in-out infinite; }
@keyframes pulseGlow { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-tertiary); }

.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }
