/* ============================================================
   Base Styles
   ============================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background-color: #0e0e10;
  color: #efeff1;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ============================================================
   Login Screen
   ============================================================ */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0e0e10 70%);
}

.login-box {
  text-align: center;
  padding: 3rem;
  background: #18181b;
  border-radius: 12px;
  border: 1px solid #2f2f35;
  max-width: 400px;
  width: 90%;
}

.login-box h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: #bf94ff;
}

.login-box p {
  color: #adadb8;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

#login-form {
  display: flex;
  gap: 0.5rem;
}

#password-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: #1f1f23;
  border: 1px solid #2f2f35;
  border-radius: 6px;
  color: #efeff1;
  font-size: 1rem;
  outline: none;
}

#password-input:focus {
  border-color: #bf94ff;
}

#login-form button {
  padding: 0.75rem 1.5rem;
  background: #bf94ff;
  color: #0e0e10;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

#login-form button:hover {
  background: #a77bff;
}

.error {
  color: #eb0400;
  margin-top: 1rem;
  font-size: 0.85rem;
}

/* ============================================================
   Header
   ============================================================ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: #18181b;
  border-bottom: 1px solid #2f2f35;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.2rem;
  color: #bf94ff;
}

#stream-count {
  color: #adadb8;
  font-size: 0.85rem;
}

/* ============================================================
   Stream List
   ============================================================ */
#stream-list-section {
  padding: 2rem;
}

#stream-list-section h2 {
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
}

.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.stream-card {
  background: #18181b;
  border: 1px solid #2f2f35;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.stream-card:hover {
  border-color: #bf94ff;
  transform: translateY(-2px);
}

.stream-card-preview {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.stream-card-title {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.3rem;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.02em;
}

.live-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: #eb0400;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.live-badge.header-live {
  position: static;
  margin-left: auto;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.stream-card-info {
  padding: 0.75rem 1rem;
}

.stream-card-info .stream-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.stream-card-info .stream-meta {
  color: #adadb8;
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

.no-streams {
  text-align: center;
  padding: 4rem 1rem;
  color: #53535f;
  font-size: 1.1rem;
}

/* ============================================================
   Player Section
   ============================================================ */
#player-section {
  padding: 0;
  max-width: 1200px;
  margin: 0 auto;
}

/* VOD player takes full page — feels like a separate page */
#player-section.vod-player-full {
  max-width: 100%;
  padding: 0;
}

#player-section.vod-player-full .player-header {
  padding: 0.75rem 1.5rem;
  background: #18181b;
}

#player-section.vod-player-full .player-container {
  max-width: 1200px;
  margin: 1.5rem auto 0;
}

#player-section.vod-player-full .player-overlay-bottom {
  padding: 0 0.5rem 0.5rem;
}

.player-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem 0.75rem;
}

.btn-back {
  padding: 0.4rem 0.8rem;
  background: #2f2f35;
  color: #efeff1;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.btn-back:hover {
  background: #3f3f46;
}

.player-header h2 {
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   Video Player Container (Twitch-style)
   ============================================================ */
.player-container {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  cursor: none;
}

.player-container:hover {
  cursor: default;
}

.player-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Top overlay bar (stream info) */
.player-overlay-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.player-container:hover .player-overlay-top {
  opacity: 1;
}

.player-overlay-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-viewer-count {
  color: #efeff1;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.player-overlay-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-quality,
.player-fps {
  color: #adadb8;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* Bottom controls bar (Twitch-style) */
.player-overlay-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem;
  background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, transparent 100%);
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s;
}

.player-container:hover .player-overlay-bottom {
  opacity: 1;
}

.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
}

