/* BlackMirror Ops Centre — Shared Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg:           #0a0a0f;
  --bg-card:      #111827;
  --bg-sidebar:   #0d1117;
  --border:       #1f2937;
  --border-light: #374151;
  --accent:       #6366f1;
  --accent-hover: #818cf8;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --critical:     #dc2626;
  --text:         #f9fafb;
  --text-muted:   #9ca3af;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg:    0 10px 25px rgba(0,0,0,.5);
  --transition:   .2s ease;
  --sidebar-w:    56px;
  --sidebar-w-exp:200px;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ──────────────────────────────────────
   Scrollbar
   ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }
html { scrollbar-width: thin; scrollbar-color: #374151 transparent; }

/* ──────────────────────────────────────
   Animations
   ────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes glow {
  0%, 100% { box-shadow: 0 0 4px currentColor; }
  50%      { box-shadow: 0 0 12px currentColor; }
}

@keyframes criticalPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); }
  50%      { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

.fade-in { animation: fadeIn .4s ease both; }

.glow {
  animation: glow 2s ease-in-out infinite;
}

/* ──────────────────────────────────────
   Login Page
   ────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0a0f 0%, #1a1033 50%, #0a0a0f 100%);
  padding: 1rem;
}

.login-page .login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  animation: fadeIn .5s ease both;
}

.login-page .login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .25rem;
  text-align: center;
}

.login-page .login-card p {
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.75rem;
  font-size: .9rem;
}

.login-page .login-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  font-size: .85rem;
  margin-bottom: 1rem;
  display: none;
}

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

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: .75rem 0;
  z-index: 100;
  transition: width .25s ease;
  overflow: hidden;
}

.sidebar.expanded {
  width: var(--sidebar-w-exp);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 1rem;
  margin-bottom: .75rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo svg { flex-shrink: 0; }

.sidebar-label {
  opacity: 0;
  transition: opacity .2s ease;
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
}

.sidebar.expanded .sidebar-label {
  opacity: 1;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255,255,255,.05);
  color: var(--text);
}

.sidebar-item.active {
  color: var(--accent);
  background: rgba(99,102,241,.08);
  border-left-color: var(--accent);
}

.sidebar-item svg { flex-shrink: 0; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 1.75rem 2rem;
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
  transition: margin-left .25s ease;
}

/* ──────────────────────────────────────
   Page Header
   ────────────────────────────────────── */
.page-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 1.75rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.page-header p {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: .25rem;
}

/* ──────────────────────────────────────
   Status Cards
   ────────────────────────────────────── */
.status-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.status-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-lg);
}

.status-card .card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(99,102,241,.12);
  color: var(--accent);
}

.status-card .card-body {
  flex: 1;
  min-width: 0;
}

.status-card .card-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 500;
}

.status-card .card-value {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Status indicator dots */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-ok {
  background: var(--success);
  box-shadow: 0 0 6px rgba(16,185,129,.5);
}

.status-warn {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(245,158,11,.5);
}

.status-critical {
  background: var(--critical);
  box-shadow: 0 0 6px rgba(220,38,38,.5);
  animation: pulse 1.5s ease-in-out infinite;
}

/* ──────────────────────────────────────
   Risk Badges
   ────────────────────────────────────── */
.risk-badge {
  display: inline-flex;
  align-items: center;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .2rem .55rem;
  border-radius: 9999px;
  line-height: 1.4;
}

.risk-badge.critical {
  background: rgba(220,38,38,.2);
  color: #fca5a5;
  animation: criticalPulse 2s ease-in-out infinite;
}

.risk-badge.high {
  background: rgba(249,115,22,.18);
  color: #fdba74;
}

.risk-badge.medium {
  background: rgba(245,158,11,.16);
  color: #fcd34d;
}

.risk-badge.low {
  background: rgba(16,185,129,.15);
  color: #6ee7b7;
}

/* ──────────────────────────────────────
   Data Table
   ────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.data-table thead th {
  text-align: left;
  padding: .7rem 1rem;
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
}

.data-table tbody td {
  padding: .65rem 1rem;
  border-bottom: 1px solid rgba(31,41,55,.5);
  vertical-align: middle;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(17,24,39,.5);
}

.data-table tbody tr:hover {
  background: rgba(99,102,241,.06);
}

/* ──────────────────────────────────────
   Flow Diagram
   ────────────────────────────────────── */
.flow-diagram {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  padding: 1rem 0;
}

.flow-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1.1rem;
  border-left: 4px solid var(--accent);
  position: relative;
  transition: transform var(--transition), box-shadow var(--transition);
  min-width: 160px;
}

