:root {
  --theme-color: #6366f1;
}
/* Default Styles */
html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  color: #fff;
  overflow: hidden;
  font-family: "Inter", sans-serif;
}
section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

#video-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

video {
  width: 100%;
  height: 100%;
  z-index: 1;
  object-fit: contain;
}

#video-wrapper:fullscreen {
  width: 100vw;
  height: 100vh;
}

video:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
}

#video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  padding: 0.625em;
  transition: all 0.3s ease;
  z-index: 10;
}

#video-controls::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.25);
}

.controls-bottom,
.controls-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.controls-top {
  position: fixed;
  top: 0.5em;
  right: 0.5em;
}

.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  gap: 0.625em;
}

.controls-left {
  position: relative;
}

.control-button {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5em;
  margin: 0 0.3125em;
  opacity: 0.8;
  transition: opacity 0.3s;
  z-index: 15;
  position: relative;
}

.control-button:hover {
  opacity: 1;
}

.control-button:active {
  transform: scale(0.95);
}

.control-button::before {
  content: "";
  position: absolute;
  top: -0.25em;
  right: -0.25em;
  bottom: -0.25em;
  left: -0.25em;
}

.control-button.active {
  color: var(--theme-color);
}

.control-button svg {
  width: 1.5em;
  height: 1.5em;
  fill: white;
}

.control-button.active svg {
  fill: var(--theme-color);
}

/* Big Play Button */
#big-play-button {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  width: 5em;
  height: 5em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
}

#big-play-button svg {
  width: 3em;
  height: 3em;
  fill: white;
}

/* Progress Bar*/
.progress-container {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.625em;
  z-index: 12;
}

.progress-bar-wrapper {
  position: relative;
  flex: 1;
  height: 0.625em;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  border-radius: 0.3125em;
}

.progress-bar-wrapper::before {
  content: "";
  position: absolute;
  top: -0.5em;
  bottom: -0.5em;
  left: 0;
  right: 0;
  z-index: 0;
}

.progress {
  position: absolute;
  height: 100%;
  background: var(--theme-color);
  width: 0;
  border-radius: 0.3125em;
  pointer-events: none;
}

.progress-thumb {
  position: absolute;
  width: 1em;
  height: 1em;
  background: var(--theme-color);
  border-radius: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  left: 0;
  box-shadow: 0 0 0.25em rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.buffer {
  position: absolute;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  width: 0;
  border-radius: 0.3125em;
  pointer-events: none;
}

.current-time,
.duration {
  color: white;
  font-size: 0.75em;
  min-width: 2.8125em;
  text-align: center;
}

.time-tooltip {
  position: absolute;
  bottom: 100%;
  transform: translateX(-50%);
  background-color: rgba(28, 28, 28, 0.9);
  color: white;
  padding: 0.25em 0.5em;
  border-radius: 0.25em;
  font-size: 0.75em;
  display: none;
  margin-bottom: 0.375em;
  pointer-events: none;
  white-space: nowrap;
  z-index: 20;
}

/* Volume Control */
.volume-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.volume-control {
  position: relative;
  display: flex;
  align-items: center;
  width: 0;
  height: 24px;
  overflow: hidden;
  transition: width 0.3s ease;
}

.volume-button:hover + .volume-control,
.volume-control:hover {
  width: 100px;
}

.volume-slider {
  width: 100%;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  outline: none;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 2;
}

.volume-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--theme-color);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  margin-top: -2px;
}

.volume-slider::-moz-range-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--theme-color);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  margin-top: -2px;
}

.volume-level {
  position: absolute;
  height: 4px;
  width: 0%;
  background: var(--theme-color);
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
}

/* Menus */
.settings-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  width: 200px;
  max-width: 90%;
  max-height: calc(100vh - 100px);
  background: rgba(28, 28, 28, 0.9);
  border-radius: 0.5em;
  padding: 0.5em;
  display: flex;
  min-width: 160px;
  z-index: 20;
  margin-bottom: 5px;
  overflow-y: auto;
  flex-direction: column;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.settings-menu button {
  display: flex;
  width: 100%;
  padding: 0.5em 1em;
  background: none;
  border: none;
  color: white;
  text-align: left;
  cursor: pointer;
  font-size: 0.75em;
  border-radius: 0.25em;
  align-items: center;
}

.settings-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.settings-menu button.active {
  color: var(--theme-color);
}

.settings-button-container {
  position: relative;
}

.settings-category {
  width: 100%;
}

.settings-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.5em 1em;
  color: white;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s;
  gap: 0.5em;
}

.settings-item.active {
  color: #1d9bf0;
}

.settings-item span {
  flex: 1;
}

