/* ============================================================
   LEGACY LIVE — Premium UI Design System
   Aesthetic: Refined Dark Luxury · Calm · Trustworthy · Modern
   Font: DM Sans (body) + DM Serif Display (headings)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=DM+Serif+Display&display=swap');

/* ─── Design Tokens ──────────────────────────────────────────────────────── */

:root {
  --navy-950: #0d1117;
  --navy-900: #131a24;
  --navy-800: #1a2535;
  --navy-700: #213045;
  --navy-600: #2c3e58;
  --navy-500: #3d5166;
  --navy-400: #5a7189;
  --navy-300: #8aa0b4;
  --navy-200: #c2d0dc;
  --navy-100: #e8eef4;
  --navy-50:  #f4f6f9;

  --blue-600: #1a6bc4;
  --blue-500: #2179d9;
  --blue-400: #3a8ef0;
  --blue-300: #6aabf5;
  --blue-100: #ddeeff;
  --blue-50:  #eef6ff;

  --success-700: #166534;
  --success-500: #22c55e;
  --success-100: #dcfce7;
  --danger-700:  #991b1b;
  --danger-500:  #ef4444;
  --danger-100:  #fee2e2;
  --warning-500: #f59e0b;
  --warning-100: #fef3c7;

  --bg:            #eef1f6;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #f1f5f9;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  --shadow-xs: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 6px rgba(15,23,42,0.07), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 24px rgba(15,23,42,0.08), 0 4px 8px rgba(15,23,42,0.04);
  --shadow-xl: 0 20px 40px rgba(15,23,42,0.12), 0 8px 16px rgba(15,23,42,0.06);
  --shadow-glow: 0 0 0 3px rgba(33,121,217,0.18);

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 350ms ease;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */

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

/* ─── Base ───────────────────────────────────────────────────────────────── */

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: 'DM Serif Display', Georgia, serif;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h4, h5, h6 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: var(--blue-500); text-decoration: none; }
a:hover { color: var(--blue-400); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.container { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  text-align: center;
  padding: 28px 20px 22px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: relative;
}

.sidebar h1::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 25%;
  right: 25%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue-400), transparent);
  border-radius: var(--radius-full);
}

.sidebar ul {
  list-style: none;
  padding: 12px;
  margin: 0;
  flex: 1;
}

.sidebar li {
  border-radius: var(--radius-md);
  margin-bottom: 2px;
}

.sidebar a {
  color: var(--navy-300);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: color var(--transition-base), background var(--transition-base);
  letter-spacing: 0.01em;
}

.sidebar a:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.sidebar a i {
  width: 16px;
  text-align: center;
  opacity: 0.65;
  font-size: 0.82rem;
  transition: opacity var(--transition-base);
}

.sidebar a:hover i { opacity: 1; }

