/* AgentDror Dashboard — Admin UI styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2d3148;
  --text: #e2e8f0;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #5158e0;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --alert: #f97316;
  --local: #06b6d4;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }

/* Navbar */
.navbar { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 52px; position: sticky; top: 0; z-index: 100; }
.navbar-brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 20px; }
.brand-name { font-weight: 700; font-size: 16px; color: var(--text); }
.brand-tag { font-size: 11px; background: var(--accent); color: white; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.navbar-links { display: flex; align-items: center; gap: 20px; }
.navbar-links a { color: var(--text-muted); text-decoration: none; font-size: 13px; }
.navbar-links a:hover, .navbar-links a.active { color: var(--text); }
.logout-link { color: var(--text-muted) !important; }

/* Main */
.main-content { max-width: 1400px; margin: 0 auto; padding: 24px 20px; }

/* Footer */
.footer { text-align: center; padding: 16px; color: var(--text-muted); font-size: 11px; border-top: 1px solid var(--border); margin-top: 40px; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 12px; text-align: center; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-success .stat-value { color: var(--success); }
.stat-error .stat-value { color: var(--error); }
.stat-local .stat-value { color: var(--local); }
.stat-alert .stat-value { color: var(--alert); }

/* Safety banner */
.safety-banner { background: #0c1a0c; border: 1px solid var(--success); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 16px; font-size: 12px; color: var(--success); font-weight: 600; }
.cloud-alert-inline { color: var(--alert); margin-left: 16px; }

/* Filter bar */
.filter-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-input { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 6px 12px; font-size: 13px; min-width: 180px; }
.filter-select { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 6px 10px; font-size: 13px; }
.filter-checkbox { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; }
.filter-input:focus, .filter-select:focus { outline: 2px solid var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; border: none; transition: background 0.15s; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-full { width: 100%; justify-content: center; }

/* Request list */
.request-list { display: flex; flex-direction: column; gap: 8px; }
.trace-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.trace-card-error { border-left: 3px solid var(--error); }
.trace-card-alert { border-left: 3px solid var(--alert); }
.trace-header { padding: 12px 16px; cursor: pointer; }
.trace-header:hover { background: var(--surface2); }
.trace-meta-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.trace-ts { font-size: 11px; color: var(--text-muted); }
.trace-summary-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.trace-request-preview { color: var(--text); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: right; }
.trace-tokens { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.token-info { font-size: 11px; color: var(--text-muted); font-family: monospace; }
.latency-info { font-size: 11px; color: var(--text-muted); }
.routing-reason { font-size: 11px; }

/* Badges */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.badge-channel { background: var(--surface2); color: var(--text-muted); }
.badge-agent { background: #1e293b; color: var(--local); border: 1px solid var(--local); }
.badge-model { background: #1e1e3f; color: var(--accent); border: 1px solid var(--accent); font-family: monospace; font-size: 11px; }
.badge-alert { background: #2d1a00; color: var(--alert); border: 1px solid var(--alert); }
.badge-status { }
.muted { color: var(--text-muted); }

/* Trace body */
.trace-body { border-top: 1px solid var(--border); }
.trace-actions { padding: 8px 16px; border-bottom: 1px solid var(--border); }
.trace-sections { padding: 0; }

/* Section details */
.trace-section { border-bottom: 1px solid var(--border); }
.trace-section:last-child { border-bottom: none; }
.trace-section summary { padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-muted); list-style: none; display: flex; align-items: center; gap: 6px; }
.trace-section summary:hover { background: var(--surface2); color: var(--text); }
.trace-section[open] summary { color: var(--text); background: var(--surface2); }
.trace-section-error summary { color: var(--error); }
.section-content { padding: 12px 16px; font-size: 13px; }
.sensitive-content { background: #1a0a00; border-radius: 6px; padding: 12px; }
.sensitive-warn { color: var(--warning); font-size: 12px; margin-bottom: 8px; }
.sensitive-tag { font-size: 10px; background: var(--warning); color: #000; padding: 1px 6px; border-radius: 4px; margin-left: 8px; font-weight: 700; }

/* RTL text */
.rtl-text { direction: rtl; text-align: right; font-family: var(--font); white-space: pre-wrap; word-break: break-word; }

/* Meta table */
.meta-table { width: 100%; border-collapse: collapse; }
.meta-table th { text-align: left; color: var(--text-muted); font-weight: 500; padding: 4px 12px 4px 0; font-size: 12px; width: 160px; vertical-align: top; }
.meta-table td { padding: 4px 0; word-break: break-all; }
.meta-table code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 11px; }

/* Pre */
pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow-x: auto; font-size: 11px; font-family: monospace; white-space: pre-wrap; word-break: break-word; margin-top: 8px; }

/* Detail page */
.detail-header { margin-bottom: 24px; }
.detail-title { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; }
.detail-trace-id { font-family: monospace; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.detail-ts { font-size: 12px; color: var(--text-muted); }
.detail-summary { display: flex; flex-wrap: wrap; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
.summary-item { display: flex; flex-direction: column; gap: 2px; }
.summary-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.detail-sections { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.provider-local { color: var(--local); font-weight: 600; }
.provider-cloud { color: var(--alert); font-weight: 600; }
.text-alert { color: var(--alert); font-weight: 600; }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 24px; }
.page-info { color: var(--text-muted); font-size: 13px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }

/* Login page */
.login-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--bg); flex-direction: column; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 40px; width: 100%; max-width: 420px; }
.login-header { text-align: center; margin-bottom: 32px; }
.brand-icon-large { font-size: 48px; display: block; margin-bottom: 12px; }
.login-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; }
.login-form { margin-bottom: 0; }
.login-divider { text-align: center; color: var(--text-muted); font-size: 12px; margin: 20px 0; position: relative; }
.login-divider::before, .login-divider::after { content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border); }
.login-divider::before { left: 0; }
.login-divider::after { right: 0; }
.login-hint { color: var(--text-muted); font-size: 11px; text-align: center; margin-top: 16px; }
.login-hint code { background: var(--bg); padding: 1px 4px; border-radius: 3px; font-size: 10px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-group input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 9px 12px; font-size: 14px; }
.form-group input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* Alerts */
.alert { border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #2d0b0b; border: 1px solid var(--error); color: var(--error); }
.alert-info { background: #0c1a2d; border: 1px solid var(--accent); color: var(--accent); }
