/* FireScrape Dashboard — Light Professional Design System */

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

/* ─── Variables ─── */
:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --border: #e9ecef;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
  --trust-1: #16a34a;
  --trust-2: #2563eb;
  --trust-3: #d97706;
  --trust-4: #dc2626;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;
  --sidebar-active-text: #ffffff;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --font-heading: 'Barlow Condensed', sans-serif;
  --font-body: 'Barlow', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --sidebar-w: 240px;
  --transition: 150ms ease;
}

/* ─── Reset ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-body); color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ─── Typography ─── */
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 600; color: var(--text); }
h1 { font-size: 1.8rem; letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
.mono { font-family: var(--font-mono); font-size: 0.85rem; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }

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

.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand h1 {
  font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700;
  color: #fff; letter-spacing: 0.02em; margin: 0;
}
.sidebar-brand p { font-size: 0.75rem; color: var(--sidebar-text); margin-top: 2px; opacity: .7; }

.sidebar-nav { flex: 1; padding: .75rem 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1.25rem; color: var(--sidebar-text);
  font-size: .9rem; font-weight: 500; text-decoration: none;
  border-left: 3px solid transparent; transition: all var(--transition);
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-nav a.active {
  background: rgba(37,99,235,.12); color: var(--sidebar-active-text);
  border-left-color: var(--sidebar-active);
}
.sidebar-nav a .icon { width: 18px; text-align: center; font-size: 1rem; }

.main { margin-left: var(--sidebar-w); flex: 1; padding: 1.75rem 2rem 3rem; min-width: 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; }
.page-header h2 { margin: 0; }

/* ─── Cards ─── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.metric-card { text-align: center; padding: 1.5rem 1rem; }
.metric-card .metric-value { font-family: var(--font-heading); font-size: 2.2rem; font-weight: 700; color: var(--text); }
.metric-card .metric-label { font-size: .85rem; color: var(--text-secondary); margin-top: .25rem; }
.metric-card .metric-sub { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; font-size: .9rem; }
th { font-family: var(--font-heading); font-weight: 600; text-transform: uppercase; font-size: .75rem; letter-spacing: .04em; color: var(--text-secondary); text-align: left; padding: .65rem .75rem; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }
td.mono { font-family: var(--font-mono); font-size: .8rem; color: var(--text-secondary); }
.table-empty { padding: 3rem 1rem; text-align: center; color: var(--text-muted); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 500; font-size: .875rem; cursor: pointer;
  transition: all var(--transition); white-space: nowrap; line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-icon { padding: .4rem; }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .55rem; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.badge-trust-1 { background: #dcfce7; color: var(--trust-1); }
.badge-trust-2 { background: #dbeafe; color: var(--trust-2); }
.badge-trust-3 { background: #fef3c7; color: var(--trust-3); }
.badge-trust-4 { background: #fee2e2; color: var(--trust-4); }
.badge-status-queued { background: var(--surface-2); color: var(--text-secondary); }
.badge-status-running { background: #dbeafe; color: var(--primary); }
.badge-status-completed { background: #dcfce7; color: var(--success); }
.badge-status-failed { background: #fee2e2; color: var(--error); }
.badge-status-pending { background: #fef3c7; color: var(--warning); }
.badge-status-approved { background: #dcfce7; color: var(--success); }
.badge-status-rejected { background: #fee2e2; color: var(--error); }
.badge-lang { background: var(--surface-2); color: var(--text-secondary); }

/* ─── Status Dot ─── */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot-green { background: var(--success); }
.status-dot-yellow { background: var(--warning); }
.status-dot-red { background: var(--error); }
.status-dot-blue { background: var(--primary); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.status-dot-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* ─── Forms ─── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: .3rem; }
.form-control {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-size: .9rem; transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ─── Filter Bar ─── */
.filter-bar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filter-bar .form-control { width: auto; min-width: 150px; padding: .4rem .65rem; font-size: .85rem; }
.filter-bar .btn { font-size: .85rem; }

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px); z-index: 500; display: flex;
  align-items: center; justify-content: center; padding: 1.5rem;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-md); width: 100%; max-width: 560px;
  max-height: 85vh; overflow-y: auto; padding: 0;
}
.modal-lg { max-width: 720px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }

/* ─── Toast ─── */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 600; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: .75rem 1rem; min-width: 280px; max-width: 400px;
  font-size: .875rem; display: flex; align-items: center; gap: .65rem;
  animation: toast-in .25s ease;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-warning { border-left: 3px solid var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: none; } }

/* ─── Progress Bar ─── */
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; }
.progress-bar { height: 100%; border-radius: 99px; transition: width .3s ease; }
.progress-red { background: var(--error); }
.progress-yellow { background: var(--warning); }
.progress-green { background: var(--success); }

/* ─── Loading Skeleton ─── */
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm); height: 1rem; margin-bottom: .5rem;
}
.skeleton-row { display: flex; gap: .75rem; margin-bottom: .75rem; }
.skeleton-row .skeleton { flex: 1; }

/* ─── Empty State ─── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }
.empty-state p { font-size: .95rem; }

/* ─── Checkbox ─── */
.checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ─── Pagination ─── */
.pagination { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; justify-content: center; }
.pagination .btn { min-width: 32px; justify-content: center; }
.pagination .page-info { font-size: .85rem; color: var(--text-secondary); }

/* ─── Utility ─── */
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 250px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-sm { gap: .35rem; }
.gap-md { gap: .75rem; }
.ml-auto { margin-left: auto; }
.mb-1 { margin-bottom: .75rem; }
.mt-1 { margin-top: .75rem; }

/* ─── Section visibility ─── */
.section { display: none; }
.section.active { display: block; }

/* ─── API Key Prompt ─── */
.api-key-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  backdrop-filter: blur(8px); z-index: 700;
  display: flex; align-items: center; justify-content: center;
}
.api-key-box {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 2rem; width: 100%; max-width: 400px; text-align: center;
}
.api-key-box h2 { margin-bottom: .5rem; }
.api-key-box p { color: var(--text-secondary); margin-bottom: 1.25rem; font-size: .9rem; }
.api-key-box .form-control { margin-bottom: 1rem; }