.sidebar .bottom {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar .bottom a { color: var(--navy-400); font-size: 0.85rem; }
.sidebar .bottom a:hover { color: var(--danger-500); background: rgba(239,68,68,0.08); }

/* ─── Main Content ───────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
  min-width: 0;
  background: var(--bg);
}

/* ─── Page Header ────────────────────────────────────────────────────────── */

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

.header h2 { font-size: 1.65rem; color: var(--text-primary); }
.header h2 + p { font-size: 0.875rem; color: var(--text-muted); margin-top: 3px; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  transition: box-shadow var(--transition-base);
}

.card:hover { box-shadow: var(--shadow-md); }

.card > h3 {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

button {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  line-height: 1;
}

button:active { transform: translateY(1px) !important; }

button.primary {
  background: var(--blue-500);
  color: #fff;
  box-shadow: 0 1px 2px rgba(33,121,217,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}
button.primary:hover {
  background: var(--blue-600);
  box-shadow: 0 4px 14px rgba(33,121,217,0.4);
  transform: translateY(-1px);
}

button.success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 1px 2px rgba(34,197,94,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}
button.success:hover {
  background: linear-gradient(135deg, #16a34a, #15803d);
  box-shadow: 0 4px 14px rgba(34,197,94,0.35);
  transform: translateY(-1px);
}

button.danger {
  background: var(--danger-500);
  color: #fff;
  box-shadow: 0 1px 2px rgba(239,68,68,0.3);
}
button.danger:hover {
  background: var(--danger-700);
  box-shadow: 0 4px 14px rgba(239,68,68,0.35);
  transform: translateY(-1px);
}

button.secondary {
  background: var(--surface);
  color: var(--blue-500);
  border: 1.5px solid var(--blue-300);
  box-shadow: var(--shadow-xs);
}
button.secondary:hover {
  background: var(--blue-50);
  border-color: var(--blue-500);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 7px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  margin-bottom: 0;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue-400);
  box-shadow: var(--shadow-glow);
}

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

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

textarea { resize: vertical; min-height: 90px; }

.input-with-button { display: flex; gap: 8px; }
.input-with-button input { flex: 1; }

.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group input { width: auto; margin: 0; accent-color: var(--blue-500); }

/* ─── Status Messages ────────────────────────────────────────────────────── */

.status-message {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  display: none;
  margin-top: 12px;
}

.status-success {
  background: var(--success-100);
  color: var(--success-700);
  border: 1px solid #bbf7d0;
  display: block;
}

.status-error {
  background: var(--danger-100);
  color: var(--danger-700);
  border: 1px solid #fecaca;
  display: block;
}

/* ─── Account Info Bar ───────────────────────────────────────────────────── */

.account-info {
  background: linear-gradient(135deg, var(--navy-800), var(--navy-700));
  color: var(--navy-200);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}

.account-info strong { color: #fff; font-weight: 600; }

/* ─── Login Page ─────────────────────────────────────────────────────────── */

body:has(.login-container) {
  background: linear-gradient(145deg, var(--navy-950) 0%, var(--navy-800) 50%, var(--navy-900) 100%);
}

.main-content:has(.login-container) {
  padding: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 52px 44px;
  border-radius: var(--radius-xl);
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(58,142,240,0.8), transparent);
}

.login-container h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 2.1rem;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: -0.03em;
}

.login-container > p {
  font-size: 0.78rem;
  color: var(--navy-300);
  margin-bottom: 36px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.login-container input {
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.09);
  color: #fff;
  margin-bottom: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  text-align: left;
  border-radius: var(--radius-md);
}

.login-container input::placeholder { color: rgba(255,255,255,0.28); }

.login-container input:focus {
  border-color: var(--blue-400);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 0 3px rgba(58,142,240,0.2);
}

.login-container button.primary {
  width: 100%;
  padding: 13px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  box-shadow: 0 4px 24px rgba(33,121,217,0.45);
  margin-top: 8px;
  border-radius: var(--radius-md);
}

.login-container button.primary:hover {
  box-shadow: 0 8px 32px rgba(33,121,217,0.55);
}

.login-container a { color: var(--blue-300); font-size: 0.85rem; }
.login-container a:hover { color: var(--blue-400); }

.remember-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  text-align: left;
  color: var(--navy-300);
  font-size: 0.83rem;
}
.remember-container input { width: auto; margin: 0; accent-color: var(--blue-400); }

.create-account-link {
  margin-top: 20px;
  font-size: 0.83rem;
  color: var(--navy-300);
}

/* ─── Stats Grid ─────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue-500), var(--blue-300));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

.stat-card:hover::after { opacity: 1; }

.stat-card h4 {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 10px;
}

.stat-value {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 2.4rem;
  font-weight: 400;
  color: var(--navy-800);
  line-height: 1;
  letter-spacing: -0.03em;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */

.accounts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.accounts-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}

.accounts-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.accounts-table tbody tr:last-child td { border-bottom: none; }
.accounts-table tbody tr { transition: background var(--transition-fast); }
.accounts-table tbody tr:hover { background: var(--surface-2); }

