:root {
  --bg: #030305;
  --surface: rgba(16, 17, 24, 0.65);
  --surface-2: rgba(255, 255, 255, 0.045);
  --surface-solid: #0d0e14;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e2e8f0;
  --text-dim: #8b94a8;
  --accent: #00f3ff;
  --accent-contrast: #031014;
  --secondary: #7000ff;
  --success: #00ff9d;
  --danger: #ff0055;
  --danger-contrast: #ffffff;
  --warning: #ffb700;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 0 24px rgba(0, 243, 255, 0.12), 0 24px 70px rgba(0, 0, 0, 0.65);
  --font-ui: 'Rajdhani', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- FX layers (particles, scanlines / film grain, matching the SDR dashboard aesthetic) ---------- */

#bgCanvas {
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
}

.scanlines {
  position: fixed; inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.2));
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 50;
  opacity: 0.5;
}
.noise {
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 49;
  opacity: 0.35;
}

/* ---------- Holographic panel treatment (cards, auth card, admin panels, lightbox) ---------- */

.card, .panel, .auth-card, .modal-content {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card::before, .panel::before {
  content: '';
  position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 243, 255, 0.06), transparent);
  transition: left 0.5s ease;
  pointer-events: none;
}
.card:hover::before, .panel:hover::before { left: 100%; }
.card:hover, .panel:hover {
  border-color: rgba(0, 243, 255, 0.3);
  box-shadow: var(--shadow-lg);
}
.card:hover { transform: translateY(-2px); }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: 0 0 0 rgba(0,243,255,0); }
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 0 16px rgba(0, 243, 255, 0.45); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--danger-contrast); box-shadow: 0 0 16px rgba(255, 0, 85, 0.45); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { color: var(--accent); border-color: rgba(0, 243, 255, 0.4); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

input[type="text"], input[type="password"], input[type="search"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
}
input::placeholder { color: var(--text-dim); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 243, 255, 0.15); }

.select-pill, .input-search {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  font-family: var(--font-ui);
  font-size: 14px;
}
.input-search { width: 260px; }

.alert { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: rgba(255, 0, 85, 0.1); color: #ff6b9a; border: 1px solid rgba(255, 0, 85, 0.35); }
.alert ul { margin: 0; padding-left: 18px; }

/* ---------- Auth page ---------- */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(112, 0, 255, 0.18), transparent 45%),
    radial-gradient(circle at 80% 85%, rgba(0, 243, 255, 0.14), transparent 45%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 360px;
  border-radius: var(--radius);
  padding: 36px 32px;
  text-align: center;
}
.auth-mark { margin-bottom: 14px; filter: drop-shadow(0 0 10px rgba(0, 243, 255, 0.5)); }
.auth-card h1 {
  font-size: 22px; margin: 0 0 4px; letter-spacing: 0.02em; text-transform: uppercase;
  text-shadow: 0 0 14px rgba(0, 243, 255, 0.35);
}
.auth-sub { color: var(--text-dim); font-size: 14px; margin: 0 0 22px; font-family: var(--font-mono); }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.auth-form .btn { margin-top: 4px; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.75);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(0, 243, 255, 0.15);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-titles { line-height: 1.25; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.04em; text-transform: uppercase; }
.brand-sub { font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ---------- Impersonation banner ---------- */

.impersonate-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 28px;
  background: rgba(255, 183, 0, 0.1);
  border-bottom: 1px solid rgba(255, 183, 0, 0.35);
  color: var(--warning);
  font-size: 13px;
  font-family: var(--font-mono);
  flex-wrap: wrap;
  position: relative;
  z-index: 5;
}

/* ---------- Bulk selection bar ---------- */

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.bulk-bar[hidden] { display: none; }
#bulk-count { font-family: var(--font-mono); font-size: 13px; color: var(--accent); }
.bulk-bar-actions { display: flex; gap: 8px; }

.card-select {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 2;
  width: 20px; height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}
.card.selected { border-color: rgba(0, 243, 255, 0.5); box-shadow: var(--shadow-lg); }

/* ---------- Page layout ---------- */

.page { max-width: 1200px; margin: 0 auto; padding: 28px; position: relative; z-index: 1; }
.page-narrow { max-width: 760px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 10px; }

