/* ============================================================
   S-VID — Design System & Global Styles
   Premium dark-mode streaming platform aesthetic
   ============================================================ */

/* ── CSS Variables ────────────────────────────── */
:root {
  /* Color Palette - Deep space / cinema feel */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a28;
  --bg-card: #16161f;
  --bg-card-hover: #1e1e2e;
  --bg-glass: rgba(22, 22, 31, 0.85);

  /* Accent Gradient */
  --accent-start: #6c5ce7;
  --accent-mid: #a855f7;
  --accent-end: #ec4899;
  --accent-gradient: linear-gradient(135deg, var(--accent-start), var(--accent-mid), var(--accent-end));

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --text-accent: #a855f7;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(168, 85, 247, 0.3);

  /* Shadows */
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(168, 85, 247, 0.15);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);

  /* Spacing */
  --container-max: 1400px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset & Base ─────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(236, 72, 153, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--accent-end);
}

/* ── Typography ───────────────────────────────── */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 {
  font-size: 2rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

/* ── Layout ───────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* ── Navigation ───────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.navbar-brand .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-links a {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--accent-gradient);
  color: white !important;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-smooth);
  text-decoration: none;
}

.btn-upload:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

/* ── Video Grid ───────────────────────────────── */
.page-header {
  padding: 40px 0 24px;
}

.page-header h1 {
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  padding-bottom: 60px;
}

.video-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-smooth);
  cursor: pointer;
}

.video-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.video-card .thumbnail-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.video-card .thumbnail-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-smooth);
}

.video-card:hover .thumbnail-wrapper img {
  transform: scale(1.05);
}

.video-card .duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.video-card .card-body {
  padding: 16px;
}

.video-card .card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.video-card .card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.video-card .card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Player Page ──────────────────────────────── */
.player-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 32px;
  padding: 24px 0 60px;
}

.player-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow-lg);
}

.player-container .video-js {
  width: 100%;
  aspect-ratio: 16/9;
}

.video-info {
  padding: 20px 0;
}

.video-info h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  -webkit-text-fill-color: var(--text-primary);
  background: none;
}

.video-info .info-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.video-info .info-stats span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.video-info .description {
  margin-top: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.95rem;
}

/* ── Sidebar ──────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 2px;
}

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.sidebar-card .thumb {
  width: 160px;
  min-width: 160px;
  aspect-ratio: 16/9;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.sidebar-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-card .info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sidebar-card .info h4 {
  font-size: 0.85rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.sidebar-card .info .meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ── Comments Section ─────────────────────────── */
.comments-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.comments-section h2 {
  margin-bottom: 20px;
  font-size: 1.2rem;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.comment-form .form-row {
  display: flex;
  gap: 12px;
}

.comment-form input,
.comment-form textarea {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
  resize: vertical;
}

.comment-form input:focus,
.comment-form textarea:focus {
  outline: none;
  border-color: var(--accent-mid);
}

.comment-form textarea {
  min-height: 80px;
}

.comment-form .btn-submit {
  align-self: flex-end;
  padding: 10px 24px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-smooth);
}

.comment-form .btn-submit:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.comment-form .btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Comment List */
.comment-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
  animation: fadeIn 0.3s ease;
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.comment-username {
  font-weight: 600;
  font-size: 0.9rem;
}

.comment-date {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.comment-body {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  padding-left: 40px;
}

.comment-actions {
  padding-left: 40px;
  margin-top: 8px;
}

.btn-reply {
  background: none;
  border: none;
  color: var(--text-accent);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 0;
  font-weight: 500;
}

.btn-reply:hover {
  text-decoration: underline;
}

/* Replies (nested) */
.comment-replies {
  margin-left: 40px;
  padding-left: 16px;
  border-left: 2px solid var(--border-subtle);
}

.comment-replies .comment-item {
  padding: 12px 0;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 0;
}

.pagination button {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination .page-info {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0 12px;
}

/* ── Upload Page ──────────────────────────────── */
.upload-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 48px 0 60px;
}

.upload-container h1 {
  margin-bottom: 32px;
  text-align: center;
}

.upload-dropzone {
  border: 2px dashed var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 60px 40px;
  text-align: center;
  background: var(--bg-card);
  transition: all var(--transition-smooth);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.upload-dropzone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.upload-dropzone:hover::before,
.upload-dropzone.dragover::before {
  opacity: 0.05;
}

.upload-dropzone.dragover {
  border-color: var(--accent-mid);
  transform: scale(1.01);
}

.upload-dropzone .drop-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.upload-dropzone .drop-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.upload-dropzone .drop-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  position: relative;
  z-index: 1;
}

.upload-form {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-mid);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

/* Progress Bar */
.upload-progress {
  display: none;
  margin-top: 24px;
}

.upload-progress.active {
  display: block;
}

.progress-bar-container {
  background: var(--bg-tertiary);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 4px;
  width: 0%;
  transition: width var(--transition-smooth);
}

.progress-text {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: center;
}

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-badge.pending {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.status-badge.processing {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.status-badge.ready {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.status-badge.error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Pulse animation for processing */
.status-badge.processing::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #3b82f6;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

/* ── Toast Notifications ──────────────────────── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  min-width: 300px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.toast.success { border-left: 3px solid #22c55e; }
.toast.error { border-left: 3px solid #ef4444; }
.toast.info { border-left: 3px solid #3b82f6; }

/* ── Loader / Skeleton ────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-tertiary) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}

/* ── Empty State ──────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Animations ───────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.5); }
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 1024px) {
  .player-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .video-grid {
    grid-template-columns: 1fr;
  }

  .navbar .container {
    gap: 8px;
  }

  .navbar-links {
    gap: 4px;
  }

  .navbar-links a {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  h1 { font-size: 1.5rem; }

  .upload-dropzone {
    padding: 40px 20px;
  }

  .comment-form .form-row {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .video-grid {
    gap: 16px;
  }

  .sidebar-card {
    flex-direction: column;
  }

  .sidebar-card .thumb {
    width: 100%;
    min-width: unset;
  }
}
