/* ═══════════════════════════════════════════════════
   API Admin v2 — Portal Styles
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #f0f2f5; --bg-card: #fff; --bg-sidebar: #1e293b;
  --text: #1e293b; --text-muted: #64748b; --text-light: #94a3b8;
  --primary: #3b82f6; --primary-hover: #2563eb; --primary-light: #eff6ff;
  --success: #10b981; --warning: #f59e0b; --danger: #ef4444;
  --border: #e2e8f0; --shadow: 0 1px 3px rgba(0,0,0,.08);
  --radius: 8px; --transition: .2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); font-size: .9rem; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── Layout ────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--bg-sidebar); color: #fff; padding: 1.5rem 0; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 100; }
.sidebar-brand { padding: 0 1.2rem 1.5rem; font-size: 1.1rem; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); margin-bottom: 1rem; }
.sidebar-brand small { display: block; font-size: .7rem; color: var(--text-light); font-weight: 400; }
.sidebar a { display: flex; align-items: center; gap: .6rem; padding: .55rem 1.2rem; color: #cbd5e1; font-size: .85rem; transition: var(--transition); }
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,.08); color: #fff; }
.sidebar a.active { border-right: 3px solid var(--primary); }
.sidebar .section-title { padding: .4rem 1.2rem; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-light); margin-top: 1rem; }
.sidebar i { width: 18px; text-align: center; }

.main { margin-left: 240px; flex: 1; padding: 1.5rem 2rem; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.topbar h1 { font-size: 1.4rem; font-weight: 600; }
.topbar-actions { display: flex; gap: .5rem; align-items: center; }

/* ── Cards ─────────────────────────────── */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.card-body { padding: 1.2rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-card); border-radius: var(--radius); padding: 1.2rem; border: 1px solid var(--border); }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Tables ────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: .83rem; }
th { background: #f8fafc; text-align: left; padding: .65rem .8rem; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: .55rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f8fafc; }

/* ── Forms ─────────────────────────────── */
.form-group { margin-bottom: .9rem; }
.form-group label { display: block; font-size: .78rem; font-weight: 600; margin-bottom: .3rem; color: var(--text-muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="url"], select, textarea {
  width: 100%; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 6px;
  font-size: .85rem; transition: var(--transition); background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea { resize: vertical; min-height: 80px; font-family: 'Fira Code', monospace; }

/* ── Buttons ───────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: 6px; font-size: .83rem; font-weight: 500; cursor: pointer; border: none; transition: var(--transition); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; color: #1e293b; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: .3rem .6rem; font-size: .75rem; }
.btn-xs { padding: .2rem .4rem; font-size: .7rem; }

/* ── Badges ────────────────────────────── */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 12px; font-size: .7rem; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ── Alerts ────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .85rem; border: 1px solid; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #dc2626; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #16a34a; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #2563eb; }
.alert-warning { background: #fffbeb; border-color: #fed7aa; color: #d97706; }

/* ── Key Display ───────────────────────── */
.key-display { background: #1e293b; color: #4ade80; padding: .8rem 1rem; border-radius: 6px; font-family: 'Fira Code', monospace; font-size: .82rem; word-break: break-all; margin: .5rem 0; position: relative; }
.key-display .copy-btn { position: absolute; top: .4rem; right: .4rem; background: rgba(255,255,255,.15); border: none; color: #fff; padding: .3rem .5rem; border-radius: 4px; cursor: pointer; font-size: .7rem; }

/* ── Notification bell ─────────────────── */
.notif-badge { background: var(--danger); color: #fff; font-size: .6rem; padding: 1px 5px; border-radius: 10px; margin-left: 4px; }

/* ── Modal (simple) ────────────────────── */
.form-inline { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.form-inline .form-group { flex: 1; min-width: 150px; margin-bottom: 0; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .25rem .6rem; }
.checkbox-grid label { display: flex; align-items: center; gap: .35rem; font-weight: 500; color: var(--text); margin: 0; }

/* ── Progress bar ──────────────────────── */
.progress { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width .4s ease; }
.progress-bar.green { background: var(--success); }
.progress-bar.yellow { background: var(--warning); }
.progress-bar.red { background: var(--danger); }

/* Onboarding */
.onboarding-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; }
.onboarding-step { display: flex; align-items: center; gap: .55rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 6px; color: var(--text); background: #fff; }
.onboarding-step:hover { border-color: var(--primary); background: var(--primary-light); }
.onboarding-step.done { border-color: #bbf7d0; background: #f0fdf4; }
.onboarding-step .step-icon { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #f1f5f9; color: var(--primary); flex: 0 0 28px; }
.onboarding-step.done .step-icon { background: #d1fae5; color: #047857; }
.onboarding-step .step-state { margin-left: auto; color: var(--text-muted); }
.onboarding-step.done .step-state { color: var(--success); }

/* ── Auth pages ────────────────────────── */
.auth-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #1e293b 0%, #334155 100%); }
.auth-card { background: #fff; border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.auth-card h2 { text-align: center; margin-bottom: 1.5rem; font-size: 1.3rem; }
.auth-card .logo { text-align: center; margin-bottom: 1.5rem; font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.auth-card .btn { width: 100%; justify-content: center; padding: .65rem; }
.auth-links { text-align: center; margin-top: 1rem; font-size: .82rem; color: var(--text-muted); }
.auth-links a { margin: 0 .3rem; }

/* ── Message page ──────────────────────── */
.message-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--bg); }
.message-card { background: #fff; border-radius: 12px; padding: 3rem; text-align: center; max-width: 480px; box-shadow: var(--shadow); }
.message-card h2 { margin-bottom: 1rem; }
.message-card p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Tools page ────────────────────────── */
.tools-tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tools-tab { padding: .5rem 1rem; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; background: transparent; cursor: pointer; font-size: .83rem; font-weight: 500; color: var(--text-muted); border-radius: 6px 6px 0 0; transition: var(--transition); }
.tools-tab:hover { color: var(--primary); background: var(--primary-light); }
.tools-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }
.tool-pane { display: none; }
.tool-pane.active { display: block; }
.tool-output { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 6px; font-family: 'Fira Code', monospace; font-size: .8rem; white-space: pre-wrap; word-break: break-all; min-height: 60px; max-height: 420px; overflow-y: auto; margin: 0; }
.match-item { background: #f8fafc; border: 1px solid var(--border); border-radius: 4px; padding: .45rem .8rem; margin-bottom: .35rem; font-size: .78rem; }
.match-item .match-text { font-family: 'Fira Code', monospace; color: var(--primary); font-weight: 600; }
.match-item .match-meta { color: var(--text-muted); }

/* ── Responsive ────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Utility ───────────────────────────── */
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); } .text-sm { font-size: .8rem; }
.text-center { text-align: center; } .text-right { text-align: right; }
.d-flex { display: flex; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none; }
.mono { font-family: 'Fira Code', monospace; font-size: .82rem; }