.flow-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.flow-box.success { border-left-color: var(--success); }
.flow-box.warning { border-left-color: var(--warning); }
.flow-box.danger  { border-left-color: var(--danger); }

.flow-box .flow-title {
  font-weight: 600;
  font-size: .85rem;
  margin-bottom: .25rem;
}

.flow-box .flow-desc {
  font-size: .75rem;
  color: var(--text-muted);
}

.flow-arrow {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: .85rem;
  position: relative;
  padding: 0 .25rem;
  align-self: center;
}

.flow-arrow::after {
  content: '';
  display: inline-block;
  width: 32px;
  height: 2px;
  background: var(--border-light);
  position: relative;
}

.flow-arrow::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--border-light);
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* ──────────────────────────────────────
   Sections (Collapsible)
   ────────────────────────────────────── */
.section {
  margin-bottom: 1.75rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.05rem;
  font-weight: 600;
  padding: .6rem 0;
  cursor: default;
  user-select: none;
}

.section-header[data-collapsible] {
  cursor: pointer;
}

.section-header[data-collapsible]::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.section-header[data-collapsible].collapsed::before {
  transform: rotate(-90deg);
}

.section-content {
  overflow: hidden;
  max-height: 5000px;
  transition: max-height .35s ease, opacity .25s ease;
  opacity: 1;
}

.section-content.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ──────────────────────────────────────
   Tree View (Codebase)
   ────────────────────────────────────── */
.tree-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .6rem;
  padding-left: calc(.6rem + var(--indent, 0) * 1.25rem);
  font-size: .85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text);
}

.tree-item:hover {
  background: rgba(255,255,255,.04);
}

.tree-item .tree-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.tree-toggle {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
  cursor: pointer;
}

.tree-toggle.open {
  transform: rotate(90deg);
}

/* ──────────────────────────────────────
   Metric Grid
   ────────────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.metric-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* ──────────────────────────────────────
   Pills / Tags
   ────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .7rem;
  font-weight: 500;
  padding: .15rem .5rem;
  border-radius: 9999px;
  background: rgba(99,102,241,.14);
  color: var(--accent-hover);
}

.pill.green  { background: rgba(16,185,129,.14); color: #6ee7b7; }
.pill.amber  { background: rgba(245,158,11,.14); color: #fcd34d; }
.pill.red    { background: rgba(239,68,68,.14);  color: #fca5a5; }
.pill.gray   { background: rgba(156,163,175,.14);color: #d1d5db; }

/* ──────────────────────────────────────
   Buttons
   ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.15rem;
  font-size: .85rem;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.btn:hover {
  background: #1f2937;
  border-color: var(--border-light);
}

.btn:active {
  transform: scale(.98);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 12px rgba(99,102,241,.3);
}

.btn-danger {
  background: rgba(239,68,68,.15);
  border-color: rgba(239,68,68,.3);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239,68,68,.25);
  border-color: rgba(239,68,68,.5);
}

/* ──────────────────────────────────────
   Inputs / Forms
   ────────────────────────────────────── */
.input {
  width: 100%;
  padding: .6rem .85rem;
  font-size: .9rem;
  font-family: var(--font);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input::placeholder {
  color: #6b7280;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: 1rem;
}

.input-group label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ──────────────────────────────────────
   Responsive
   ────────────────────────────────────── */
@media (max-width: 1024px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .metric-grid,
  .metric-grid.cols-3,
  .metric-grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
  }

  .sidebar {
    display: none;
  }

  .flow-diagram {
    flex-direction: column;
    align-items: stretch;
  }

  .flow-arrow {
    transform: rotate(90deg);
    align-self: center;
  }
}

/* ══════════════════════════════════════
   HELPER MODE — Floating Toggle + Cards
   ══════════════════════════════════════ */

.helper-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0;
}
.helper-fab:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  transform: scale(1.08);
}
.helper-fab.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  color: #60a5fa;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}
.helper-fab svg {
  width: 24px;
  height: 24px;
}

.helper-card {
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 0 16px 0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: helperSlideIn 0.35s ease-out both;
}
.helper-card-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
}
.helper-card-icon svg {
  width: 18px;
  height: 18px;
}
.helper-card-body {
  flex: 1;
  min-width: 0;
}
.helper-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #60a5fa;
  margin: 0 0 4px;
}
.helper-card-text {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.5;
  margin: 0 0 6px;
}
.helper-card-look {
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  padding-top: 6px;
  border-top: 1px solid rgba(59, 130, 246, 0.1);
}
.helper-card-look strong {
  color: #60a5fa;
}

@keyframes helperSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
