/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0c0e1a;
  --surface:     #131629;
  --surface-2:   #1a1e35;
  --border:      #242840;
  --primary:     #6366f1;
  --primary-dim: #4f52d9;
  --primary-glow:rgba(99,102,241,.15);
  --success:     #22c55e;
  --error:       #ef4444;
  --warning:     #f59e0b;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --radius:      10px;
  --sidebar-w:   240px;
  --font:        'Inter', system-ui, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
a    { color: var(--primary); text-decoration: none; }

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

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.logo-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.logo-sub  { font-size: 11px; color: var(--primary); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-footer {
  padding: 10px 10px 18px;
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-glow); color: var(--primary); }
.logout-btn:hover { background: rgba(239,68,68,.12); color: var(--error); }

/* ─── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0;
  z-index: 10;
}
.page-heading { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-time  { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.content-area { padding: 28px; flex: 1; }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content:''; width:6px; height:6px; border-radius:50%; background:currentColor; }
.badge-active  { background: rgba(34,197,94,.12); color: var(--success); }
.badge-error   { background: rgba(239,68,68,.12);  color: var(--error); }
.badge-warning { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-info    { background: var(--primary-glow);  color: var(--primary); }

/* ─── Cards / Stats ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.stat-ok    .stat-value { color: var(--success); }
.stat-error .stat-value { color: var(--error); }
.stat-info  .stat-value { color: var(--primary); }

/* ─── Panel ─────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 14px; font-weight: 600; }
.panel-body  { padding: 0; }

/* ─── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead tr { border-bottom: 1px solid var(--border); }
th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 7px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-sm      { padding: 4px 10px; font-size: 12px; }
.btn-ghost   { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger  { background: rgba(239,68,68,.15); color: var(--error); border: 1px solid rgba(239,68,68,.2); }

/* ─── Login Page ────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,.08) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 20%, rgba(99,102,241,.05) 0%, transparent 50%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 24px 48px rgba(0,0,0,.4);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px;
}
.login-logo .logo-mark { width: 44px; height: 44px; font-size: 16px; }
.login-logo .logo-name { font-size: 18px; font-weight: 700; }
.login-logo .logo-sub  { font-size: 12px; }

.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email] {
  width: 100%; padding: 10px 14px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 15px; margin-top: 8px; }

.alert {
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  margin-bottom: 16px;
}
.alert-error   { background: rgba(239,68,68,.12); color: var(--error); border: 1px solid rgba(239,68,68,.2); }
.alert-success { background: rgba(34,197,94,.12);  color: var(--success); border: 1px solid rgba(34,197,94,.2); }

/* ─── State Grid ────────────────────────────────────────────────────────────── */
.state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  padding: 20px;
}
.state-chip {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 10px 6px; border-radius: 8px;
  font-size: 11px; font-weight: 600; text-align: center; cursor: default;
  border: 1px solid transparent;
  transition: transform .1s;
}
.state-chip:hover { transform: scale(1.04); }
.state-chip .uf   { font-size: 14px; font-weight: 700; }
.state-ok      { background: rgba(34,197,94,.08);  color: var(--success); border-color: rgba(34,197,94,.18); }
.state-error   { background: rgba(239,68,68,.08);  color: var(--error);   border-color: rgba(239,68,68,.18); }
.state-unknown { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }

/* ─── Log Viewer ────────────────────────────────────────────────────────────── */
.log-entry { border-bottom: 1px solid var(--border); }
.log-entry-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; cursor: pointer;
}
.log-entry-header:hover { background: var(--surface-2); }
.log-entry-body {
  display: none;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
}
.log-entry-body.open { display: block; }
pre.json-block {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px; line-height: 1.6;
  color: var(--text-muted); white-space: pre-wrap; word-break: break-all;
}

/* ─── Agent Status ──────────────────────────────────────────────────────────── */
.agent-status-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 13px;
}
.agent-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
}
.agent-dot.running  { background: var(--success); box-shadow: 0 0 6px var(--success); animation: pulse 2s infinite; }
.agent-dot.stopped  { background: var(--error); }
.agent-dot.idle     { background: var(--warning); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* ─── Moderação ─────────────────────────────────────────────────────────────── */
.mod-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.mod-item:last-child { border-bottom: none; }
.mod-actions { display: flex; gap: 8px; flex-shrink: 0; }
.mod-uf   { font-weight: 700; font-size: 16px; min-width: 40px; }
.mod-info { flex: 1; }
.mod-err  { font-size: 12px; color: var(--error); margin-top: 2px; font-family: monospace; }

/* ─── Iframe (Agentes) ───────────────────────────────────────────────────────── */
.agent-frame {
  width: 100%; height: calc(100vh - 100px);
  border: none; border-radius: var(--radius);
  background: var(--surface);
}

/* ─── Misc ───────────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-dim);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .3; }
.section-label { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 12px; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.ml-auto { margin-left: auto; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
