/* ═══════════════════════════════════════════════════════════════════════════
   Blaze Admin UI — Dark Theme Stylesheet
   Derived from blaze-operations-dashboard.html CSS patterns
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg: #0d1117;
  --card: #161b22;
  --card-hover: #1c2330;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --white: #fff;

  --blue: #58a6ff;
  --green: #3fb950;
  --purple: #bc8cff;
  --yellow: #d29922;
  --red: #f85149;
  --orange: #f0883e;
  --teal: #56d4dd;

  --gauge-bg: #21262d;
  --sidebar-w: 220px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
}

.sidebar-brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

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

.sidebar nav { flex: 1; padding: 12px 0; }

.sidebar nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.sidebar nav button:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.sidebar nav button.active {
  color: var(--white);
  background: rgba(240, 136, 62, 0.08);
  border-right: 2px solid var(--orange);
}

.sidebar nav button .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

/* ── Main Content Area ─────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px 32px;
  min-width: 0;
}

/* ── Page Header ───────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--white);
}

.page-header .filters {
  display: flex;
  gap: 8px;
}

.page-header select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
}

/* ── Stat Cards ────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.stat-card.c-blue::before { background: var(--blue); }
.stat-card.c-green::before { background: var(--green); }
.stat-card.c-orange::before { background: var(--orange); }
.stat-card.c-purple::before { background: var(--purple); }
.stat-card.c-teal::before { background: var(--teal); }
.stat-card.c-red::before { background: var(--red); }
.stat-card.c-yellow::before { background: var(--yellow); }

.stat-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--white);
}

.stat-lbl {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 12px;
}

.card p {
  font-size: 13px;
  color: var(--muted);
}

/* ── Gauge ─────────────────────────────────────────────────────────────── */
.gauge-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.gauge {
  position: relative;
  width: 160px;
  height: 160px;
}

.gauge svg { transform: rotate(-90deg); }

.gauge circle {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
}

.gauge .bg { stroke: var(--gauge-bg); }
.gauge .fill { transition: stroke-dashoffset 0.8s ease; }

.gauge .label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.gauge .label .val {
  font-size: 32px;
  font-weight: 800;
  color: var(--white);
}

.gauge .label .sub {
  font-size: 11px;
  color: var(--muted);
}

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

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

.data-table .amount {
  text-align: right;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-variant-numeric: tabular-nums;
}

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.badge-yellow { background: rgba(210, 153, 34, 0.15); color: var(--yellow); }
.badge-red { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.badge-blue { background: rgba(88, 166, 255, 0.15); color: var(--blue); }
.badge-orange { background: rgba(240, 136, 62, 0.15); color: var(--orange); }
.badge-purple { background: rgba(188, 140, 255, 0.15); color: var(--purple); }
.badge-teal { background: rgba(86, 212, 221, 0.15); color: var(--teal); }

/* ── Alert Cards ───────────────────────────────────────────────────────── */
.alert-card {
  border-left: 3px solid;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: 0 6px 6px 0;
  background: rgba(255, 255, 255, 0.02);
}

.alert-card.sev-critical { border-left-color: var(--red); }
.alert-card.sev-high { border-left-color: var(--orange); }
.alert-card.sev-medium { border-left-color: var(--yellow); }
.alert-card.sev-low { border-left-color: var(--blue); }

.alert-card .alert-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
}

.alert-card .alert-body {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Progress Bar ──────────────────────────────────────────────────────── */
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.progress-label {
  width: 80px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--gauge-bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.progress-val {
  width: 44px;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  flex-shrink: 0;
}

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--orange);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text); }
.btn-danger { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.btn-danger:hover { background: rgba(248, 81, 73, 0.25); }

/* ── View Tabs ─────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Wizard Modal ──────────────────────────────────────────────────────── */
.wizard-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.wizard-overlay.active { display: flex; }

.wizard-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 680px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

.wizard-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wizard-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
}

.wizard-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}

.wizard-close:hover { color: var(--white); }

.wizard-progress {
  display: flex;
  padding: 16px 24px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.wizard-step-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--gauge-bg);
  transition: background 0.3s;
}

.wizard-step-dot.done { background: var(--green); }
.wizard-step-dot.current { background: var(--orange); }

.wizard-body { padding: 24px; }

.wizard-body h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 16px;
}

.wizard-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

/* ── Chart Container ───────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  height: 200px;
  margin-top: 8px;
}

.chart-container svg {
  width: 100%;
  height: 100%;
}

/* ── Inline Code ───────────────────────────────────────────────────────── */
code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--orange);
}

/* ── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--white);
  font-size: 16px;
  margin-bottom: 8px;
}

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

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar nav button span:not(.icon) { display: none; }
  .sidebar-brand h1 { display: none; }
  .sidebar-footer { display: none; }
  .main { margin-left: 60px; padding: 16px; }
  :root { --sidebar-w: 60px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ── Print ─────────────────────────────────────────────────────────────── */
@media print {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .page-header .filters { display: none; }
  .view { display: block !important; }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .view + .view { page-break-before: always; }
}

/* ── Reduced Motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