.action-buttons { display: flex; gap: 8px; }
.action-buttons button { padding: 5px 12px; font-size: 0.76rem; border-radius: var(--radius-sm); }

/* ─── Log Table ──────────────────────────────────────────────────────────── */

.log-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }

.log-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}

.log-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td { background: var(--surface-2); }

.log-success { color: var(--success-500); font-weight: 600; }
.log-error   { color: var(--danger-500);  font-weight: 600; }
.log-warning { color: var(--warning-500); font-weight: 600; }

/* ─── Location Cards ─────────────────────────────────────────────────────── */

.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.location-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.location-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--border);
  transition: background var(--transition-base);
}

.location-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.location-card:hover::before {
  background: linear-gradient(180deg, var(--blue-400), var(--blue-300));
}

.location-card h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  padding: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 600;
}

.location-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.location-card a.primary {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  background: var(--blue-500);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--transition-base);
  letter-spacing: 0.01em;
}

.location-card a.primary:hover {
  background: var(--blue-600);
  box-shadow: 0 4px 12px rgba(33,121,217,0.3);
  transform: translateY(-1px);
}

/* ─── Status Indicators ──────────────────────────────────────────────────── */

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-live {
  background: var(--success-500);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
  animation: pulse-live 2s infinite;
}

.status-idle    { background: var(--warning-500); }
.status-offline { background: var(--danger-500); }

@keyframes pulse-live {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34,197,94,0.2); }
  50%       { box-shadow: 0 0 0 6px rgba(34,197,94,0.0); }
}

/* ─── Stream Hub ─────────────────────────────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 300px);
  gap: 16px;
}

.quadrant {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  overflow: auto;
}

.quadrant h3 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.camera-preview {
  background: var(--navy-950);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--navy-400);
  height: 100%;
  width: 100%;
  font-size: 0.85rem;
}

.camera-preview video { width: 100%; height: 100%; object-fit: contain; }

#start-stream {
  background: linear-gradient(135deg, #22c55e, #16a34a) !important;
  box-shadow: 0 4px 18px rgba(34,197,94,0.3) !important;
  font-weight: 700;
  letter-spacing: 0.03em;
}

#stop-stream {
  background: linear-gradient(135deg, var(--danger-500), var(--danger-700)) !important;
  font-weight: 700;
}

/* ─── Modals ─────────────────────────────────────────────────────────────── */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  padding: 32px;
  width: 520px;
  max-width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-slide-up 220ms cubic-bezier(0.34,1.3,0.64,1);
  position: relative;
}

