/* ═══════════════════════════════════════════════════════════
   StreamVault — Premium Dark Cinema Theme
   ═══════════════════════════════════════════════════════════ */

/* ── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-glass: rgba(18, 18, 30, 0.85);
  --bg-overlay: rgba(0, 0, 0, 0.8);

  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;

  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-glow: rgba(139, 92, 246, 0.3);
  --accent-subtle: rgba(139, 92, 246, 0.1);

  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  /* Spacing */
  --header-height: 72px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient background effect */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 80%, rgba(59, 130, 246, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── HEADER ────────────────────────────────────────────────── */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: background 0.3s var(--ease);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.logo-icon {
  font-size: 28px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo .accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.video-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 6px 14px;
  background: var(--bg-card);
  border-radius: 100px;
  border: 1px solid var(--border);
}

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  box-shadow: 0 6px 24px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  box-shadow: 0 6px 24px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ── UPLOAD PANEL ──────────────────────────────────────────── */
.upload-panel {
  position: relative;
  z-index: 1;
  margin-top: var(--header-height);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s var(--ease), opacity 0.3s var(--ease);
  opacity: 0;
}

.upload-panel.open {
  max-height: 400px;
  opacity: 1;
}

.upload-panel-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 0;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s var(--ease);
  background: var(--bg-card);
  position: relative;
  overflow: hidden;
}

.dropzone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-subtle), transparent);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.05);
}

.dropzone:hover::before,
.dropzone.dragover::before {
  opacity: 1;
}

.dropzone-content {
  position: relative;
  z-index: 1;
}

.dropzone-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
  transition: all 0.3s var(--ease);
}

.dropzone:hover .dropzone-icon {
  color: var(--accent);
  transform: translateY(-4px);
}

.dropzone-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.dropzone-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Upload progress */
.upload-progress {
  display: none;
  padding: 20px 0;
}

.upload-progress.active {
  display: block;
  animation: fadeIn 0.3s var(--ease);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progress-filename {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-percent {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.progress-bar-track {
  height: 6px;
  background: var(--bg-card);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 100px;
  transition: width 0.3s var(--ease);
  box-shadow: 0 0 12px var(--accent-glow);
}

.progress-status {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── LIBRARY ───────────────────────────────────────────────── */
#library {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 60px;
  margin-top: var(--header-height);
}

.upload-panel.open ~ #library {
  margin-top: 0;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.library-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.25s var(--ease);
  min-width: 240px;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  animation: fadeIn 0.5s var(--ease);
}

.empty-state.show {
  display: flex;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

.empty-state h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

/* ── VIDEO GRID ────────────────────────────────────────────── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.35s var(--ease);
  position: relative;
  group: true;
}

.video-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-hover);
  background: var(--bg-card-hover);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, #1a1a2e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.video-thumbnail::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%);
}

.thumbnail-icon {
  font-size: 40px;
  opacity: 0.3;
  transition: all 0.3s var(--ease);
}

.video-card:hover .thumbnail-icon {
  opacity: 0.5;
  transform: scale(1.1);
}

/* Play button overlay */
.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.video-card:hover .play-overlay {
  opacity: 1;
}

.play-btn {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: all 0.3s var(--ease-spring);
}

.video-card:hover .play-btn {
  transform: scale(1.1);
}

.play-btn svg {
  color: white;
  margin-left: 3px;
}

/* File extension badge */
.ext-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-hover);
  z-index: 3;
  letter-spacing: 0.5px;
}

.video-info {
  padding: 16px;
}

.video-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.video-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.video-meta-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.video-size,
.video-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.video-date {
  position: relative;
  padding-left: 12px;
}

.video-date::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* Delete button on card */
.card-delete {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.25s var(--ease-spring);
  z-index: 5;
}

.video-card:hover .card-delete {
  opacity: 1;
  transform: scale(1);
}

.card-delete:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* ── PLAYER MODAL ──────────────────────────────────────────── */
.player-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.player-modal.open {
  display: flex;
  animation: fadeIn 0.3s var(--ease);
}

.player-backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(10px);
}

.player-container {
  position: relative;
  width: 90vw;
  max-width: 1100px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.35s var(--ease-spring);
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.player-title {
  font-size: 1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 50px);
}

#video-player {
  width: 100%;
  display: block;
  max-height: 75vh;
  background: #000;
}

/* ── CONFIRM MODAL ─────────────────────────────────────────── */
.confirm-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.confirm-modal.open {
  display: flex;
  animation: fadeIn 0.2s var(--ease);
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
}

.confirm-dialog {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.3s var(--ease-spring);
}

.confirm-icon {
  font-size: 40px;
  margin-bottom: 16px;
}

.confirm-dialog h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-dialog p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
  word-break: break-all;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.confirm-actions .btn {
  min-width: 100px;
}

/* ── TOAST ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  animation: toastIn 0.4s var(--ease-spring);
  max-width: 380px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

.toast.out {
  animation: toastOut 0.3s var(--ease) forwards;
}

/* ── ANIMATIONS ────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

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

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

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner {
    padding: 0 16px;
  }

  .logo h1 {
    font-size: 1.2rem;
  }

  .video-count {
    display: none;
  }

  .btn-primary svg {
    display: none;
  }

  #library {
    padding: 16px 16px 40px;
  }

  .library-header {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: unset;
  }

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

  .dropzone {
    padding: 32px 16px;
  }

  .player-container {
    width: 95vw;
    border-radius: var(--radius-md);
  }
}

@media (max-width: 480px) {
  .video-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .player-container {
    width: 100vw;
    height: 100vh;
    max-width: unset;
    border-radius: 0;
  }

  .player-header {
    padding: 12px 16px;
  }

  #video-player {
    max-height: unset;
    height: calc(100vh - 56px);
  }
}

/* ── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ── UTILITY ───────────────────────────────────────────────── */
.hidden {
  display: none !important;
}
