/* Import Google font - Poppins */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif; /* Changed to Poppins for a modern look */
}

body {
  min-height: 100vh;
  background: rgb(37, 46, 61);
  color: #fff;
}

body,
.container,
.video-controls,
.video-timer,
.options {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Branding & Logo Styling --- */
.branding {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.logo {
  height: 70px; /* Adjusted logo size */
}

/* --- Main Video Container --- */
.main-container {
  display: flex;
  flex-direction: column; /* Stack video and buttons vertically */
  align-items: center;
  gap: 20px;
  width: 100%;
  padding: 20px;
  padding-top: 100px; /* Add padding to avoid overlap with logos */
}

.container {
  width: 100%;
  max-width: 900px;
  user-select: none;
  overflow: hidden;
  border-radius: 8px; /* Softer border radius */
  background: #000;
  aspect-ratio: 16 / 9;
  position: relative; /* Changed from absolute */
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.container.fullscreen {
  max-width: 100%;
  width: 100%;
  height: 100vh;
  border-radius: 0px;
}

/* --- Video Controls Wrapper --- */
.wrapper {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -15px;
  z-index: 1;
  opacity: 0;
  transition: all 0.13s ease;
}

.container.show-controls .wrapper {
  opacity: 1;
  bottom: 0;
}

.wrapper::before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: calc(100% + 35px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  pointer-events: none;
  z-index: -1;
}

/* --- Video Timeline & Progress Bar --- */
.video-timeline {
  height: 7px;
  width: 100%;
  cursor: pointer;
}

.video-timeline .progress-area {
  height: 3px;
  position: relative;
  background: rgba(255, 255, 255, 0.5);
}

.progress-area span {
  position: absolute;
  left: 50%;
  top: -25px;
  font-size: 13px;
  color: #fff;
  pointer-events: none;
  transform: translateX(-50%);
  display: none; /* Hide by default */
}

.progress-area .progress-bar {
  width: 0%;
  height: 100%;
  position: relative;
  background: #2289ff;
}

.progress-bar::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 13px;
  width: 13px;
  background: #2289ff;
  border-radius: 50%;
  display: none; /* Hide by default */
}

.video-timeline:hover .progress-bar::before,
.video-timeline:hover .progress-area span {
  display: block;
}

/* --- Video Control Buttons & Options --- */
.wrapper .video-controls {
  padding: 5px 20px 10px;
}

.video-controls .options {
  width: 100%;
}

.video-controls .options:first-child {
  justify-content: flex-start;
}

.video-controls .options:last-child {
  justify-content: flex-end;
}

.options button {
  height: 40px;
  width: 40px;
  font-size: 19px;
  border: none;
  cursor: pointer;
  background: none;
  color: #efefef;
  border-radius: 3px;
  transition: all 0.3s ease;
}

.options button :where(i, span) {
  height: 100%;
  width: 100%;
  line-height: 40px;
}

.options button:hover :where(i, span) {
  color: #fff;
}

.options button:active :where(i, span) {
  transform: scale(0.9);
}

.options button span {
  font-size: 23px;
}

/* --- Volume Slider --- */
.options input[type="range"] {
  height: 4px;
  margin-left: 3px;
  max-width: 75px;
  accent-color: #2289ff; /* Changed accent color to blue */
  cursor: pointer;
}

.options .video-timer {
  color: #efefef;
  margin-left: 15px;
  font-size: 14px;
}

.video-timer .separator {
  margin: 0 5px;
  font-size: 16px;
  font-family: "Open sans";
}

/* --- Playback Speed Options --- */
.playback-content {
  display: flex;
  position: relative;
}

.playback-content .speed-options {
  position: absolute;
  list-style: none;
  left: -30px;
  bottom: 40px;
  width: 95px;
  overflow: hidden;
  opacity: 0;
  border-radius: 4px;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  transition: opacity 0.13s ease;
}

.playback-content .speed-options.show {
  opacity: 1;
  pointer-events: auto;
}

.speed-options li {
  cursor: pointer;
  color: #000;
  font-size: 14px;
  margin: 2px 0;
  padding: 5px 0 5px 15px;
  transition: all 0.1s ease;
}

.speed-options li:where(:first-child, :last-child) {
  margin: 0px;
}

.speed-options li:hover {
  background: #dfdfdf;
}

.speed-options li.active {
  color: #fff;
  background: #3e97fd;
}

.container video {
  width: 100%;
}

/* --- Action Buttons (Upload, Play, etc.) --- */
.action-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px; /* Space between buttons */
  flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
  width: 100%;
  max-width: 900px;
}

.button-64 {
  align-items: center;
  background-image: linear-gradient(144deg, #af40ff, #5b42f3 50%, #00ddeb);
  border: 0;
  border-radius: 8px;
  box-shadow: rgba(151, 65, 252, 0.2) 0 15px 30px -5px;
  box-sizing: border-box;
  color: #ffffff;
  display: flex;
  font-family: Phantomsans, sans-serif;
  font-size: 18px; /* Adjusted font size */
  justify-content: center;
  line-height: 1em;
  max-width: 100%;
  min-width: 140px;
  padding: 3px;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
  cursor: pointer;
}

.button-64:active,
.button-64:hover {
  outline: 0;
}

.button-64 span {
  background-color: rgb(5, 6, 45);
  padding: 12px 18px; /* Adjusted padding */
  border-radius: 6px;
  width: 100%;
  height: 100%;
  transition: 300ms;
}

.button-64:hover span {
  background: none;
}

#upload-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

#uploading-message, #loading-message {
  color: white;
  font-size: 16px;
}

#loading-message {
    display: none;
}