@keyframes modal-slide-up {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

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

.modal-header h3 { font-size: 1.1rem; color: var(--text-primary); }

.close-modal {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0;
  position: static;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.close-modal:hover {
  background: var(--danger-100);
  border-color: var(--danger-500);
  color: var(--danger-500);
}

/* ─── Gallery ────────────────────────────────────────────────────────────── */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.gallery-item {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.gallery-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.gallery-item img { width: 100%; height: 175px; object-fit: cover; }

.gallery-item-content { padding: 16px; }
.gallery-item-content h4 { font-size: 0.95rem; color: var(--text-primary); margin-bottom: 4px; }
.gallery-item-content p  { font-size: 0.8rem; color: var(--text-muted); }

/* ─── Settings ───────────────────────────────────────────────────────────── */

.settings-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.settings-tab {
  padding: 11px 20px;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-base);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.settings-tab i { margin-right: 7px; font-size: 0.78rem; }
.settings-tab:hover { color: var(--text-secondary); }
.settings-tab.active { border-bottom-color: var(--blue-500); color: var(--blue-500); }

.settings-content { display: none; }
.settings-content.active {
  display: block;
  animation: fade-up 180ms ease;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.settings-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.settings-section h4 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 700;
  font-family: 'DM Sans', system-ui, sans-serif;
}

.setting-description { font-size: 0.77rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Toggle Switch ──────────────────────────────────────────────────────── */

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 24px;
}

.toggle-row:last-of-type { border-bottom: none; }

.toggle-row > div > label,
.toggle-row > label:first-child {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; margin: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  transition: background var(--transition-base);
}

.toggle-slider::before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-base);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--blue-500); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ─── Role & Status Badges ───────────────────────────────────────────────── */

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.role-corporate   { background: var(--blue-50);    color: var(--blue-600);    border: 1px solid var(--blue-100); }
.role-independent { background: var(--success-100); color: var(--success-700); border: 1px solid #bbf7d0; }
.role-admin       { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.role-user        { background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-active   { background: var(--success-100); color: var(--success-700); border: 1px solid #bbf7d0; }
.status-inactive { background: var(--danger-100);  color: var(--danger-700);  border: 1px solid #fecaca; }

/* ─── Detail Grid ────────────────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 20px;
}

.detail-item { display: flex; flex-direction: column; gap: 4px; }

.detail-label {
  font-size: 0.67rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
}

.detail-value { font-size: 0.93rem; color: var(--text-primary); font-weight: 500; }

/* ─── Location Tag ───────────────────────────────────────────────────────── */

.location-tag {
  display: inline-block;
  background: var(--blue-50);
  color: var(--blue-600);
  border: 1px solid var(--blue-100);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-right: 3px;
}

/* ─── Location Assignment Row ────────────────────────────────────────────── */

.location-assignment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  background: var(--surface-2);
  transition: all var(--transition-fast);
}

.location-assignment-row:hover { border-color: var(--border-strong); background: var(--surface); }
.location-assignment-row button { padding: 4px 12px; font-size: 0.74rem; border-radius: var(--radius-sm); }

/* ─── Loading ────────────────────────────────────────────────────────────── */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid var(--border);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  margin-bottom: 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Search ─────────────────────────────────────────────────────────────── */

.search-container { position: relative; margin-bottom: 20px; }

/* ─── Notification Bell ──────────────────────────────────────────────────── */

.notification-bell {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 999;
  color: var(--text-muted);
  font-size: 0.87rem;
  transition: all var(--transition-base);
}

.notification-bell:hover {
  border-color: var(--blue-300);
  color: var(--blue-500);
  box-shadow: var(--shadow-lg);
}

/* ─── Settings Button ────────────────────────────────────────────────────── */

.settings-button {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.87rem;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
}

.settings-button:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--blue-500);
}

/* ─── Device Select ──────────────────────────────────────────────────────── */

.device-select-btn {
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
  padding: 11px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition-base);
}

.device-select-btn:hover {
  border-color: var(--blue-400);
  background: var(--blue-50);
  color: var(--blue-600);
}

/* ─── Agora Video ────────────────────────────────────────────────────────── */

.agora-video-player {
  width: 100%;
  height: 100%;
  background: var(--navy-950);
  border-radius: var(--radius-md);
}

/* ─── Modal Body Links ───────────────────────────────────────────────────── */

.modal-body-links a {
  display: block;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition-base);
}

.modal-body-links a:hover {
  background: var(--blue-50);
  border-color: var(--blue-300);
  color: var(--blue-600);
}

/* ─── SPA View Panels ────────────────────────────────────────────────────── */

.view { display: none; flex-direction: column; width: 100%; }
.view.active { display: flex; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .main-content { padding: 24px 28px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .container { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 12px;
    gap: 12px;
  }

  .sidebar h1 { font-size: 1rem; padding: 0; border: none; white-space: nowrap; }
  .sidebar h1::after { display: none; }

  .sidebar ul {
    display: flex;
    flex: 1;
    padding: 0;
    gap: 2px;
    overflow-x: auto;
  }

  .sidebar li { margin: 0; }

  .sidebar a {
    padding: 8px 12px;
    font-size: 0.78rem;
    flex-direction: column;
    gap: 2px;
    text-align: center;
  }

  .sidebar a i { width: auto; margin: 0; }
  .sidebar .bottom { padding: 0; border: none; margin: 0; }

  .main-content { padding: 16px; }

  .dashboard-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .locations-grid { grid-template-columns: 1fr; }
  .action-buttons { flex-wrap: wrap; }
  .settings-tab i { display: none; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .login-container { padding: 36px 24px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-content { padding: 20px; }
}

/* ─── Mobile Stream Hub Fixes ────────────────────────────────────────────── */

@media (max-width: 768px) {
    /* Stream hub grid stacks vertically */
    .stream-hub-grid,
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
    }

    /* Stream control buttons full width */
    .stream-controls-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }

    /* Header inner button group wraps on mobile */
    .header > div {
        flex-wrap: wrap;
        gap: 8px;
    }

    .header > div > button,
    .header > div > a {
        font-size: 0.78rem;
        padding: 7px 10px;
    }

    /* Bookings table horizontal scroll */
    .card { overflow-x: auto; }

    .accounts-table {
        min-width: 500px;
    }

    /* Main content padding on mobile */
    .main-content {
        padding: 12px;
    }

    /* Header stacks on mobile */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header button,
    .header a {
        width: 100%;
        justify-content: center;
    }

    /* Stats grid 2 col on mobile */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }

    .stat-value { font-size: 1.8rem; }

    /* Modal full width on mobile */
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0;
        border-radius: 16px 16px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 90vh;
    }

    .modal {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    /* Booking form grid stacks */
    #addBookingModal .modal-content div[style*="grid-template-columns:1fr 1fr"] {
        display: block !important;
    }

    #addBookingModal .modal-content div[style*="grid-template-columns:1fr 1fr"] > div {
        margin-bottom: 12px;
    }

    /* Locations grid 1 col */
    .locations-grid {
        grid-template-columns: 1fr !important;
    }

    /* Settings tabs scroll horizontally */
    .settings-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Account info bar smaller */
    .account-info {
        font-size: 0.75rem;
        padding: 8px 12px;
    }

    /* Notification bell doesn't overlap on mobile */
    .notification-bell {
        display: none;
    }

    /* Stream hub quadrant height */
    .quadrant {
        min-height: 200px;
    }
}

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

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons button,
    .action-buttons a {
        width: 100%;
        justify-content: center;
    }

    .sidebar a span { display: none; }
}

