/* ═══════════════════════════════════════════════════════════════════════════
   Slide Notes — Admin Stylesheet
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --sidebar-w:    240px;
  --sidebar-bg:   #1a1d2e;
  --sidebar-text: #c5c9e0;
  --sidebar-active: #4361ee;
  --sidebar-hover: rgba(255,255,255,.07);

  --bg:           #f0f2f8;
  --surface:      #ffffff;
  --surface-2:    #f5f7fc;
  --border:       #e2e6ef;
  --text:         #1a1d2e;
  --text-muted:   #6b7280;
  --accent:       #4361ee;
  --accent-hover: #3451d1;
  --accent-light: #eff2fd;
  --danger:       #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fef2f2;
  --success-bg:   #d1fae5;
  --success-text: #065f46;
  --error-bg:     #fee2e2;
  --error-text:   #991b1b;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.1);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.14);
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform .3s ease;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.sidebar-brand svg { width: 30px; height: 30px; flex-shrink: 0; }

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: .25rem;
}
.sidebar-close svg { width: 20px; height: 20px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
}

.sidebar-username {
  font-size: .875rem;
  font-weight: 600;
  color: #fff;
}
.sidebar-role {
  font-size: .75rem;
  color: var(--sidebar-text);
  opacity: .7;
}

.sidebar-nav {
  list-style: none;
  padding: .75rem 0;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  font-size: .875rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  margin: .1rem .5rem;
  transition: background .15s, color .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: calc(100% - 1rem);
  text-align: left;
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--accent); color: #fff; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: .75rem 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-logout { color: #f87171; }
.sidebar-logout:hover { background: rgba(239,68,68,.15); color: #fca5a5; }

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 190;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 180;
  width: 40px;
  height: 40px;
  background: var(--sidebar-bg);
  border: none;
  border-radius: 8px;
  color: #fff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}
.sidebar-toggle svg { width: 20px; height: 20px; }

/* ── Admin Content ────────────────────────────────────────────────────────── */
.admin-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1400px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.page-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── Breadcrumb ───────────────────────────────────────────────────────────── */
.breadcrumb-back {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .8rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: .4rem;
  transition: color .15s;
}
.breadcrumb-back:hover { color: var(--accent); }
.breadcrumb-back svg   { width: 14px; height: 14px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: .9rem;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error   { background: var(--error-bg);   color: var(--error-text);   }
.alert-dismissible { justify-content: space-between; }
.alert-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  line-height: 1;
  padding: 0 .2rem;
}
.alert-close:hover { opacity: 1; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  text-decoration: none;
  border: 1.5px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn svg    { width: 15px; height: 15px; flex-shrink: 0; }

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

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--surface-2); border-color: #c0c7da; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-block { width: 100%; }
.btn-sm    { padding: .4rem .75rem; font-size: .8rem; }

.btn-icon-sm {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.btn-icon-sm svg     { width: 15px; height: 15px; }
.btn-icon-sm.btn-danger { color: var(--danger); }
.btn-icon-sm.btn-danger:hover { background: var(--danger-light); color: var(--danger-hover); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.2rem; }

label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .4rem;
}
.required { color: var(--danger); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"] {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  font-family: var(--font);
}
select,
.form-select {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  font-family: var(--font);
  transition: border-color .15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}
select:focus,
.form-select:focus { outline: none; border-color: var(--accent); }

input:focus { outline: none; border-color: var(--accent); }

