/* ═══════════════════════════════════════════════════════════
   YORAI ADMIN — dashboard.css
   Layout principal: sidebar, topbar, views, grids.
   Variáveis do dashboard (sobrescrevem as de login ao ativar).
═══════════════════════════════════════════════════════════ */

:root {
  --teal: #5CC8C2;
  --pink: #F4A7B9;
  --teal-light: #A8E4E1;
  --pink-light: #FAD4DE;
  --dark: #0F0F1A;
  --mid: #1E1E30;
  --soft: #6B6B8A;
  --bg: #0F0F1A;
  --white: #161625;
  --surface: #1A1A2E;
  --surface2: #1E1E30;
  --surface3: #252538;
  --border: rgba(92,200,194,0.12);
  --border2: rgba(92,200,194,0.20);
  --text: #E8E8F0;
  --text2: #9090B0;
  --text3: #5A5A7A;
  --sidebar-w: 220px;
  --green: #22c55e;
  --red: #ef4444;
  --gold: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --r: 16px;
  --accent-gradient: linear-gradient(135deg, var(--teal), var(--pink));
  --cta-gradient: linear-gradient(135deg, var(--teal), var(--teal-light));
}

* { margin: 0; padding: 0; box-sizing: border-box }

::-webkit-scrollbar { width: 4px; height: 4px }
::-webkit-scrollbar-track { background: transparent }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 100px }

body {
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  padding-bottom: 20px;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo img {
  width: 32px; height: 32px;
  border-radius: 9px;
  object-fit: cover;
}

.sidebar-logo-text {
  font-family: "Cormorant Garamond", serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.3px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 100px;
  background: rgba(244,167,185,0.15);
  color: var(--pink);
  border: 1px solid rgba(244,167,185,0.25);
  font-weight: 700;
  letter-spacing: .8px;
  margin-left: auto;
}

.nav-section {
  padding: 16px 16px 5px;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.70);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  margin: 1px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  font-size: 13px;
  color: rgba(255,255,255,0.70);
  font-weight: 500;
  user-select: none;
}

.nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.90) }

.nav-item.active {
  background: rgba(92,200,194,0.12);
  color: var(--teal-light);
  border: 1px solid rgba(92,200,194,0.2);
}

.nav-icon { font-size: 14px; width: 18px; text-align: center }

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 100px;
  background: rgba(239,68,68,0.2);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.25);
}

.sidebar-sep { height: 1px; background: rgba(255,255,255,0.06); margin: 8px 14px }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0 }

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 var(--border);
}

.page-title {
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.topbar-right { display: flex; align-items: center; gap: 8px }

.sys-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 100px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sys-pill.ok { background: rgba(92,200,194,0.08); border: 1px solid rgba(92,200,194,0.25); color: #0d9488 }
.sys-pill.warn { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25); color: var(--gold) }

.dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor }

.content {
  flex: 1;
  padding: 26px 28px;
  overflow-y: auto;
  max-height: calc(100vh - 58px);
  overflow-x: hidden;
}

.view { display: none }
.view.active { display: block; animation: fadeIn .2s ease }

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

/* GRIDS */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 16px }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 14px; margin-bottom: 16px }
.three-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; margin-bottom: 16px }

/* SECTION HEADER */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px }
.section-title { font-family: "Cormorant Garamond", serif; font-size: 18px; font-weight: 700; color: var(--text) }

/* MINI CHART */
.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 64px }
.mini-bar { flex: 1; border-radius: 4px 4px 0 0; background: var(--surface3); transition: background .15s; min-width: 0 }
.mini-bar:hover { background: rgba(92,200,194,0.3) }
.mini-bar.hl { background: var(--teal); opacity: 1 }

/* TOAST WRAP */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px }

.search-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 9px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  flex: 1;
  min-width: 0;
}
.search-bar input::placeholder { color: var(--text3) }

/* TIMELINE */
.timeline { display: flex; flex-direction: column; gap: 0 }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; position: relative }
.timeline-item:not(:last-child)::before { content: ''; position: absolute; left: 7px; top: 22px; bottom: -2px; width: 1px; background: var(--border) }
.tl-dot { width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; border: 2px solid var(--surface); z-index: 1 }
.tl-dot.plan { background: var(--teal) }
.tl-dot.payment { background: var(--green) }
.tl-dot.warn { background: var(--gold) }
.tl-dot.contact { background: var(--blue) }
.tl-dot.discount { background: var(--purple) }
.tl-title { font-size: 12.5px; color: var(--text); font-weight: 500 }
.tl-meta { font-size: 11px; color: var(--text3); margin-top: 1px }

/* NEXT ACTION */
.next-action-card { background: linear-gradient(135deg, rgba(92,200,194,0.06), rgba(244,167,185,0.04)); border: 1px solid rgba(92,200,194,0.2); border-radius: 12px; padding: 14px 16px; margin-top: 14px }
.next-action-label { font-size: 11px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; display: flex; align-items: center; gap: 5px }
.next-action-text { font-size: 12.5px; color: var(--text); line-height: 1.5 }

