/* === sec-check-bot-rs — Design System === */

:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #e5e7eb;
  --sidebar-active: #2563eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --sidebar-bg: #0c0c1d;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

/* === Layout === */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  font-size: 1.5rem;
  font-weight: 800;
  padding: 0 1.5rem;
  letter-spacing: -0.5px;
}

.sidebar__app-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.25rem 1.5rem 1rem;
  opacity: 0.6;
}

.sidebar__section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 1rem 1.5rem 0.5rem;
  opacity: 0.4;
}

.sidebar__nav { list-style: none; }

.sidebar__link {
  display: block;
  padding: 0.5rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.sidebar__link:hover { background: rgba(255,255,255,.08); }
.sidebar__link.is-active { background: var(--sidebar-active); color: #fff; font-weight: 600; }

.sidebar__spacer { flex: 1; }

.sidebar__user {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar__user-name { font-size: 0.85rem; font-weight: 600; }
.sidebar__user-role { font-size: 0.7rem; opacity: 0.6; text-transform: capitalize; }

.sidebar__footer {
  padding: 0.5rem 1.5rem;
}

.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
}

/* === Components === */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.75rem; font-weight: 700; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h2 { margin: 0; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* === Table === */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }
.table-sm th, .table-sm td { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
.table a { color: var(--primary); text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }
.input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font);
}
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.input-sm { padding: 0.35rem 0.5rem; font-size: 0.8rem; width: auto; }
textarea.input { resize: vertical; }
.monospace { font-family: var(--mono); font-size: 0.8rem; }
select.input { cursor: pointer; }

.form-inline { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  font-family: var(--font);
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.btn-full { width: 100%; justify-content: center; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--border);
  color: var(--text);
}

.badge-success, .badge.status-completed, .badge.decision-approved { background: #d1fae5; color: #065f46; }
.badge.status-queued { background: #dbeafe; color: #1e40af; }
.badge.status-in-progress { background: #fef3c7; color: #92400e; }
.badge.status-failed, .badge.decision-rejected { background: #fee2e2; color: #991b1b; }
.badge.status-cancelled { background: #f3f4f6; color: #6b7280; }
.badge.decision-needs-further-review { background: #fef3c7; color: #92400e; }
.badge-type { background: #ede9fe; color: #5b21b6; }
.badge-sm { font-size: 0.65rem; padding: 0.1rem 0.4rem; }

/* === Alerts === */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* === Detail grid === */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.75rem; }
.detail-item { display: flex; flex-direction: column; gap: 0.15rem; }
.detail-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }

/* === Decision === */
.decision-display { display: flex; align-items: center; gap: 0.75rem; }
.decision-reason { margin-top: 0.5rem; padding: 0.75rem; background: var(--bg); border-radius: var(--radius); font-style: italic; }

/* === Prose (markdown reports) === */
.prose { line-height: 1.7; }
.prose h1, .prose h2, .prose h3 { margin-top: 1.5rem; margin-bottom: 0.75rem; }
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.prose h3 { font-size: 1.1rem; }
.prose p { margin-bottom: 0.75rem; }
.prose ul, .prose ol { margin-bottom: 0.75rem; padding-left: 1.5rem; }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.prose table th, .prose table td { padding: 0.5rem; border: 1px solid var(--border); text-align: left; }
.prose table th { background: var(--bg); font-weight: 600; }
.prose code { background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 3px; font-family: var(--mono); font-size: 0.85em; }
.prose pre { background: var(--bg); padding: 1rem; border-radius: var(--radius); overflow-x: auto; margin-bottom: 1rem; }
.prose pre code { background: none; padding: 0; }

.code-block {
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* === Pagination === */
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; justify-content: center; }

/* === Misc === */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-error { color: var(--danger); }

.theme-toggle {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.6;
}
.theme-toggle:hover { opacity: 1; }

.actions { white-space: nowrap; }

/* === Login === */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--sidebar-bg);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.2);
}

.login-title { font-size: 2rem; font-weight: 800; text-align: center; margin-bottom: 0.25rem; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 1rem; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; }
  .filter-bar .input { width: 100%; }
}