/* ── Checkbox (Remember Me) ──────────────────────────────────────────────── */
.remember-group { margin-bottom: 1.4rem; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 0;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.field-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

.copy-field {
  display: flex;
  gap: .5rem;
}
.copy-field input { flex: 1; background: var(--surface-2); }

/* ── Role Badges ──────────────────────────────────────────────────────────── */
/* Sidebar user role badge */
.sidebar-role-badge {
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 99px;
  display: inline-block;
  margin-top: .1rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-admin  { background: rgba(99,102,241,.25); color: #a5b4fc; }
.role-editor { background: rgba(255,255,255,.1);  color: #94a3b8; }

/* Table role pill */
.role-pill {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .55rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-pill-admin  { background: #ede9fe; color: #6d28d9; }
.role-pill-editor { background: #e0f2fe; color: #0369a1; }

/* ── Role Selector (add user form) ───────────────────────────────────────── */
.role-selector {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.role-option {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .65rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-weight: normal; /* override label default */
}
.role-option:hover { border-color: var(--accent); background: var(--accent-light); }
.role-option input[type="radio"] { margin-top: .15rem; flex-shrink: 0; accent-color: var(--accent); }
.role-option input[type="radio"]:checked ~ .role-option-body strong { color: var(--accent); }
.role-option:has(input:checked) { border-color: var(--accent); background: var(--accent-light); }

.role-option-body {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.role-option-body strong { font-size: .875rem; color: var(--text); }
.role-option-body small  { font-size: .78rem;  color: var(--text-muted); }

/* ── Login Page ───────────────────────────────────────────────────────────── */
body.login-page {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.login-logo svg { width: 44px; height: 44px; flex-shrink: 0; }
.login-logo h1  { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.login-logo span { font-size: .85rem; color: var(--text-muted); }

/* ── Presentation Grid ────────────────────────────────────────────────────── */
.pres-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.pres-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
}
.pres-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.pres-thumb {
  position: relative;
  background: #0e0f1a;
  aspect-ratio: 16/9;
  overflow: hidden;
}
.pres-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .2s;
}

.pres-thumb-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #5a6080;
  gap: .5rem;
}
.pres-thumb-placeholder svg   { width: 40px; height: 40px; }
.pres-thumb-placeholder span  { font-size: .8rem; }

.pres-badge {
  position: absolute;
  bottom: .5rem;
  right: .5rem;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 99px;
  backdrop-filter: blur(4px);
}

.pres-body {
  padding: 1rem 1.1rem .75rem;
  flex: 1;
}
.pres-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .4rem;
}
.pres-meta {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .2rem;
}
.pres-meta svg { width: 13px; height: 13px; flex-shrink: 0; }
.pres-created  { font-size: .75rem; }

.pres-actions {
  display: flex;
  gap: .4rem;
  padding: .75rem 1.1rem 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ── Empty Card ───────────────────────────────────────────────────────────── */
.empty-card {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 4rem 2rem;
  text-align: center;
}
.empty-icon svg { width: 64px; height: 64px; color: #c0c7da; margin: 0 auto 1.25rem; display: block; }
.empty-card h3  { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; }
.empty-card p   { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Panel Cards ──────────────────────────────────────────────────────────── */
.edit-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.75rem;
  align-items: start;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.panel-card-muted { background: var(--surface-2); }

.panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.panel-header-row .panel-title { margin-bottom: 0; }

.slide-count-badge {
  font-size: .78rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  padding: .2rem .6rem;
  border-radius: 99px;
}

.panel-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}
.panel-placeholder svg { width: 48px; height: 48px; opacity: .4; }

/* ── Drop Zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--surface-2);
  margin-bottom: 1.25rem;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone-icon svg { width: 48px; height: 48px; color: #b0b8d0; margin: 0 auto .75rem; display: block; }
.drop-zone-text  { font-weight: 600; color: var(--text); margin-bottom: .3rem; }
.drop-zone-sub   { font-size: .82rem; color: var(--text-muted); margin-bottom: .75rem; }
.drop-zone-hint  { font-size: .78rem; color: var(--text-muted); margin-top: .75rem; }

/* ── Upload Queue ─────────────────────────────────────────────────────────── */
.upload-queue {
  margin-bottom: 1.25rem;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
  border: 1px solid var(--border);
}
.upload-item:last-child { margin-bottom: 0; }

.upload-item-name { flex: 1; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-progress-bar {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  flex-shrink: 0;
}
.upload-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .3s;
}

.upload-status { font-size: .78rem; color: var(--text-muted); flex-shrink: 0; }
.upload-status.done   { color: #059669; }
.upload-status.error  { color: var(--danger); }

/* ── Slide List (admin) ───────────────────────────────────────────────────── */
.slide-list { display: flex; flex-direction: column; gap: .5rem; }

.no-slides-msg { color: var(--text-muted); font-size: .875rem; text-align: center; padding: 1rem 0; }

.slide-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.slide-row:hover { background: var(--accent-light); }

.slide-row-drag {
  cursor: grab;
  color: var(--text-muted);
  flex-shrink: 0;
  padding: .25rem;
}
.slide-row-drag:active { cursor: grabbing; }
.slide-row-drag svg   { width: 18px; height: 18px; }

.slide-row-thumb {
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  background: #000;
  flex-shrink: 0;
}

.slide-row-info { flex: 1; min-width: 0; }
.slide-row-num  { font-size: .8rem; font-weight: 600; color: var(--text); display: block; }
.slide-row-file { font-size: .72rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* Drag ghost style */
.slide-row-ghost {
  opacity: .4;
  background: var(--accent-light) !important;
  border: 2px dashed var(--accent) !important;
}

.reorder-hint {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .75rem;
}
.reorder-hint svg { width: 14px; height: 14px; }

/* ── Data Table ───────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  text-align: left;
  padding: .6rem .75rem;
  background: var(--surface-2);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table td {
  padding: .7rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td      { background: var(--surface-2); }
.table-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.badge-you {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  padding: .1rem .4rem;
  border-radius: 99px;
  margin-left: .35rem;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}
.modal-icon svg   { width: 26px; height: 26px; }
.modal-icon-danger { background: var(--danger-light); color: var(--danger); }

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .75rem;
}
.modal-body {
  font-size: .9rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}
.modal-body strong { color: var(--text); }

.modal-footer {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .edit-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close  { display: flex; }
  .sidebar-overlay.show { display: block; }
  .sidebar-toggle { display: flex; }
  .admin-content  { margin-left: 0; padding: 1.25rem 1rem; padding-top: 4rem; }
  .pres-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .pres-table-wrap { overflow-x: auto; }
  .analytics-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Page Header Actions (view toggle + new btn) ─────────────────────────── */
.page-header-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}

/* ── View Toggle ──────────────────────────────────────────────────────────── */
.view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.view-toggle-btn:hover { color: var(--text); }
.view-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}
.view-toggle-btn svg { width: 16px; height: 16px; }

/* ── Presentation Table (List View) ──────────────────────────────────────── */
.pres-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.pres-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.pres-table thead th {
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: .75rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.pres-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.pres-table tbody tr:last-child { border-bottom: none; }
.pres-table tbody tr:hover { background: var(--surface-2); }
.pres-table td {
  padding: .7rem 1rem;
  color: var(--text);
  vertical-align: middle;
}
.pres-table .col-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pres-table .col-thumb { width: 64px; padding-right: .25rem; }
.pres-table .col-actions { width: 1%; white-space: nowrap; }
.pres-table .col-campus,
.pres-table .col-date { white-space: nowrap; }

.row-thumb {
  width: 56px;
  height: 34px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: var(--surface-2);
}
.row-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  color: var(--text-muted);
}
.row-thumb-empty svg { width: 18px; height: 18px; }

.row-title-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.row-title-link:hover { color: var(--accent); }

.row-actions {
  display: flex;
  gap: .25rem;
  justify-content: flex-end;
}
.btn-icon-danger { color: var(--danger); }
.btn-icon-danger:hover { background: var(--danger-light); color: var(--danger-hover); }

.campus-pill {
  display: inline-block;
  padding: .15rem .55rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.cell-muted { color: var(--text-muted); }

/* ── Views badge on grid cards ──────────────────────────────────────────── */
.pres-badge-views {
  left: .65rem;
  right: auto;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}

/* ── Analytics — Stat Cards ──────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-value-sm {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

/* ── Analytics Grid ─────────────────────────────────────────────────────── */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ── Aggregate lists ────────────────────────────────────────────────────── */
.agg-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.agg-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.agg-list li:last-child { border-bottom: none; }
.agg-count {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ── Bar Chart ──────────────────────────────────────────────────────────── */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  padding: 1rem 0 0;
  overflow-x: auto;
}
.bar-chart-col {
  flex: 1 0 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 28px;
}
.bar-chart-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  position: relative;
  min-height: 2px;
  transition: background .15s;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.bar-chart-col:hover .bar-chart-bar { background: var(--accent-hover); }
.bar-chart-value {
  position: absolute;
  top: -1.2rem;
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
}
.bar-chart-label {
  font-size: .65rem;
  color: var(--text-muted);
  margin-top: .35rem;
  white-space: nowrap;
  transform: rotate(-45deg);
  transform-origin: top center;
}

/* ── Visitor ID code ────────────────────────────────────────────────────── */
.visitor-id {
  font-family: ui-monospace, 'SF Mono', Monaco, Consolas, monospace;
  font-size: .75rem;
  background: var(--surface-2);
  padding: .15rem .4rem;
  border-radius: 4px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile width fixes — prevent horizontal overflow
   ═══════════════════════════════════════════════════════════════════════════ */
html, body { overflow-x: hidden; max-width: 100%; }
.admin-content { min-width: 0; max-width: 100vw; }

@media (max-width: 768px) {
  .admin-content {
    padding: 4rem .85rem 1.25rem;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: .75rem;
  }
  .page-header-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
  }
  .page-header-actions .btn { flex: 1; justify-content: center; }
  .panel-card { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .stat-card { padding: .8rem .9rem; }
  .stat-value { font-size: 1.5rem; }
  .stat-value-sm { font-size: .8rem; }
  .analytics-grid { grid-template-columns: 1fr; }
  .copy-field { flex-wrap: wrap; }
  .copy-field input { min-width: 0; width: 100%; }
  .edit-layout { grid-template-columns: 1fr; gap: 1rem; }
  .pres-grid { grid-template-columns: 1fr; }
  .pres-actions { flex-wrap: wrap; }
  .pres-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pres-table { min-width: 640px; }
  .slide-row { padding: .5rem; gap: .5rem; }
  .slide-row-thumb { width: 52px; height: 30px; }
  .slide-row-info { min-width: 0; }
  .slide-row-file { font-size: .68rem; }
  .bar-chart-col { min-width: 22px; flex-basis: 22px; }
  .bar-chart-label { font-size: .6rem; }
  .drop-zone { padding: 1.25rem .75rem; }
  .drop-zone-text { font-size: .88rem; }
}

@media (max-width: 480px) {
  .admin-content { padding: 4rem .65rem 1rem; }
  .stat-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 1.25rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Sidebar theme toggle button
   ═══════════════════════════════════════════════════════════════════════════ */
.sidebar-theme-toggle {
  font-size: .875rem;
  width: calc(100% - 1rem);
}
.theme-icon-dark,
.theme-label-dark { display: none; }
[data-theme="dark"] .theme-icon-light,
[data-theme="dark"] .theme-label-light { display: none; }
[data-theme="dark"] .theme-icon-dark,
[data-theme="dark"] .theme-label-dark { display: inline-block; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

/* ═══════════════════════════════════════════════════════════════════════════
   Dark Mode — variable overrides + component patches
   ═══════════════════════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  --bg:           #0f1120;
  --surface:      #1a1d2e;
  --surface-2:    #23273d;
  --border:       #2e3350;
  --text:         #e6e8f0;
  --text-muted:   #9aa1c0;
  --accent:       #6b83ff;
  --accent-hover: #8196ff;
  --accent-light: rgba(107, 131, 255, .18);
  --danger:       #ef4444;
  --danger-hover: #f87171;
  --danger-light: rgba(239, 68, 68, .18);
  --success-bg:   rgba(16, 185, 129, .22);
  --success-text: #6ee7b7;
  --error-bg:     rgba(239, 68, 68, .22);
  --error-text:   #fca5a5;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.4);
  --shadow-md:    0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.6);
}

/* Dark mode: per-element tweaks where hardcoded colors live */
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .pres-thumb { background: #000; }
[data-theme="dark"] .sidebar-role-badge.role-admin { background: rgba(107,131,255,.25); color: #b7c2ff; }
[data-theme="dark"] .sidebar-role-badge.role-editor { background: rgba(156,163,192,.2); color: #d1d5e6; }
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] .form-select {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus { border-color: var(--accent); }
[data-theme="dark"] input[type="date"] { color-scheme: dark; }
[data-theme="dark"] .btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn-outline:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .btn-icon-sm { background: var(--surface); border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .btn-icon-sm:hover { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .alert-success { background: var(--success-bg); color: var(--success-text); }
[data-theme="dark"] .alert-error   { background: var(--error-bg);   color: var(--error-text); }
[data-theme="dark"] .modal { background: var(--surface); color: var(--text); }
[data-theme="dark"] .drop-zone { background: var(--surface-2); border-color: var(--border); }
[data-theme="dark"] .drop-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }
[data-theme="dark"] .drop-zone-icon svg { color: #6b7299; }
[data-theme="dark"] .pres-thumb-placeholder { color: #6b7299; }
[data-theme="dark"] .row-thumb { background: var(--surface-2); }
[data-theme="dark"] .pres-table thead th { background: var(--surface-2); color: var(--text-muted); }
[data-theme="dark"] .pres-table tbody tr:hover { background: rgba(255,255,255,.03); }
[data-theme="dark"] .view-toggle { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .slide-row { background: var(--surface-2); border-color: var(--border); }
[data-theme="dark"] .slide-row:hover { background: var(--accent-light); }
[data-theme="dark"] .copy-field input { background: var(--surface-2); }
[data-theme="dark"] .bar-chart-bar { background: var(--accent); }

/* ─────────────────────────────────────────────────────────────
   Profile page
   ───────────────────────────────────────────────────────────── */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  align-items: start;
}
.profile-grid .panel-card { margin: 0; }
.profile-dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .65rem 1rem;
}
.profile-dl dt {
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.profile-dl dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
}
.panel-card h3 { margin: 0 0 1rem; font-size: 1.05rem; color: var(--text); }
.panel-card h3:first-child { margin-top: 0; }

/* ─────────────────────────────────────────────────────────────
   Audit log page
   ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.filter-bar .form-group { margin: 0; min-width: 180px; flex: 1 1 180px; }
.filter-bar .filter-actions {
  display: flex;
  gap: .5rem;
  flex: 0 0 auto;
  align-items: center;
}
.filter-bar .filter-actions .btn { white-space: nowrap; }

.audit-table th,
.audit-table td {
  font-size: .88rem;
  vertical-align: top;
}
.audit-table .col-date { width: 150px; white-space: nowrap; }
.audit-table .col-ip   { width: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }

.audit-action {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}
.audit-action-auth         { background: #e0e7ff; color: #3730a3; }
.audit-action-user         { background: #fde4cf; color: #9a3412; }
.audit-action-presentation { background: #dcfce7; color: #166534; }
.audit-action-slide        { background: #fef3c7; color: #854d0e; }
.audit-action-other        { background: #e5e7eb; color: #374151; }

[data-theme="dark"] .audit-action-auth         { background: rgba(99,102,241,.18); color: #a5b4fc; }
[data-theme="dark"] .audit-action-user         { background: rgba(249,115,22,.18); color: #fdba74; }
[data-theme="dark"] .audit-action-presentation { background: rgba(34,197,94,.18); color: #86efac; }
[data-theme="dark"] .audit-action-slide        { background: rgba(234,179,8,.18); color: #fde68a; }
[data-theme="dark"] .audit-action-other        { background: var(--surface-2); color: var(--text-muted); }

.audit-details {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .75rem;
  max-width: 420px;
}
.audit-kv {
  display: inline-flex;
  gap: .25rem;
  font-size: .82rem;
  line-height: 1.3;
}
.audit-k { color: var(--text-muted); font-weight: 600; }
.audit-v { color: var(--text); word-break: break-word; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
}
.pagination-info { color: var(--text-muted); font-size: .88rem; }

/* ─────────────────────────────────────────────────────────────
   Users page — modal, role pill, "you" badge
   ───────────────────────────────────────────────────────────── */
.modal-lg { max-width: 560px; }
.modal-body-sub {
  color: var(--text-muted);
  font-size: .88rem;
  margin: 0 0 1rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
}

.role-pill {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.role-pill-admin  { background: #e0e7ff; color: #3730a3; }
.role-pill-editor { background: #dcfce7; color: #166534; }
[data-theme="dark"] .role-pill-admin  { background: rgba(99,102,241,.2);  color: #a5b4fc; }
[data-theme="dark"] .role-pill-editor { background: rgba(34,197,94,.18); color: #86efac; }

.badge-you {
  display: inline-block;
  margin-left: .5rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: middle;
}

/* ─────────────────────────────────────────────────────────────
   Login page — forgot password link
   ───────────────────────────────────────────────────────────── */
.remember-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.link-muted {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
}
.link-muted:hover { color: var(--accent); text-decoration: underline; }
.forgot-link { white-space: nowrap; }

/* Login page spacing for success/info messages */
.alert.alert-info {
  background: #e0e7ff;
  color: #3730a3;
  padding: .85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .9rem;
}
[data-theme="dark"] .alert.alert-info {
  background: rgba(99,102,241,.15);
  color: #a5b4fc;
}