/* ─── Showreel Library ───────────────────────────────────────────────────── */

.showreel-library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  gap: 12px;
}

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

.showreel-library-item:hover {
  background: var(--surface-2);
}

/* ─── Transition Picker ──────────────────────────────────────────────────── */

.transition-option {
  user-select: none;
}

.transition-option:hover {
  border-color: var(--blue-300) !important;
  background: var(--blue-50) !important;
}

.transition-option.selected {
  border-color: var(--blue-500) !important;
  background: var(--blue-50) !important;
}

/* ─── AI Chat Bubbles ────────────────────────────────────────────────────── */

.chat-messages {
  padding: 4px 0;
}

.chat-bubble {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.45;
  word-wrap: break-word;
  animation: bubble-in 0.18s ease;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* AI message — white bubble, left aligned */
.chat-bubble.ai {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: var(--shadow-xs);
}

/* User message — blue bubble, right aligned */
.chat-bubble.user {
  background: var(--blue-500);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  margin-left: auto;
}

/* Typing indicator */
.chat-bubble.typing {
  background: #ffffff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  padding: 12px 16px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ─── Location Picker Modal ──────────────────────────────────────────────── */

.location-picker-account {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.location-picker-account:hover {
  box-shadow: var(--shadow-sm);
}

.location-picker-account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  user-select: none;
  transition: background var(--transition-fast);
}

.location-picker-account-header:hover {
  background: var(--surface-3);
}

.location-picker-locations {
  background: var(--surface);
}

.location-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px 11px 40px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
  gap: 10px;
}

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

.location-picker-item:hover {
  background: var(--blue-50);
}

.location-picker-item:hover .fa-arrow-right {
  color: var(--blue-500) !important;
  transform: translateX(3px);
  transition: all var(--transition-fast);
}
