/* ═══════════════════════════════════════════
   Tesla Video Player — Modern Dark UI
   Glassmorphism + Gradient Accents
   Tesla touchscreen optimized
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #06060b;
  --bg-secondary: #0d0d14;
  --bg-surface: rgba(255, 255, 255, 0.04);
  --bg-surface-solid: #14141e;
  --bg-hover: rgba(255, 255, 255, 0.07);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --text-primary: #eeeef3;
  --text-secondary: #6b6b82;
  --text-tertiary: #44445a;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.25);
  --accent-subtle: rgba(139, 92, 246, 0.08);
  --gradient-accent: linear-gradient(135deg, #8b5cf6, #6366f1);
  --gradient-surface: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.1);
  --highlight-bg: rgba(139, 92, 246, 0.2);
  --highlight-text: #c4b5fd;
  --error: #f43f5e;
  --success: #10b981;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Subtle background pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(139, 92, 246, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(99, 102, 241, 0.05), transparent);
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }

/* ─── Layout ────────────────────────────── */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ─── Header ────────────────────────────── */
.app-header {
  text-align: center;
  margin-bottom: 40px;
  padding: 8px 0;
}

.app-logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 6px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

/* ─── Search Box ────────────────────────── */
.search-box {
  position: relative;
  width: 100%;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.search-input-wrapper:focus-within .search-icon {
  color: var(--accent);
}

.search-input {
  width: 100%;
  padding: 16px 50px 16px 52px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 400;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
}

.search-input:focus {
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.08), var(--shadow-md);
  background: rgba(255, 255, 255, 0.06);
}

.search-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.search-clear {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  border-radius: 50%;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.search-clear:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ─── Search Dropdown ───────────────────── */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-surface-solid);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 440px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  animation: dropdownIn 0.2s var(--transition-fast);
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--bg-hover);
}

.search-result-item.selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gradient-accent);
  border-radius: 0 2px 2px 0;
}

.result-thumb {
  width: 110px;
  height: 62px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.search-result-item:hover .result-thumb {
  opacity: 0.9;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  color: var(--text-primary);
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.result-meta > span:not(:last-child)::after {
  content: '\00b7';
  margin-left: 6px;
  color: var(--text-tertiary);
}

.result-channel {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.result-duration {
  white-space: nowrap;
  color: var(--accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.result-views {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ─── Search Highlight ──────────────────── */
.search-result-item mark {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  border-radius: 3px;
  padding: 1px 3px;
}

.search-empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ─── Video Player Section ──────────────── */
.player-section {
  margin-top: 32px;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  animation: playerIn 0.4s var(--transition-base);
}

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

.player-wrapper {
  position: relative;
  background: #000;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-canvas-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  background: #000;
}

.player-canvas-wrapper video,
.player-canvas-wrapper ogvjs,
.player-canvas-wrapper canvas {
  width: 100% !important;
  max-height: 70vh;
  display: block;
}

/* ─── Fullscreen Mode ──────────────────── */
.player-section:fullscreen,
.player-section:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  background: #000;
  border: none;
  border-radius: 0;
}

.player-section:fullscreen .player-wrapper,
.player-section:-webkit-full-screen .player-wrapper {
  flex: 1;
  min-height: 0;
}

.player-section:fullscreen .player-canvas-wrapper,
.player-section:-webkit-full-screen .player-canvas-wrapper {
  width: 100%;
  height: 100%;
  align-items: center;
}

.player-section:fullscreen .player-canvas-wrapper video,
.player-section:fullscreen .player-canvas-wrapper ogvjs,
.player-section:fullscreen .player-canvas-wrapper canvas,
.player-section:-webkit-full-screen .player-canvas-wrapper video,
.player-section:-webkit-full-screen .player-canvas-wrapper ogvjs,
.player-section:-webkit-full-screen .player-canvas-wrapper canvas {
  max-height: 100% !important;
  height: 100%;
  object-fit: contain;
}

.player-section:fullscreen .player-controls,
.player-section:-webkit-full-screen .player-controls {
  padding: 8px 16px;
  background: rgba(13, 13, 20, 0.92);
  backdrop-filter: blur(16px);
  border-top: none;
  flex-shrink: 0;
}

.player-section:fullscreen .player-info,
.player-section:-webkit-full-screen .player-info {
  padding: 6px 20px 8px;
  background: rgba(13, 13, 20, 0.92);
  flex-shrink: 0;
}

.player-section:fullscreen .player-title,
.player-section:-webkit-full-screen .player-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-section:fullscreen .player-channel,
.player-section:-webkit-full-screen .player-channel {
  font-size: 12px;
  margin-top: 2px;
}

/* ─── Player Loading ────────────────────── */
.player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.player-loading span {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--error);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.player-error span {
  font-size: 14px;
  font-weight: 500;
}

.btn-retry {
  padding: 10px 28px;
  background: var(--gradient-accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.btn-retry:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

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

/* ─── Player Controls ───────────────────── */
.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-surface-solid);
  border-top: 1px solid var(--border);
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  min-width: 40px;
  min-height: 40px;
}

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

.ctrl-btn:active {
  transform: scale(0.92);
}

.ctrl-time {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 90px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.ctrl-progress-wrapper {
  flex: 1;
  padding: 0 4px;
}

.ctrl-progress {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: height var(--transition-fast);
}

.ctrl-progress:hover {
  height: 6px;
}

.ctrl-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
  transition: transform var(--transition-fast);
}

.ctrl-progress:hover::-webkit-slider-thumb {
  transform: scale(1.2);
}

.ctrl-progress::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.4);
}

.ctrl-quality {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
}

.ctrl-quality:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.ctrl-quality option {
  background: var(--bg-surface-solid);
  color: var(--text-primary);
}

/* ─── Player Info ───────────────────────── */
.player-info {
  padding: 14px 20px 16px;
  border-top: 1px solid var(--border);
}

.player-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.2px;
}

.player-channel {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 400;
}

/* ─── Scrollbar ─────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

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

/* ─── Selection ─────────────────────────── */
::selection {
  background: var(--accent-glow);
  color: var(--text-primary);
}

/* ─── Responsive ────────────────────────── */
@media (max-width: 600px) {
  .app-container {
    padding: 20px 14px;
  }

  .app-header {
    margin-bottom: 28px;
  }

  .app-logo {
    font-size: 20px;
  }

  .search-input {
    font-size: 16px;
    padding: 14px 46px;
  }

  .result-thumb {
    width: 90px;
    height: 51px;
  }

  .result-meta > span:not(:last-child)::after {
    display: none;
  }

  .result-meta {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .player-controls {
    gap: 6px;
    padding: 8px 12px;
  }

  .ctrl-time {
    font-size: 11px;
    min-width: 75px;
  }

  .player-title {
    font-size: 15px;
  }
}

/* ─── Footer ────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 32px 0 8px;
  margin-top: 48px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.2px;
  border-top: 1px solid var(--border);
}

/* ─── Large Screens ─────────────────────── */
@media (min-width: 1200px) {
  .app-container {
    max-width: 1000px;
  }
}