.settings-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.settings-back {
  border-radius: none !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.settings-back:hover {
  background-color: transparent !important;
}

/* Subtitles */
#subtitle-search-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 19;
}

#subtitle-search-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 450px;
  max-width: 90vw;
  background-color: rgba(15, 18, 30, 0.95);
  border-radius: 0.5em;
  border: 1px solid rgba(99, 102, 241, 0.2);
  z-index: 20;
  overflow: hidden;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.subtitle-search-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  background-color: rgba(15, 18, 30, 1);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  padding-right: 8px;
  border-radius: 4px;
  background-color: rgba(25, 30, 45, 0.8);
  padding: 2px 8px;
}

.search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  background-color: transparent;
  border: none;
}

.search-icon svg {
  width: 18px;
  height: 18px;
}

.subtitle-search-input {
  flex: 1;
  padding: 6px 2px;
  border: none;
  background-color: transparent;
  color: white;
  font-size: 14px;
  width: 100%;
}

.subtitle-search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.subtitle-search-input:focus {
  outline: none;
}

.subtitle-search-close {
  background: none;
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  cursor: pointer;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.subtitle-search-close svg {
  width: 20px;
  height: 20px;
}

#subtitle-search-results {
  flex: 1;
  overflow-y: auto;
  background-color: rgba(10, 15, 25, 0.95);
  scrollbar-width: thin;
  padding-bottom: 8px;
}

#subtitle-search-results p {
  font-size: 0.75rem;
  padding: 1em 1em 0.5em 1em;
  margin: 0;
}

.subtitle-search-result {
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background-color 0.15s ease;
}

.subtitle-search-result:hover {
  background-color: rgba(99, 102, 241, 0.1);
}

.result-text {
  flex: 1;
  color: white;
  line-height: 1.3;
  font-size: 13px;
}

.result-time {
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  background: rgba(99, 102, 241, 0.3);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 10px;
  min-width: auto;
  white-space: nowrap;
  font-weight: 500;
}

mark {
  background-color: transparent;
  color: rgba(99, 102, 241, 1);
  font-weight: 500;
  padding: 0;
}

#hub-captions {
  position: absolute;
  bottom: 2em;
  left: 0;
  right: 0;
  text-align: center;
  transition: bottom 0.3s ease;
  z-index: 5;
  padding: 0 20%;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

#video-controls:not(.hidden) ~ #hub-captions {
  bottom: 5em;
}

.hub-cue {
  color: white;
  padding: 0.125em 0.5em;
  border-radius: 0.25em;
  display: inline-block;
  margin-bottom: 0.25em;
  text-shadow: 0px 0px 2px #000, 0px 0px 4px #000;
  max-width: 90%;
  font-size: 0.875rem;
}

/* Loading screen */
#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  background: linear-gradient(-45deg, #2d0b5a, #1b3f93);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
  z-index: 100;
  flex-direction: column;
  gap: 2em;
}

#loading img {
  width: 200px;
  opacity: 0;
  transform: scale(0.8);
  animation: logoFadeInZoom 2s ease-out forwards,
    logoPulse 1.5s ease-in-out 2.5s infinite;
}

#loading .loading-progress-bar {
  width: 250px;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

#loading .loading-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background-color: white;
  animation: progressFill 1s ease-out forwards,
    progressPulse 1.5s ease-in-out 1s infinite;
}

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

/* Toast */
.toast-container {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  padding: 0.5em;
}

.toast {
  background-color: #333;
  color: #fff;
  padding: 0.25em 0.5em;
  border-radius: 0.5em;
  font-size: 0.75em;
}

.toast.error {
  background-color: #ff0000;
}

.toast.info {
  background-color: #0000ff;
}

.toast.success {
  background-color: #00ff00;
}

.toast.warning {
  background-color: #ffff00;
}

@keyframes logoFadeInZoom {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes logoPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes progressFill {
  0% {
    width: 0;
  }
  100% {
    width: 100%;
  }
}

@keyframes progressPulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
  100% {
    opacity: 1;
  }
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@media screen and (max-width: 600px) {
  #video-controls::before {
    background: rgba(0, 0, 0, 0.5);
  }
  #hub-captions {
    bottom: 1em;
  }
  .hub-cue {
    font-size: 0.75rem;
  }
  #big-play-button {
    width: 3em;
    height: 3em;
  }
  .settings-item {
    padding: 0.25em;
  }
  .settings-item svg {
    width: 1.25em;
    height: 1.25em;
  }
  .settings-item span {
    font-size: 0.675rem;
  }
}

@media screen and (max-width: 360px) {
  #big-play-button {
    display: none;
  }
}
