/* ============================================================
   ATLAS ESTRATÉGICO — Sistema de Design v1
   Dark + Light · Mobile-first · Premium UI
============================================================ */

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

/* ===== TOKENS ===== */
:root {
  /* Tipografia */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Marca */
  --brand:        #2a6cf6;
  --brand-2:      #7c3aed;
  --brand-deep:   #0f2a44;
  --brand-soft:   rgba(42, 108, 246, 0.12);

  /* Estados */
  --success:      #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning:      #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger:       #ef4444;
  --danger-soft:  rgba(239, 68, 68, 0.12);
  --info:         #06b6d4;
  --info-soft:    rgba(6, 182, 212, 0.12);

  /* Layout */
  --radius-sm:    8px;
  --radius:       14px;
  --radius-lg:    20px;
  --radius-xl:    24px;

  /* Animações */
  --ease:         cubic-bezier(.2, .9, .3, 1);
  --transition:   .18s var(--ease);

  /* Sidebar */
  --sidebar-w:    260px;
  --topbar-h:     64px;
}

/* ===== TEMA DARK (padrão) ===== */
:root,
html[data-theme="dark"] {
  --bg:           #070b12;
  --bg-2:         #0b1220;
  --surface:      rgba(255, 255, 255, 0.04);
  --surface-2:    rgba(255, 255, 255, 0.06);
  --surface-hi:   rgba(255, 255, 255, 0.09);
  --border:       rgba(255, 255, 255, 0.10);
  --border-hi:    rgba(255, 255, 255, 0.18);

  --text:         #e7eaf1;
  --text-soft:    #b8bfd0;
  --text-muted:   #7a8294;
  --text-faded:   rgba(255, 255, 255, 0.35);

  --shadow-sm:    0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow:       0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg:    0 24px 60px rgba(0, 0, 0, 0.5);

  --aurora-1:     rgba(42, 108, 246, 0.18);
  --aurora-2:     rgba(124, 58, 237, 0.16);

  --input-bg:     rgba(255, 255, 255, 0.05);
  --input-border: rgba(255, 255, 255, 0.12);

  --ring:         0 0 0 3px rgba(42, 108, 246, 0.25);

  color-scheme: dark;
}

/* ===== TEMA LIGHT ===== */
html[data-theme="light"] {
  --bg:           #f6f8ff;
  --bg-2:         #eef3ff;
  --surface:      rgba(255, 255, 255, 0.85);
  --surface-2:    rgba(255, 255, 255, 0.7);
  --surface-hi:   #ffffff;
  --border:       rgba(15, 23, 42, 0.08);
  --border-hi:    rgba(15, 23, 42, 0.16);

  --text:         #0b1220;
  --text-soft:    #2c3447;
  --text-muted:   #5b677a;
  --text-faded:   rgba(15, 23, 42, 0.45);

  --shadow-sm:    0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow:       0 14px 38px rgba(15, 23, 42, 0.08);
  --shadow-lg:    0 24px 60px rgba(15, 23, 42, 0.10);

  --aurora-1:     rgba(42, 108, 246, 0.14);
  --aurora-2:     rgba(124, 58, 237, 0.10);

  --input-bg:     rgba(255, 255, 255, 0.6);
  --input-border: rgba(15, 23, 42, 0.10);

  --ring:         0 0 0 3px rgba(42, 108, 246, 0.18);

  color-scheme: light;
}

/* ===== RESET ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 700px at 14% 0%, var(--aurora-1), transparent 62%),
    radial-gradient(900px 600px at 86% 12%, var(--aurora-2), transparent 62%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== TIPOGRAFIA ===== */
.h1 { font-size: clamp(1.5rem, 1.1rem + 1.5vw, 2rem); font-weight: 900; letter-spacing: -.03em; line-height: 1.1; }
.h2 { font-size: 1.4rem;  font-weight: 800; letter-spacing: -.02em; }
.h3 { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; }
.h4 { font-size: 1rem;    font-weight: 700; }
.muted { color: var(--text-muted); }
.faded { color: var(--text-faded); }
.kicker { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: var(--text-muted); }