.empty-state { text-align: center; color: var(--text-dim); padding: 80px 20px; }
.empty-state svg { margin-bottom: 14px; opacity: 0.6; }
.empty-state-hint { font-size: 13px; margin-top: 6px; font-family: var(--font-mono); }

/* ---------- Upload: drop zone & progress ---------- */

.dropzone {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(3, 3, 5, 0.85);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.dropzone[hidden] { display: none; }
.dropzone-inner {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 48px 64px;
  text-align: center;
  color: var(--text);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
}
.dropzone-inner svg { margin-bottom: 10px; filter: drop-shadow(0 0 8px rgba(0, 243, 255, 0.6)); }
.dropzone-inner p { margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.upload-progress {
  position: fixed; right: 20px; bottom: 20px; z-index: 95;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  font-size: 13px;
  font-family: var(--font-mono);
  min-width: 220px;
}
.upload-progress[hidden] { display: none; }
.upload-progress .row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.upload-progress .row:last-child { margin-bottom: 0; }
.upload-progress .err { color: var(--danger); }
.progress-track { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: var(--accent); box-shadow: 0 0 8px rgba(0, 243, 255, 0.6); transition: width 0.15s ease; }

/* ---------- Grid & cards ---------- */

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

.card {
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.card-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb .file-icon { width: 44px; height: 44px; color: var(--text-dim); filter: drop-shadow(0 0 6px rgba(0, 243, 255, 0.2)); }
.card-thumb .play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.5) 100%);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.card-thumb:hover .play-badge { opacity: 1; }
.play-badge svg { width: 42px; height: 42px; filter: drop-shadow(0 0 8px rgba(0, 243, 255, 0.8)); }

.card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-name {
  font-size: 13.5px;
  font-weight: 600;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-meta { font-size: 11.5px; color: var(--text-dim); font-family: var(--font-mono); }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.card-actions .btn { flex: 1; padding: 7px 10px; font-size: 12px; }

/* ---------- Lightbox ---------- */

.lightbox { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(3, 3, 5, 0.85); backdrop-filter: blur(6px); }
.lightbox-content {
  position: relative;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: min(900px, 94vw);
  max-height: 90vh;
  width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
#lightbox-media { background: #000; display: flex; align-items: center; justify-content: center; max-height: 70vh; }
#lightbox-media video, #lightbox-media img { max-width: 100%; max-height: 70vh; display: block; }
.lightbox-close {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(3,3,5,0.7); color: var(--text);
  font-size: 20px; line-height: 1; cursor: pointer; z-index: 2;
}
.lightbox-close:hover { border-color: var(--accent); color: var(--accent); }
.lightbox-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; flex-wrap: wrap; }
#lightbox-name { font-weight: 600; font-size: 13px; word-break: break-word; font-family: var(--font-mono); }
.lightbox-actions { display: flex; gap: 8px; }

/* ---------- Admin ---------- */

.panel {
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 24px;
}
.panel h2 { margin: 0 0 16px; font-size: 16px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); text-shadow: 0 0 10px rgba(0, 243, 255, 0.3); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table th { color: var(--text-dim); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--font-mono); }
.table code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; font-family: var(--font-mono); color: var(--accent); }
.table-actions { display: flex; gap: 8px; justify-content: flex-end; }

.form-grid { display: flex; flex-direction: column; gap: 14px; max-width: 380px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-row input { width: auto; }

/* ---------- Themed modal (replaces native confirm/prompt) ---------- */

.modal { position: fixed; inset: 0; z-index: 110; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 3, 5, 0.85); backdrop-filter: blur(6px); }
.modal-content { position: relative; width: 100%; max-width: 420px; padding: 24px; border-radius: var(--radius); }
.modal-content h3 { margin: 0 0 10px; font-size: 16px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); text-shadow: 0 0 10px rgba(0, 243, 255, 0.3); }
.modal-content p { margin: 0 0 16px; font-size: 14px; color: var(--text-dim); line-height: 1.5; white-space: pre-line; }
.modal-content #ui-modal-input-wrap { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.pw-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 14px; }

/* ---------- Toast notification ---------- */

.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 13px;
  font-family: var(--font-mono);
  z-index: 120;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

/* ---------- Scrollbar ---------- */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

@media (max-width: 640px) {
  .page { padding: 18px; }
  .topbar { padding: 12px 16px; }
  .input-search { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
}
