:root {
  --bg-deep: #0b051d;
  --bg-sidebar: #11072a;
  --bg-panel: rgba(26, 13, 58, 0.85);
  --bg-input: rgba(10, 4, 26, 0.8);
  --magenta-500: #db2777;
  --magenta-400: #f472b6;
  --purple-500: #7c3aed;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --cyan-400: #22d3ee;
  --gold-500: #f59e0b;
  --gold-400: #fbbf24;
  --text-light: #f8fafc;
  --text-muted: #94a3b8;
  --border-glass: rgba(255, 255, 255, 0.14);
  --radius-lg: 18px;
  --radius-md: 12px;
}

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

html, body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(219, 39, 119, 0.18), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(13, 148, 136, 0.18), transparent 42%),
    linear-gradient(180deg, #0b051d 0%, #130830 100%);
  color: var(--text-light);
  min-height: 100vh;
  line-height: 1.5;
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-panel);
  border: 1px solid rgba(244, 114, 182, 0.35);
  border-radius: 24px;
  max-width: 450px;
  width: 100%;
  padding: 2.25rem 2rem;
  text-align: center;
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(16px);
}

.login-logo-ring {
  width: 84px;
  height: 84px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 68%, #f5d0fe 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--magenta-400);
  box-shadow: 0 0 24px rgba(219, 39, 119, 0.5);
}

.login-logo-ring img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.badge-tag {
  display: inline-block;
  padding: 0.28rem 0.85rem;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.16);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: var(--cyan-400);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.65rem;
}

.login-card h1 {
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 0.5rem;
}

.login-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.login-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.login-footer-link {
  margin-top: 1.35rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border-glass);
}

.login-footer-link a {
  color: var(--cyan-400);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
}

/* Main Admin Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 275px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 1100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.25rem 1.2rem;
  border-bottom: 1px solid var(--border-glass);
}

.sidebar-logo {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--magenta-400);
}

.sidebar-logo img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.sidebar-brand-text {
  flex: 1;
  min-width: 0;
}

.sidebar-brand-text strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ffffff;
}

.sidebar-brand-text span {
  font-size: 0.75rem;
  color: var(--gold-400);
  font-weight: 700;
}

.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
}

.sidebar-db-status {
  margin: 0.9rem 1rem 0.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  background: rgba(13, 148, 136, 0.14);
  border: 1px solid rgba(20, 184, 166, 0.35);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  flex-shrink: 0;
}

.sidebar-db-status strong {
  display: block;
  font-size: 0.8rem;
  color: #a7f3d0;
}

.sidebar-db-status small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.nav-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(219, 39, 119, 0.28), rgba(124, 58, 237, 0.28));
  border-color: rgba(244, 114, 182, 0.45);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.nav-badge.teal {
  background: rgba(20, 184, 166, 0.25);
  color: #5eead4;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1050;
}

/* Main Content Area */
.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(11, 5, 29, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-glass);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.topbar-burger {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: #ffffff;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.25rem;
  cursor: pointer;
}

.topbar-left h2 {
  font-size: 1.35rem;
  font-weight: 900;
}

.topbar-left p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-content {
  padding: 1.75rem 2rem 3rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* KPI & Stats Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(244, 114, 182, 0.45);
}

.kpi-info small {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.kpi-info strong {
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1.1;
  display: block;
}

.kpi-info span {
  font-size: 0.78rem;
  color: var(--cyan-400);
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(219, 39, 119, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  flex-shrink: 0;
}

/* Admin Panels & Cards */
.panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.panel-header p {
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Filters Bar */
.filters-bar {
  display: grid;
  grid-template-columns: 1.6fr repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 0.68rem 0.9rem;
  color: #ffffff;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--magenta-400);
  box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.22);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1.15rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.86rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--magenta-500), var(--purple-500));
  color: #ffffff;
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-teal {
  background: linear-gradient(135deg, var(--teal-600), #0284c7);
  color: #ffffff;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-500), #d97706);
  color: #0b051d;
  font-weight: 800;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.32);
}

.btn-sm {
  padding: 0.4rem 0.78rem;
  font-size: 0.78rem;
  border-radius: 8px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 680px;
}

.admin-table th,
.admin-table td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--gold-400);
  text-transform: uppercase;
  font-size: 0.73rem;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.03);
}

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

.chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(219, 39, 119, 0.2);
  color: #fbcfe8;
}

.chip.teal {
  background: rgba(20, 184, 166, 0.22);
  color: #99f6e4;
}

.chip.gold {
  background: rgba(245, 158, 11, 0.22);
  color: #fde68a;
}

/* Live Stream Preview Grid */
.live-studio-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  align-items: start;
}

.video-preview-box {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-glass);
}

.video-preview-box iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Certificate Studio Canvas */
.cert-studio-wrap {
  background: rgba(9, 4, 24, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
}

#adminCertCanvas {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 2px solid rgba(245, 158, 11, 0.45);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 2, 15, 0.86);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: #160b36;
  border: 1px solid rgba(244, 114, 182, 0.4);
  border-radius: 20px;
  max-width: 780px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.75rem;
  position: relative;
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.75);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #1e1b4b;
  border-left: 4px solid var(--teal-500);
  color: #fff;
  padding: 0.85rem 1.2rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  font-size: 0.86rem;
  font-weight: 600;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .admin-sidebar {
    position: fixed;
    left: -290px;
    top: 0;
    bottom: 0;
    transition: left 0.25s ease;
  }

  .admin-sidebar.open {
    left: 0;
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .topbar-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .live-studio-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .admin-topbar {
    padding: 0.85rem 1rem;
  }

  .admin-content {
    padding: 1.15rem 1rem 2.5rem;
  }

  .form-grid,
  .filters-bar {
    grid-template-columns: 1fr;
  }

  .panel-card {
    padding: 1.15rem;
  }
}