.ctrl-btn {
  background: none;
  border: none;
  color: #efeff1;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ============================================================
   Settings Panel
   ============================================================ */
.settings-wrapper {
  position: relative;
}

.settings-panel {
  position: absolute;
  bottom: 40px;
  right: 0;
  background: #1f1f23;
  border: 1px solid #2f2f35;
  border-radius: 6px;
  min-width: 280px;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.settings-header {
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid #2f2f35;
  color: #bf94ff;
}

.settings-option {
  padding: 0.75rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.option-label {
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.option-badge {
  background: #bf94ff;
  color: #0e0e10;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  text-transform: uppercase;
}

.option-desc {
  font-size: 0.7rem;
  color: #adadb8;
  line-height: 1.3;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 40px;
  height: 22px;
  cursor: pointer;
  align-self: flex-end;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #53535f;
  border-radius: 11px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #efeff1;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #bf94ff;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.time-indicator {
  color: #eb0400;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.4rem;
  margin-left: 0.25rem;
  background: rgba(235, 4, 0, 0.15);
  border-radius: 3px;
}

.time-display {
  color: #efeff1;
  font-size: 0.75rem;
  font-family: 'Consolas', monospace;
  padding: 0.2rem 0.4rem;
  margin-left: 0.25rem;
}

/* Seek bar */
.seek-bar-wrapper {
  position: absolute;
  bottom: 100%;
  left: 0.5rem;
  right: 0.5rem;
  padding: 0.5rem;
  z-index: 15;
}

.seek-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #53535f;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #bf94ff;
  cursor: pointer;
  transition: transform 0.1s;
}

.seek-bar::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

.seek-bar::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #bf94ff;
  cursor: pointer;
  border: none;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.volume-slider {
  width: 0;
  opacity: 0;
  transition: width 0.2s, opacity 0.2s;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #53535f;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-control:hover .volume-slider {
  width: 60px;
  opacity: 1;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #efeff1;
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #efeff1;
  cursor: pointer;
  border: none;
}

.player-bitrate-display {
  color: #adadb8;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
}

/* Loading spinner */
.player-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(191, 148, 255, 0.2);
  border-top-color: #bf94ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error overlay */
.player-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  text-align: center;
}

.error-content {
  background: rgba(14, 14, 16, 0.95);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid #2f2f35;
}

.error-content p {
  color: #adadb8;
  margin: 1rem 0;
}

.error-content button {
  padding: 0.5rem 1.5rem;
  background: #bf94ff;
  color: #0e0e10;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.error-content button:hover {
  background: #a77bff;
}

/* ============================================================
   Statistics Panel
   ============================================================ */
.stats-panel {
  background: #18181b;
  border-top: 1px solid #2f2f35;
  padding: 1.25rem 1.5rem;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.stats-header h3 {
  font-size: 0.95rem;
  color: #efeff1;
}

.btn-toggle-stats {
  background: none;
  border: 1px solid #2f2f35;
  color: #adadb8;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-toggle-stats:hover {
  border-color: #bf94ff;
  color: #bf94ff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: #1f1f23;
  border-radius: 6px;
  padding: 0.75rem;
  text-align: center;
  border: 1px solid #2f2f35;
}

.stat-label {
  display: block;
  color: #adadb8;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.stat-value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: #efeff1;
}

/* ============================================================
   Bitrate Chart
   ============================================================ */
.chart-container {
  background: #1f1f23;
  border-radius: 6px;
  padding: 1rem;
  border: 1px solid #2f2f35;
}

.chart-container h4 {
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: #adadb8;
}

#bitrate-chart {
  width: 100%;
  height: 150px;
}

/* ============================================================
   Header Settings Button
   ============================================================ */
.btn-settings-header {
  background: none;
  border: none;
  color: #adadb8;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-settings-header:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #efeff1;
}

/* ============================================================
   Settings Dropdown
   ============================================================ */
.settings-dropdown {
  position: absolute;
  top: 48px;
  right: 1.5rem;
  background: #1f1f23;
  border: 1px solid #2f2f35;
  border-radius: 6px;
  min-width: 220px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.settings-dropdown-item {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #efeff1;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}

.settings-dropdown-item:hover {
  background: rgba(191, 148, 255, 0.1);
  color: #bf94ff;
}

.settings-dropdown-item svg {
  flex-shrink: 0;
}

/* ============================================================
   Modal (Stream Keys)
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  background: #18181b;
  border: 1px solid #2f2f35;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #2f2f35;
}

.modal-header h2 {
  font-size: 1.1rem;
  color: #bf94ff;
}

.modal-close {
  background: none;
  border: none;
  color: #adadb8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
}

.modal-close:hover {
  color: #efeff1;
}

.modal-body {
  padding: 1.25rem;
}

/* ============================================================
   VOD Section
   ============================================================ */
#vod-section {
  padding: 2rem;
}

#vod-section h2 {
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
}

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

.vod-card {
  background: #18181b;
  border: 1px solid #2f2f35;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.vod-card:hover {
  border-color: #bf94ff;
  transform: translateY(-2px);
}

.vod-card-thumb {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.vod-card-badge {
  position: absolute;
  bottom: 0.4rem;
  right: 0.4rem;
  background: rgba(0, 0, 0, 0.8);
  color: #efeff1;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
}

.vod-card-info {
  padding: 0.75rem 1rem;
}

.vod-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vod-card-meta {
  color: #adadb8;
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

.no-vods {
  text-align: center;
  padding: 3rem 1rem;
  color: #53535f;
  font-size: 0.95rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
  header {
    padding: 0.75rem 1rem;
  }

  #stream-list-section,
  #player-section .player-header {
    padding: 1rem;
  }

  .stats-panel {
    padding: 1rem;
  }

  .stream-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .player-overlay-top,
  .player-overlay-bottom {
    display: none !important;
  }
}
