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

:root {
  --bg:         #0F172A;
  --surface:    #1E293B;
  --border:     #334155;
  --accent:     #6366F1;
  --accent-h:   #4F46E5;
  --text:       #F8FAFC;
  --muted:      #94A3B8;
  --green:      #4ADE80;
  --red:        #F87171;
  --code-bg:    #0D1117;
  --nav-active: rgba(99,102,241,0.12);
}

[data-theme="light"] {
  --bg:      #F8FAFC;
  --surface: #FFFFFF;
  --border:  #CBD5E1;
  --text:    #0F172A;
  --muted:   #64748B;
  --code-bg: #F1F5F9;
}

/* public/dashboard/style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}

/* ── Login ─────────────────────────────── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: #6366f1; }
.logo-text { font-size: 18px; font-weight: 700; }

.form-group { margin-bottom: 16px; }
label { display: block; color: #888; font-size: 12px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
input[type="email"], input[type="password"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: #6366f1; }

.btn-primary {
  width: 100%;
  background: #6366f1;
  border: none;
  border-radius: 6px;
  padding: 11px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}
.btn-primary:hover { background: #4f52d9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  color: #f87171;
  font-size: 12px;
  margin-top: 10px;
  display: none;
  line-height: 1.4;
}
.error-msg.show { display: block; }

/* ── Dashboard layout ───────────────────── */
.dashboard { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.nav-item.active { background: var(--nav-active); color: var(--text); }
.nav-item:hover:not(.active) { background: #161616; color: #ccc; }
.sidebar-footer {
  margin-top: auto;
  padding: 8px 12px;
  color: #444;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main { margin-left: 200px; padding: 32px; flex: 1; max-width: 720px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { color: #555; font-size: 13px; margin-bottom: 24px; }

/* ── Cards ──────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.card-label {
  color: #666;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.usage-number { font-size: 28px; font-weight: 700; }
.usage-limit { color: #555; font-size: 16px; font-weight: 400; }
.usage-bar { background: var(--border); border-radius: 4px; height: 6px; margin-top: 12px; }
.usage-fill { background: #6366f1; height: 6px; border-radius: 4px; transition: width 0.5s ease; }
.card-sub { color: #555; font-size: 11px; margin-top: 8px; }

.plan-badge { color: #6366f1; font-size: 20px; font-weight: 700; text-transform: capitalize; }
.btn-upgrade {
  display: inline-block;
  margin-top: 12px;
  border: 1px solid #6366f1;
  color: #6366f1;
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-upgrade:hover { background: #1e1e2e; }

#btn-portal {
  margin-top: 12px;
  width: 100%;
}

.apikey-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.apikey-field {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: 'Courier New', monospace;
  color: #4ade80;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.btn-sm {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #aaa;
  border-radius: 5px;
  padding: 7px 12px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.btn-sm:hover { background: #222; color: #fff; }
.copied-feedback { color: #4ade80; font-size: 11px; margin-top: 6px; display: none; }
.copied-feedback.show { display: block; }

.success-msg {
  color: #4ade80;
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  display: none;
  line-height: 1.4;
}
.success-msg.show { display: block; }

.uso-banner { padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; background: #1a1a2e; color: #aaa; }
.uso-banner.warning { background: rgba(234,179,8,0.1); color: #fbbf24; border: 1px solid rgba(234,179,8,0.3); }
.uso-banner.danger  { background: rgba(239,68,68,0.1);  color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.uso-banner a { color: inherit; font-weight: 600; text-decoration: none; }
.success-upgrade { padding: 10px 16px; background: rgba(74,222,128,0.1); color: #4ade80; border: 1px solid rgba(74,222,128,0.3); border-radius: 8px; margin-bottom: 16px; font-size: 13px; display: none; }

/* ── Historico ──────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.history-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  transition: background 0.1s;
}
.history-header:hover { background: #161616; }

.severity-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.nivel-baixo  { background: #14532d; color: #4ade80; }
.nivel-médio  { background: #713f12; color: #fbbf24; }
.nivel-alto   { background: #7f1d1d; color: #f87171; }

.history-tipo {
  font-size: 11px;
  color: #555;
  font-family: 'Courier New', monospace;
  white-space: nowrap;
}

.history-problema {
  flex: 1;
  font-size: 13px;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time {
  font-size: 11px;
  color: #444;
  white-space: nowrap;
}

.history-detail {
  padding: 0 18px 16px;
  border-top: 1px solid #1a1a1a;
  display: none;
  flex-direction: column;
  gap: 12px;
}
.history-detail.open { display: flex; }

.detail-row { font-size: 13px; color: #aaa; line-height: 1.6; }
.detail-row strong { color: #fff; }

.detail-sugestoes { padding-left: 16px; }
.detail-sugestoes li { font-size: 12px; color: #888; margin-bottom: 4px; }

.detail-code {
  background: var(--code-bg);
  border: 1px solid #222;
  border-radius: 6px;
  padding: 10px 14px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #4ade80;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 160px;
  overflow-y: auto;
}

.confianca-bar-wrap { display: flex; align-items: center; gap: 10px; }
.confianca-bar {
  flex: 1;
  background: #222;
  border-radius: 4px;
  height: 4px;
}
.confianca-fill { background: #6366f1; height: 4px; border-radius: 4px; }

.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: #444;
  font-size: 14px;
  line-height: 1.8;
}
.history-empty a { color: #6366f1; text-decoration: none; }

/* ── Nav badge ──────────────────────────── */
.nav-item { position: relative; }
.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.nav-badge.visible { display: flex; }

/* ── Alert stat cards ────────────────────── */
.alert-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.alert-stat {
  background: var(--surface);
  border: 1px solid #2a1010;
  border-radius: 10px;
  padding: 16px 18px;
}
.alert-stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #666; margin-bottom: 6px; }
.alert-stat-value { font-size: 26px; font-weight: 700; color: #f87171; }
.alert-stat-sub { font-size: 11px; color: #555; margin-top: 4px; }

/* ── Alert list items ────────────────────── */
.alert-item {
  background: var(--surface);
  border: 1px solid #2a1010;
  border-radius: 10px;
  overflow: hidden;
}
.alert-item.is-new { border-color: #7f1d1d; animation: alertPulse 1s ease; }
@keyframes alertPulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.35); }
  60%  { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
  100% { box-shadow: none; }
}

.alert-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  transition: background 0.1s;
}
.alert-header:hover { background: #161616; }

.alert-new-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  opacity: 0;
}
.alert-item.is-new .alert-new-dot { opacity: 1; }

.alert-tipo {
  font-size: 11px;
  color: #555;
  font-family: 'Courier New', monospace;
  white-space: nowrap;
}
.alert-problema {
  flex: 1;
  font-size: 13px;
  color: #fca5a5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alert-time { font-size: 11px; color: #444; white-space: nowrap; }

.alert-empty {
  text-align: center;
  padding: 60px 20px;
  color: #444;
  font-size: 14px;
  line-height: 1.8;
}
.alert-empty a { color: #6366f1; text-decoration: none; }

/* ── Logo cursor ─────────────────────────── */
.logo-debug { color: var(--accent); font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.logo-cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--accent);
  margin-left: 1px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.sidebar-logo { display: flex; align-items: center; gap: 2px; padding: 8px 10px; margin-bottom: 12px; }

/* ── Theme toggle (sidebar) ─────────────────── */
.theme-toggle-sidebar {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
  text-align: left;
  transition: background 0.2s;
}
.theme-toggle-sidebar:hover { background: var(--surface); }
