:root {
  --nx-primary: #7c3aed;
  --nx-primary-light: #a78bfa;
  --nx-primary-dark: #5b21b6;
  --nx-accent: #06b6d4;
  --nx-accent-light: #22d3ee;
  --nx-gradient: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  --nx-gradient-warm: linear-gradient(135deg, #f43f5e 0%, #7c3aed 50%, #06b6d4 100%);
  --nx-glass-bg: rgba(15, 10, 30, 0.75);
  --nx-glass-border: rgba(255, 255, 255, 0.08);
  --nx-glass-blur: 20px;
  --nx-text: #f1f5f9;
  --nx-text-muted: #94a3b8;
  --nx-text-dim: #64748b;
  --nx-radius: 12px;
  --nx-radius-sm: 8px;
  --nx-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --nx-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --nx-glow: 0 0 15px rgba(124, 58, 237, 0.3);
  --nx-danger: #ef4444;
  --nx-success: #22c55e;
  --nx-warning: #f59e0b;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #06060e;
  color: var(--nx-text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Background Orbs ===== */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
}
.orb-1 {
  width: 600px; height: 600px;
  background: rgba(124, 58, 237, 0.12);
  top: -200px; left: -100px;
  animation: orbFloat 12s ease-in-out infinite;
}
.orb-2 {
  width: 500px; height: 500px;
  background: rgba(6, 182, 212, 0.08);
  bottom: -150px; right: -100px;
  animation: orbFloat 15s ease-in-out infinite reverse;
}
@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(40px, -30px); }
}

/* ===== Layout ===== */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ===== Navbar ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 6, 14, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--nx-glass-border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--nx-text);
  font-weight: 700;
  font-size: 20px;
}
.navbar-brand svg { width: 28px; height: 28px; color: var(--nx-primary-light); }
.navbar-brand span { background: var(--nx-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.navbar-links { display: flex; align-items: center; gap: 4px; }
.navbar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--nx-radius-sm);
  text-decoration: none;
  color: var(--nx-text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--nx-transition);
  border: none;
  background: none;
  cursor: pointer;
}
.navbar-link:hover, .navbar-link.active {
  color: var(--nx-text);
  background: rgba(255, 255, 255, 0.06);
}
.navbar-link.active { color: var(--nx-accent-light); }
.navbar-link svg { width: 18px; height: 18px; }
.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.navbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--nx-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}
.btn-logout {
  padding: 6px 14px;
  border-radius: var(--nx-radius-sm);
  border: 1px solid var(--nx-glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--nx-text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--nx-transition);
}
.btn-logout:hover { color: var(--nx-danger); border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.08); }

/* ===== Main Content ===== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ===== Glass Card ===== */
.glass {
  background: var(--nx-glass-bg);
  backdrop-filter: blur(var(--nx-glass-blur));
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius);
  box-shadow: var(--nx-shadow);
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-title {
  font-size: 28px;
  font-weight: 800;
  background: var(--nx-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.page-subtitle { color: var(--nx-text-muted); font-size: 14px; margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--nx-radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--nx-transition);
  border: none;
  text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary {
  background: var(--nx-gradient);
  color: #fff;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4); }
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--nx-text);
  border: 1px solid var(--nx-glass-border);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--nx-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-icon { padding: 8px; border-radius: var(--nx-radius-sm); }
.btn-icon:hover { background: rgba(255, 255, 255, 0.08); }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--nx-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius-sm);
  color: var(--nx-text);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--nx-transition);
  outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--nx-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--nx-text-dim); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { cursor: pointer; }
.form-select option { background: #1a1a2e; color: var(--nx-text); }

/* ===== Login ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
}
.login-card h1 {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
  background: var(--nx-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-card .subtitle {
  text-align: center;
  color: var(--nx-text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo svg { width: 48px; height: 48px; color: var(--nx-primary-light); }
.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--nx-radius-sm);
  padding: 10px 14px;
  color: var(--nx-danger);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* ===== Upload ===== */
.upload-zone {
  border: 2px dashed var(--nx-glass-border);
  border-radius: var(--nx-radius);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--nx-transition);
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--nx-primary);
  background: rgba(124, 58, 237, 0.05);
  box-shadow: inset 0 0 30px rgba(124, 58, 237, 0.05);
}
.upload-zone.dragover { border-style: solid; transform: scale(1.01); }
.upload-zone svg { width: 48px; height: 48px; color: var(--nx-text-dim); margin-bottom: 16px; }
.upload-zone h3 { font-size: 16px; color: var(--nx-text); margin-bottom: 8px; }
.upload-zone p { color: var(--nx-text-muted); font-size: 13px; }
.upload-zone input[type="file"] { display: none; }
.upload-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--nx-radius-sm);
  margin-top: 16px;
}
.upload-preview .file-icon {
  width: 48px; height: 48px;
  background: var(--nx-gradient);
  border-radius: var(--nx-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-preview .file-icon svg { width: 24px; height: 24px; color: #fff; }
.upload-preview .file-info { flex: 1; }
.upload-preview .file-name { font-weight: 600; font-size: 14px; }
.upload-preview .file-size { color: var(--nx-text-muted); font-size: 12px; }
.upload-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  background: var(--nx-gradient);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
}

/* ===== Video Grid ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.video-card {
  background: var(--nx-glass-bg);
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius);
  overflow: hidden;
  transition: all var(--nx-transition);
  cursor: pointer;
}
.video-card:hover {
  border-color: rgba(124, 58, 237, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}
.video-card-thumb {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #0a0a14;
  overflow: hidden;
}
.video-card-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-card-thumb .no-thumb {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #0a0a14 100%);
}
.video-card-thumb .no-thumb svg { width: 40px; height: 40px; color: var(--nx-text-dim); }
.video-card-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.video-card-body { padding: 14px; }
.video-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--nx-text);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card-meta {
  font-size: 12px;
  color: var(--nx-text-muted);
}
.video-card-actions {
  display: flex;
  gap: 4px;
  padding: 0 14px 14px;
}

/* ===== Playlist Grid ===== */
.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.playlist-card {
  background: var(--nx-glass-bg);
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius);
  padding: 20px;
  transition: all var(--nx-transition);
  cursor: pointer;
}
.playlist-card:hover {
  border-color: rgba(124, 58, 237, 0.3);
  transform: translateY(-2px);
}
.playlist-card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.playlist-card-meta { font-size: 13px; color: var(--nx-text-muted); margin-bottom: 12px; }
.playlist-card-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(124, 58, 237, 0.1);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--nx-primary-light);
}