/* COHORT */
.cohort-table { width: 100%; border-collapse: collapse; font-size: 12px }
.cohort-table th { padding: 8px 12px; text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text3); border-bottom: 1px solid var(--border); background: var(--surface2) }
.cohort-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text2) }
.cohort-table tr:last-child td { border-bottom: none }
.cohort-cell { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 22px; border-radius: 5px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums }
.c-high { background: rgba(34,197,94,0.15); color: #15803d }
.c-mid { background: rgba(245,158,11,0.12); color: #b45309 }
.c-low { background: rgba(239,68,68,0.1); color: #dc2626 }
.c-na { background: var(--surface3); color: var(--text3) }

/* MODAL TABS */
.modal-tabs { display: flex; gap: 2px; background: var(--surface2); border-radius: 10px; padding: 3px; margin-bottom: 18px }
.modal-tab { flex: 1; padding: 6px 10px; border-radius: 8px; border: none; font-size: 12px; font-weight: 600; color: var(--text3); background: none; cursor: pointer; font-family: inherit; transition: background .15s, color .15s }
.modal-tab.active { background: var(--surface2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.3) }

/* HAMBURGER */
.hamburger {
  display: none;
  position: relative;
  left: auto; top: auto;
  transform: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  z-index: 10;
  flex-shrink: 0;
  margin-right: 6px;
}
.hamburger span { width: 18px; height: 2px; background: var(--text2); border-radius: 2px; display: block; transition: transform .2s, opacity .2s }

/* OVERLAY */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 299; backdrop-filter: blur(3px) }
.overlay.open { display: block }

/* COMPACT SIDEBAR */
.sidebar.compact { width: 52px; min-width: 52px }
.sidebar.compact .sidebar-logo-text,
.sidebar.compact .sidebar-badge,
.sidebar.compact .nav-section,
.sidebar.compact .nav-item span:not(.nav-icon),
.sidebar.compact .nav-badge { display: none }
.sidebar.compact .nav-item { justify-content: center; padding: 10px; margin: 1px 4px }
.sidebar.compact .nav-icon { font-size: 16px; width: auto }
.sidebar.compact .sidebar-sep { margin: 6px 8px }
.sidebar.compact .sidebar-logo { justify-content: center; padding: 16px 0 }
.sidebar.compact .sidebar-logo img { margin: 0 }
.sidebar-compact-btn { display: flex; align-items: center; justify-content: flex-end; padding: 8px 12px; cursor: pointer; color: rgba(255,255,255,0.35); transition: color .15s; margin-top: auto }
.sidebar-compact-btn:hover { color: rgba(255,255,255,0.65) }
.sidebar.compact .sidebar-compact-btn { justify-content: center; padding: 10px }
.main { transition: none }

/* DEMO BANNER */
#demo-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(245,158,11,0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(245,158,11,0.4);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #1a1000;
  letter-spacing: .2px;
  text-align: center;
  flex-wrap: wrap;
}
#demo-banner svg { flex-shrink: 0 }
body.has-demo-banner .topbar { top: 30px }
body.has-demo-banner .sidebar { top: 30px; height: calc(100vh - 30px) }
body.has-demo-banner { padding-top: 30px }

/* CACHE INDICATOR */
.cache-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(92,200,194,0.08);
  border: 1px solid rgba(92,200,194,0.2);
  color: #0d9488;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  vertical-align: middle;
  margin-left: 6px;
}
.cache-pill.visible { opacity: 1 }

/* LOGS PAGINATION */
.logs-pag-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  font-size: 12px;
  color: var(--text3);
}
.logs-cursor-btn {
  padding: 5px 14px;
  border-radius: 50px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, color .15s;
}
.logs-cursor-btn:hover:not(:disabled) { border-color: var(--teal); color: #0d9488 }
.logs-cursor-btn:disabled { opacity: .35; cursor: not-allowed }

/* CMD PALETTE */
@keyframes cmdIn { from { opacity: 0; transform: translateY(-8px) scale(0.97) } to { opacity: 1; transform: translateY(0) scale(1) } }
@keyframes cmdOut { from { opacity: 1; transform: translateY(0) scale(1) } to { opacity: 0; transform: translateY(-8px) scale(0.97) } }
#cmd-overlay { display: none; align-items: flex-start; justify-content: center }
#cmd-overlay.open { display: flex }
#cmd-overlay.open .cmd-box { animation: cmdIn .18s ease-out }
#cmd-overlay.closing .cmd-box { animation: cmdOut .14s ease-in forwards }

/* CMD API SEARCH INDICATOR */
.cmd-api-pill { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text3); padding: 4px 10px; border-radius: 6px; background: var(--surface2) }
.cmd-spinner { width: 10px; height: 10px; border: 1.5px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; flex-shrink: 0 }

/* ERROR BANNER */
#error-banner {
  display: none;
  position: sticky;
  top: 58px;
  z-index: 49;
  background: rgba(200,50,50,0.97);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(239,68,68,0.4);
  padding: 8px 16px;
  min-height: 0;
  max-height: 48px;
  height: 48px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  flex-wrap: nowrap;
}
#error-banner.visible { display: flex }
#error-banner-msg { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0 }
#error-banner-retry {
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 50px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
#error-banner-retry:hover { background: rgba(255,255,255,0.3) }
body.has-demo-banner #error-banner { top: 88px }
