/* ═══════════════════════════════════════════════════════════
   StreamPortal 2.0 - Master Theme
   Dark theme with neon accents
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS Variables ─────────────────────────────────────── */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2234;
  --bg-card-hover: #1f2a40;
  --bg-input: #0d1321;
  --border-color: #2a3548;
  --border-focus: #3b82f6;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --neon-blue: #3b82f6;
  --neon-cyan: #06b6d4;
  --neon-green: #10b981;
  --neon-orange: #f59e0b;
  --neon-red: #ef4444;
  --neon-purple: #8b5cf6;
  --neon-glow-blue: 0 0 12px rgba(59, 130, 246, 0.4);
  --neon-glow-green: 0 0 12px rgba(16, 185, 129, 0.4);
  --neon-glow-red: 0 0 12px rgba(239, 68, 68, 0.4);
  --sidebar-width: 240px;
  --header-height: 60px;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--neon-blue);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--neon-cyan);
}

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: var(--header-height);
  min-height: 100vh;
}

.content-wrapper {
  padding: 24px;
  max-width: 1400px;
}

/* ─── Header ────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--neon-cyan);
  letter-spacing: 0.5px;
}

.brand-version {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 8px;
  padding: 2px 6px;
  background: var(--bg-card);
  border-radius: 4px;
}

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

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--neon-blue);
  border-left: 3px solid var(--neon-blue);
}

.nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition);
}

.card:hover {
  border-color: rgba(59, 130, 246, 0.3);
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: rgba(59, 130, 246, 0.15);
  color: var(--neon-blue);
}
.stat-icon.green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--neon-green);
}
.stat-icon.orange {
  background: rgba(245, 158, 11, 0.15);
  color: var(--neon-orange);
}
.stat-icon.purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--neon-purple);
}
.stat-icon.red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--neon-red);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Node Badge Cards ──────────────────────────────────── */
.nodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.node-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.node-badge:hover {
  border-color: var(--neon-blue);
  box-shadow: var(--neon-glow-blue);
  transform: translateY(-2px);
}

.node-badge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.node-name {
  font-size: 16px;
  font-weight: 600;
}

.node-hostname {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.node-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.node-stat {
  font-size: 12px;
  color: var(--text-secondary);
}

.node-stat-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Status Indicators ─────────────────────────────────── */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--neon-green);
  box-shadow: var(--neon-glow-green);
}

.status-dot.offline {
  background: var(--text-muted);
}

.status-dot.degraded {
  background: var(--neon-orange);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--neon-green);
}

.status-badge.offline {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.status-badge.live {
  background: rgba(239, 68, 68, 0.15);
  color: var(--neon-red);
}

.status-badge.upcoming {
  background: rgba(59, 130, 246, 0.15);
  color: var(--neon-blue);
}

.status-badge.completed {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

/* --- Progress / Gauge ---------------------------------------- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

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

.progress-fill.green { background: var(--neon-green); }
.progress-fill.orange { background: var(--neon-orange); }
.progress-fill.red { background: var(--neon-red); }

/* ─── Tables ────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(42, 53, 72, 0.5);
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--neon-blue);
  color: white;
}
.btn-primary:hover {
  background: #2563eb;
  box-shadow: var(--neon-glow-blue);
  color: white;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--neon-red);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: var(--neon-red);
  color: white;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

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

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-help-text {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* ─── Flash Messages ────────────────────────────────────── */
.flash-message {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flash-message.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--neon-red);
}

.flash-message.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--neon-green);
}

.flash-message.info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--neon-blue);
}

/* ─── Auth Pages ────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.auth-card-wide {
  max-width: 520px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}

.auth-brand-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--neon-cyan);
}

.auth-brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.auth-description {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.5;
}

.auth-submit-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
}

.auth-footer-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.auth-back-link {
  font-size: 12px;
  color: var(--text-muted);
}

.auth-back-link:hover {
  color: var(--neon-cyan);
}

.auth-resend-form {
  display: inline;
}

.auth-link-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

/* ─── Auth: Form Extras ─────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-help {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-help-error {
  color: var(--neon-orange);
}

.input-error {
  border-color: var(--neon-red);
}

/* ─── Auth: MFA Method Cards ────────────────────────────── */
.mfa-method-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mfa-method-option {
  cursor: pointer;
}

.mfa-method-option input[type="radio"] {
  display: none;
}

.mfa-method-card {
  padding: 16px;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  text-align: center;
  transition: all var(--transition);
}

.mfa-method-option input:checked + .mfa-method-card {
  border-color: var(--neon-blue);
  background: rgba(59, 130, 246, 0.08);
}

.mfa-method-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.mfa-method-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Auth: TOTP Setup ──────────────────────────────────── */
.totp-qr-container {
  text-align: center;
  padding: 20px;
  margin-bottom: 16px;
}

.totp-qr-image {
  width: 200px;
  height: 200px;
  border-radius: var(--radius);
  background: white;
  padding: 8px;
}

.totp-manual-entry {
  text-align: center;
  margin-bottom: 24px;
}

.totp-secret-code {
  display: inline-block;
  padding: 8px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  color: var(--neon-cyan);
  letter-spacing: 2px;
  user-select: all;
  margin-top: 8px;
}

/* ─── Auth: Alert inline ────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--neon-red);
}

/* ─── Activity Feed ─────────────────────────────────────── */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(42, 53, 72, 0.5);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-blue);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Section Headers ───────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Content Grid ──────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

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

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

.empty-state-text {
  font-size: 14px;
}

/* ─── Responsive: see responsive.css ─────────────────────── */