/* ===== Table ===== */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--nx-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--nx-glass-border);
}
td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ===== Watch Page ===== */
.watch-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}
.watch-player {
  background: #000;
  border-radius: var(--nx-radius);
  overflow: hidden;
  aspect-ratio: 16/9;
}
.watch-player .nx-player { height: 100%; }
.watch-info { padding: 20px 0; }
.watch-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.watch-meta { color: var(--nx-text-muted); font-size: 13px; margin-bottom: 16px; }
.watch-desc { color: var(--nx-text-muted); font-size: 14px; line-height: 1.7; }
.watch-sidebar { max-height: calc(100vh - 100px); overflow-y: auto; }
.watch-sidebar-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--nx-text-muted);
  margin-bottom: 12px;
  padding: 0 4px;
}
.watch-sidebar-item {
  display: flex;
  gap: 12px;
  padding: 8px;
  border-radius: var(--nx-radius-sm);
  cursor: pointer;
  transition: all var(--nx-transition);
}
.watch-sidebar-item:hover { background: rgba(255, 255, 255, 0.04); }
.watch-sidebar-item.active { background: rgba(124, 58, 237, 0.1); border: 1px solid rgba(124, 58, 237, 0.2); }
.watch-sidebar-thumb {
  width: 140px;
  min-width: 140px;
  aspect-ratio: 16/9;
  border-radius: 6px;
  overflow: hidden;
  background: #0a0a14;
}
.watch-sidebar-thumb img { width: 100%; height: 100%; object-fit: cover; }
.watch-sidebar-info { flex: 1; min-width: 0; }
.watch-sidebar-info h4 {
  font-size: 13px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.watch-sidebar-info p { font-size: 12px; color: var(--nx-text-muted); }

/* ===== Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--nx-glass-bg);
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius);
  padding: 20px;
}
.stat-card-value { font-size: 32px; font-weight: 800; background: var(--nx-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-card-label { font-size: 13px; color: var(--nx-text-muted); margin-top: 4px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: #1a1a2e;
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius);
  padding: 28px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal h2 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--nx-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  animation: toastIn 0.3s ease;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  max-width: 360px;
}
.toast.success { background: rgba(34, 197, 94, 0.9); }
.toast.error { background: rgba(239, 68, 68, 0.9); }
.toast.info { background: rgba(124, 58, 237, 0.9); }
.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--nx-text-muted);
}
.empty-state svg { width: 64px; height: 64px; color: var(--nx-text-dim); margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--nx-text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 24px; }

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-admin { background: rgba(124, 58, 237, 0.15); color: var(--nx-primary-light); }
.badge-user { background: rgba(6, 182, 212, 0.15); color: var(--nx-accent-light); }

/* ===== Add-to-Playlist Dropdown ===== */
.add-to-playlist-wrap { position: relative; display: inline-block; }
.add-to-playlist-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background: #1a1a2e;
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius-sm);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  z-index: 50;
  display: none;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}
.add-to-playlist-menu.open { display: block; }
.add-to-playlist-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--nx-text);
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
}
.add-to-playlist-menu button:hover { background: rgba(255, 255, 255, 0.06); }

/* ===== Spinner ===== */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--nx-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .watch-layout { grid-template-columns: 1fr; }
  .watch-sidebar { max-height: none; }
  .navbar { padding: 0 16px; }
  .main-content { padding: 20px 16px 48px; }
}
@media (max-width: 600px) {
  .video-grid { grid-template-columns: 1fr; }
  .playlist-grid { grid-template-columns: 1fr; }
  .navbar-links .link-text { display: none; }
  .page-title { font-size: 22px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