/* ===== UTILITÁRIOS ===== */
.row    { display: flex; gap: 12px; align-items: center; }
.row-sb { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.col    { display: flex; flex-direction: column; gap: 12px; }
.grow   { flex: 1; min-width: 0; }
.center { display: flex; align-items: center; justify-content: center; }
.hide-mobile { display: initial; }
.show-mobile { display: none; }
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: initial; }
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.card.compact { padding: 16px; }
.card.flat { box-shadow: none; }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 800; color: var(--text); }
.card-sub   { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

/* ===== BOTÕES ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  background: var(--surface-2);
  color: var(--text);
  font-size: .92rem; font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--surface-hi);
  border-color: var(--border-hi);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff !important;
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(42, 108, 246, 0.32);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 12px 28px rgba(42, 108, 246, 0.42);
}

.btn-success { background: var(--success); color: #fff; border-color: transparent; }
.btn-success:hover:not(:disabled) { background: #0ea371; }

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

.btn-ghost { background: transparent; }
.btn-link  { background: transparent; border: 0; padding: 0; color: var(--brand); font-weight: 700; min-height: auto; }
.btn-link:hover { text-decoration: underline; }

.btn-sm { padding: 7px 12px; min-height: 34px; font-size: .82rem; border-radius: 10px; }
.btn-lg { padding: 14px 22px; min-height: 50px; font-size: 1rem; border-radius: 16px; }
.btn-icon { padding: 0; width: 38px; height: 38px; min-height: 38px; }
.btn-icon.btn-sm { width: 32px; height: 32px; min-height: 32px; }
.btn-block { width: 100%; }

/* ===== INPUTS ===== */
.input,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="tel"],
input[type="url"], input[type="date"], input[type="time"],
input[type="datetime-local"], textarea, select {
  width: 100%;
  padding: 12px 14px;
  min-height: 44px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: .94rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.input:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.input::placeholder, input::placeholder, textarea::placeholder {
  color: var(--text-faded);
}
textarea { min-height: 96px; resize: vertical; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: .78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.field-hint  { font-size: .78rem; color: var(--text-faded); }
.field-error { font-size: .8rem; color: var(--danger); font-weight: 600; }

/* checkbox e radio custom */
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  border: 1px solid transparent;
  display: flex; align-items: flex-start; gap: 10px;
  line-height: 1.5;
}
.alert-success { background: var(--success-soft); border-color: rgba(16, 185, 129, 0.25); color: var(--success); }
.alert-warning { background: var(--warning-soft); border-color: rgba(245, 158, 11, 0.25); color: var(--warning); }
.alert-danger  { background: var(--danger-soft);  border-color: rgba(239, 68, 68, 0.25);  color: var(--danger); }
.alert-info    { background: var(--info-soft);    border-color: rgba(6, 182, 212, 0.25);  color: var(--info); }

html[data-theme="dark"] .alert-success { color: #6ee7b7; }
html[data-theme="dark"] .alert-warning { color: #fcd34d; }
html[data-theme="dark"] .alert-danger  { color: #fca5a5; }
html[data-theme="dark"] .alert-info    { color: #67e8f9; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-soft);
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-brand   { background: var(--brand-soft);   border-color: rgba(42, 108, 246, 0.25);   color: var(--brand); }
.badge-success { background: var(--success-soft); border-color: rgba(16, 185, 129, 0.25);   color: var(--success); }
.badge-warning { background: var(--warning-soft); border-color: rgba(245, 158, 11, 0.25);   color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  border-color: rgba(239, 68, 68, 0.25);    color: var(--danger); }

html[data-theme="dark"] .badge-brand   { color: #93c5fd; }
html[data-theme="dark"] .badge-success { color: #6ee7b7; }
html[data-theme="dark"] .badge-warning { color: #fcd34d; }
html[data-theme="dark"] .badge-danger  { color: #fca5a5; }

/* ===== AVATAR ===== */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: .82rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(42, 108, 246, 0.32);
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.2rem; }
.avatar-sm { width: 30px; height: 30px; font-size: .68rem; }

/* ===== PROGRESS BAR ===== */
.progress {
  height: 8px;
  width: 100%;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  transition: width .6s var(--ease);
}
.progress-fill.success { background: linear-gradient(90deg, var(--success), #059669); }
.progress-fill.warning { background: linear-gradient(90deg, var(--warning), #d97706); }
.progress-fill.danger  { background: linear-gradient(90deg, var(--danger),  #dc2626); }

/* ===== EMPTY STATE ===== */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: .6; }
.empty-title { font-size: 1.05rem; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.empty-text { font-size: .9rem; line-height: 1.6; max-width: 380px; margin: 0 auto 18px; }

/* ===== LAYOUT APP (sidebar + topbar) ===== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
}

.app-sidebar {
  position: sticky; top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  gap: 4px;
  overflow-y: auto;
  z-index: 50;
}
@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .3s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.is-open { transform: translateX(0); }
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  backdrop-filter: blur(4px);
}
@media (max-width: 1024px) {
  .sidebar-overlay.is-open { display: block; }
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  font-weight: 900; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(42, 108, 246, 0.4);
}
.sidebar-brand-text { font-size: .98rem; font-weight: 800; }
.sidebar-brand-sub  { font-size: .68rem; color: var(--text-muted); }

.sidebar-section {
  font-size: .68rem; font-weight: 800;
  color: var(--text-faded);
  text-transform: uppercase; letter-spacing: .12em;
  padding: 14px 12px 6px;
}

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-soft);
  font-size: .9rem; font-weight: 600;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sidebar-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.sidebar-item.is-active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}
html[data-theme="dark"] .sidebar-item.is-active { color: #93c5fd; }
.sidebar-item-icon { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-item-badge {
  margin-left: auto;
  font-size: .68rem; font-weight: 800;
  background: var(--danger);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 20px; text-align: center;
}

.app-main {
  display: flex; flex-direction: column;
  min-width: 0; /* fix overflow */
}

.app-topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
.topbar-toggle {
  display: none;
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  align-items: center; justify-content: center;
}
@media (max-width: 1024px) { .topbar-toggle { display: flex; } }

.topbar-title { font-size: 1rem; font-weight: 800; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.app-content {
  padding: 24px 20px;
  max-width: 100%;
  overflow-x: hidden;
}
@media (min-width: 1280px) {
  .app-content { padding: 28px 32px; }
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 1.05rem;
}
.theme-toggle:hover { background: var(--surface-hi); }
html[data-theme="dark"] .theme-toggle .icon-light { display: none; }
html[data-theme="light"] .theme-toggle .icon-dark { display: none; }

/* ===== LAYOUT AUTH (login/cadastro) ===== */
.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1200px 600px at 80% 10%, var(--aurora-1), transparent 60%),
    radial-gradient(900px 700px at 10% 90%, var(--aurora-2), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-title { font-size: 1.6rem; font-weight: 900; letter-spacing: -.03em; margin-bottom: 6px; }
.auth-sub   { font-size: .9rem; color: var(--text-muted); margin-bottom: 24px; }
.auth-foot  { margin-top: 22px; text-align: center; font-size: .88rem; color: var(--text-muted); }
.auth-foot a { color: var(--brand); font-weight: 700; }

/* ===== FLASH MESSAGES (toast) ===== */
.flash-stack {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
  max-width: calc(100vw - 36px);
}
.flash-toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  font-size: .9rem;
  font-weight: 600;
  min-width: 280px;
  animation: toastIn .3s var(--ease);
}
.flash-toast.success { border-color: rgba(16, 185, 129, 0.3); }
.flash-toast.warning { border-color: rgba(245, 158, 11, 0.3); }
.flash-toast.error,
.flash-toast.danger  { border-color: rgba(239, 68, 68, 0.3); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 80;
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .2s var(--ease);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px);
  animation: modalIn .3s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ===== SCROLLBAR ===== */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ===== ACCESSIBILITY ===== */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ===========================================================
   GLOBAL TOOLTIP — funciona em qualquer card/bloco com data-tooltip
   Não fica cortado por overflow de pais
   =========================================================== */
#atlas-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-hi);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.45;
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .12s var(--ease);
  backdrop-filter: blur(14px);
}
#atlas-tooltip.is-visible { opacity: 1; }