/* --- Sidebar Styling --- */
.sidebar {
  display: none; /* Initially hide the sidebar */
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: absolute;
  top: 50%;
  right: 20px; /* Position relative to the viewport or a parent */
  transform: translateY(-50%);
  background-color: rgba(40, 40, 50, 0.85);
  backdrop-filter: blur(5px);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  z-index: 20;
}

.sidebar.show {
  display: flex;
}

#product-list {
  list-style-type: none;
  padding-left: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2x2 grid */
  gap: 10px;
}

#product-list li img {
  width: 100px;
  height: 100px;
  border-radius: 6px;
  transition: transform 0.2s ease;
}

#product-list li img:hover {
  transform: scale(1.05);
}

#close-button {
  position: absolute;
  top: 5px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  color: #fff;
  cursor: pointer;
}


/* --- Media Queries for Responsiveness --- */
@media (min-width: 768px) {
  .button-64 {
    font-size: 20px;
    min-width: 196px;
  }
}

@media screen and (max-width: 540px) {
  .wrapper .video-controls {
    padding: 3px 10px 7px;
  }
  .options input,
  .progress-area span {
    display: none !important;
  }
  .options button {
    height: 30px;
    width: 30px;
    font-size: 17px;
  }
  .options .video-timer {
    margin-left: 5px;
  }
  .video-timer .separator {
    font-size: 14px;
    margin: 0 2px;
  }
  .options button :where(i, span) {
    line-height: 30px;
  }
  .options button span {
    font-size: 21px;
  }
  .options .video-timer,
  .progress-area span,
  .speed-options li {
    font-size: 12px;
  }
  .playback-content .speed-options {
    width: 75px;
    left: -30px;
    bottom: 30px;
  }
  .speed-options li {
    margin: 1px 0;
    padding: 3px 0 3px 10px;
  }
  .right .pic-in-pic {
    display: none;
  }
  .sidebar {
      width: calc(100% - 40px);
      right: 20px;
      top: 100px;
      transform: translateY(0);
  }
  #product-list {
      grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  }
}

/* --- NEW: Loading Message Overlay Styling --- */
#loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  display: none; /* Hidden by default */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  border-radius: 8px; /* Match container's border-radius */
  font-size: 1.2em;
  text-align: center;
}

#loading-overlay.show {
  display: flex; /* Show when the 'show' class is added */
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 4px solid #fff;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

#loading-text {
  padding: 0 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --- Media Queries for Responsiveness --- */
@media (min-width: 768px) {
  .button-64 {
    font-size: 20px;
    min-width: 196px;
  }
}

@media screen and (max-width: 540px) {
  /* ... (your existing mobile styles) ... */

  .right .pic-in-pic {
    display: none;
  }
  .sidebar {
      width: calc(100% - 40px);
      right: 20px;
      top: 100px;
      transform: translateY(0);
  }
  #product-list {
      grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  }
}
