:root {
  color-scheme: light dark;
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-strong: #0f172a;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body.admin-body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at top, #eef2ff 0%, #f8fafc 55%, #f1f5f9 100%);
  color: var(--text);
  min-height: 100vh;
}

.auth-gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.admin-loading {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
}

.auth-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-no-access {
  margin-top: 18px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: #991b1b;
}

.auth-no-access-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.btn {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.2);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

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

.btn-ghost {
  background: transparent;
}

.admin-app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: #0f172a;
  color: #e2e8f0;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}

.admin-logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #1e293b;
  font-weight: 700;
}

.admin-brand-text {
  letter-spacing: 0.2px;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: background 120ms ease, color 120ms ease;
}

.admin-nav-item i {
  font-size: 18px;
}

.admin-nav-item.is-active {
  background: #1e293b;
  color: #fff;
}

.admin-main {
  display: flex;
  flex-direction: column;
  padding: 20px 24px 24px;
  gap: 18px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.admin-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.admin-search input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.admin-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  flex: 1;
  min-height: 0;
}

.admin-list,
.admin-detail {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

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

.list-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  background: #f8fafc;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.filter-chip.is-active {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: #1d4ed8;
}

.list-table-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  flex: 1;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table thead {
  background: #f8fafc;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

.data-table tbody tr:hover {
  background: #f1f5f9;
}

.data-table tbody tr.is-selected {
  background: #e0e7ff;
}

.detail-header {
  margin-bottom: 8px;
}

.detail-title {
  font-weight: 700;
  font-size: 1rem;
}

.detail-body {
  overflow: auto;
  font-size: 0.9rem;
  color: var(--text);
}

.detail-section {
  margin-bottom: 16px;
}

.detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.detail-value {
  font-weight: 600;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.detail-placeholder {
  color: var(--muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.form-group input,
.form-group select,
.form-group textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.green {
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
}

.badge.red {
  background: rgba(220, 38, 38, 0.12);
  color: #991b1b;
}

.badge.yellow {
  background: rgba(234, 179, 8, 0.16);
  color: #854d0e;
}

.badge.blue {
  background: rgba(59, 130, 246, 0.15);
  color: #1e40af;
}

.add-video-toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.add-video-toast {
  min-width: 200px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: auto;
}

.add-video-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.add-video-toast-success {
  border-left: 4px solid #22c55e;
}

.add-video-toast-error {
  border-left: 4px solid #ef4444;
}

.add-video-toast-muted,
.add-video-toast-info {
  border-left: 4px solid #783dd2;
}

@media (max-width: 980px) {
  .admin-app {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }

  .admin-brand {
    width: 100%;
  }

  .admin-content {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --panel: #0f172a;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #1e293b;
    --shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  }

  body.admin-body {
    background: radial-gradient(circle at top, #0f172a 0%, #0b1120 60%, #0b1220 100%);
    color: var(--text);
  }

  .admin-sidebar {
    background: #0b1120;
    color: #cbd5f5;
  }

  .admin-nav-item.is-active {
    background: #1f2937;
  }

  .admin-topbar,
  .admin-list,
  .admin-detail,
  .auth-card {
    background: var(--panel);
    border-color: var(--border);
  }

  .data-table thead {
    background: #111827;
  }

  .data-table tbody tr:hover {
    background: rgba(30, 41, 59, 0.6);
  }

  .data-table tbody tr.is-selected {
    background: rgba(99, 102, 241, 0.2);
  }

  .role-badge {
    background: #1e293b;
    color: #e2e8f0;
  }

  .filter-chip {
    background: #0f172a;
    border-color: #1e293b;
    color: #cbd5f5;
  }

  .filter-chip.is-active {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    color: #c7d2fe;
  }

  .add-video-toast {
    background: rgba(15, 23, 42, 0.95);
    color: #f8fafc;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  }

  .add-video-toast-muted,
  .add-video-toast-info {
    border-left-color: #a78bfa;
  }
}
