/* General styles */
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #fff;
  transition: all 0.3s ease;
}

/* Hide scrollbar for a cleaner look */
::-webkit-scrollbar {
  width: 0;
  background: transparent;
}

/* Loading animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

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

@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 200px 0;
  }
}

@keyframes skeletonPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Skeleton Loading Styles */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px 0;
  grid-column: 1 / -1;
}

.skeleton-card {
  background: #181818;
  border-radius: 12px;
  overflow: hidden;
  animation: fadeIn 0.6s ease-out;
  width: 100%;
  max-width: 320px;
}

.skeleton-card:nth-child(1) { animation-delay: 0.1s; }
.skeleton-card:nth-child(2) { animation-delay: 0.2s; }
.skeleton-card:nth-child(3) { animation-delay: 0.3s; }
.skeleton-card:nth-child(4) { animation-delay: 0.4s; }
.skeleton-card:nth-child(5) { animation-delay: 0.5s; }
.skeleton-card:nth-child(6) { animation-delay: 0.6s; }

.skeleton-thumb {
  width: 100%;
  height: 180px;
  background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-meta {
  padding: 12px;
}

.skeleton-title {
  width: 80%;
  height: 16px;
  background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
  background-size: 200px 100%;
  border-radius: 4px;
  margin-bottom: 8px;
  animation: shimmer 1.5s infinite;
  animation-delay: 0.2s;
}

.skeleton-subtitle {
  width: 60%;
  height: 12px;
  background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
  background-size: 200px 100%;
  border-radius: 4px;
  animation: shimmer 1.5s infinite;
  animation-delay: 0.4s;
}

/* Main container for the player and up-next list */
#playerView {
  display: none !important;
  /* Hidden by default */
  padding: 24px;
  margin: 0 auto;
  gap: 24px;
  animation: fadeIn 0.5s ease-out;
  max-width: 1200px;
}

/* Back Button Styles */
.back-button-container {
  margin-bottom: 20px;
  animation: slideInFromLeft 0.4s ease-out;
}

.back-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.back-btn:hover {
  background: rgba(255, 107, 107, 0.2);
  border-color: #ff6b6b;
  transform: translateX(-5px);
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.2);
}

.back-btn i {
  transition: transform 0.3s ease;
}

.back-btn:hover i {
  transform: translateX(-3px);
}

/* Responsive layout: side-by-side on desktop, stacked on mobile */
@media (min-width: 1024px) {
  #playerView.active {
    display: block !important;
  }
}

@media (max-width: 1023px) {
  #playerView.active {
    display: block !important;
  }
}

/* Player section */
.player-section {
  flex-grow: 1;
  min-width: 0;
  /* Prevents flexbox overflow */
  animation: slideInFromLeft 0.6s ease-out;
}

.player-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  /* 16:9 Aspect Ratio */
  background-color: #000;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.player-frame:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

.player-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
  transition: opacity 0.3s ease;
}

.video-details {
  animation: fadeIn 0.7s ease-out 0.2s both;
}

.video-details .title-large {
  font-size: 20px;
  font-weight: 600;
  margin-top: 12px;
  transition: color 0.3s ease;
}

.video-details .title-large:hover {
  color: #ff6b6b;
}

.video-details .byline {
  font-size: 14px;
  color: #aaa;
  margin-top: 8px;
  transition: color 0.3s ease;
}

.video-details .byline:hover {
  color: #fff;
}

/* Up Next playlist section */
.up-next-section {
  width: 100%;
  margin-top: 24px;
  animation: slideInFromRight 0.6s ease-out 0.1s both;
}

@media (min-width: 1024px) {
  .up-next-section {
    width: 380px;
    flex-shrink: 0;
    margin-top: 0;
  }
}

.up-next-section h2 {
  transition: all 0.3s ease;
}

.up-next-section h2:hover {
  color: #ff6b6b;
  transform: translateX(5px);
}

.up-next-item {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateX(20px);
  animation: slideInFromRight 0.4s ease-out forwards;
}

.up-next-item:nth-child(1) { animation-delay: 0.1s; }
.up-next-item:nth-child(2) { animation-delay: 0.2s; }
.up-next-item:nth-child(3) { animation-delay: 0.3s; }
.up-next-item:nth-child(4) { animation-delay: 0.4s; }
.up-next-item:nth-child(5) { animation-delay: 0.5s; }

.up-next-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateX(5px) scale(1.02);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.up-next-item img {
  width: 160px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.up-next-item:hover img {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.up-next-meta .title {
  font-size: 14px;
  font-weight: 500;
  color: #f1f1f1;
  transition: color 0.3s ease;
}

.up-next-item:hover .up-next-meta .title {
  color: #ff6b6b;
}

.up-next-meta .sub {
  font-size: 12px;
  color: #aaa;
  margin-top: 4px;
  transition: color 0.3s ease;
}

.up-next-item:hover .up-next-meta .sub {
  color: #fff;
}

/* All Videos Section */
.all-videos-section {
  animation: fadeIn 0.8s ease-out 0.3s both;
}

.all-videos-section h2 {
  transition: all 0.3s ease;
}

.all-videos-section h2:hover {
  color: #ff6b6b;
  transform: translateX(5px);
}

.all-videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.all-videos-item {
  background: #181818;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeIn 0.4s ease-out forwards;
}

.all-videos-item:nth-child(1) { animation-delay: 0.1s; }
.all-videos-item:nth-child(2) { animation-delay: 0.2s; }
.all-videos-item:nth-child(3) { animation-delay: 0.3s; }
.all-videos-item:nth-child(4) { animation-delay: 0.4s; }
.all-videos-item:nth-child(5) { animation-delay: 0.5s; }
.all-videos-item:nth-child(6) { animation-delay: 0.6s; }

.all-videos-item:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  background: #222;
}

.all-videos-item.current-video {
  border: 2px solid #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

.all-videos-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.all-videos-item:hover img {
  transform: scale(1.05);
}

.all-videos-item .meta {
  padding: 8px;
}

.all-videos-item .meta .title {
  font-size: 12px;
  font-weight: 500;
  color: #f1f1f1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s ease;
}

.all-videos-item:hover .meta .title {
  color: #ff6b6b;
}

.all-videos-item .meta .sub {
  font-size: 10px;
  color: #aaa;
  margin-top: 4px;
  transition: color 0.3s ease;
}

.all-videos-item:hover .meta .sub {
  color: #fff;
}

/* Video grid styles */
.discover-container {
  padding: 16px;
  animation: fadeIn 0.6s ease-out;
}

/* Search Bar Styles */
.search-container {
  margin-bottom: 24px;
  animation: slideInFromLeft 0.5s ease-out;
}

.search-bar {
  position: relative;
  max-width: 500px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 16px 50px 16px 50px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  color: #fff;
  font-size: 16px;
  outline: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.search-input:focus {
  border-color: #ff6b6b;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

.search-input::placeholder {
  color: #aaa;
  transition: color 0.3s ease;
}

.search-input:focus::placeholder {
  color: #ccc;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  font-size: 18px;
  transition: color 0.3s ease;
  pointer-events: none;
  z-index: 2;
}

.search-input:focus ~ .search-icon,
.search-input:not(:placeholder-shown) ~ .search-icon {
  color: #ff6b6b;
}

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #aaa;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background: rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
  transform: translateY(-50%) scale(1.1);
}

.discover-container h1 {
  animation: slideInFromLeft 0.5s ease-out;
  transition: all 0.3s ease;
}

.discover-container h1:hover {
  color: #ff6b6b;
  transform: translateX(10px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px 0;
}

.thumb-card {
  background: #181818;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s ease;
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  animation: scaleIn 0.6s ease-out forwards;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 320px;
}

.thumb-card:nth-child(1) { animation-delay: 0.1s; }
.thumb-card:nth-child(2) { animation-delay: 0.2s; }
.thumb-card:nth-child(3) { animation-delay: 0.3s; }
.thumb-card:nth-child(4) { animation-delay: 0.4s; }
.thumb-card:nth-child(5) { animation-delay: 0.5s; }
.thumb-card:nth-child(6) { animation-delay: 0.6s; }

.thumb-card:hover {
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  background: #222;
}

.thumb-card .thumb {
  position: relative;
  overflow: hidden;
}

.thumb-card .thumb img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  transition: all 0.4s ease;
}

.thumb-card:hover .thumb img {
  transform: scale(1.1);
}

.thumb-card .thumb::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.thumb-card:hover .thumb::after {
  transform: translateX(100%);
}

.thumb-card .meta {
  padding: 12px 8px;
  transition: all 0.3s ease;
}

.thumb-card:hover .meta {
  background: rgba(255, 107, 107, 0.1);
}

.thumb-card .meta .title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  color: #f1f1f1;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s ease;
  max-height: 2.6em;
}

.thumb-card:hover .meta .title {
  color: #ff6b6b;
}

.thumb-card .meta .sub {
  font-size: 12px;
  color: #aaa;
  line-height: 1.2;
  transition: all 0.3s ease;
}

.thumb-card:hover .meta .sub {
  color: #fff;
}

/* Loading and Error states */
.loading-state, .error-state, .empty-state, .no-results-state {
  animation: fadeIn 0.5s ease-out;
  text-align: center;
  padding: 40px;
  grid-column: 1 / -1;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.empty-state i {
  font-size: 64px;
  color: #555;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 24px;
  color: #fff;
  margin: 0;
}

.empty-state p {
  font-size: 16px;
  color: #aaa;
  margin: 0;
}

.no-results-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.no-results-state i {
  font-size: 64px;
  color: #555;
  margin-bottom: 16px;
}

.no-results-state h3 {
  font-size: 24px;
  color: #fff;
  margin: 0;
}

.no-results-state p {
  font-size: 16px;
  color: #aaa;
  margin: 0;
  text-align: center;
}

.no-results-state .search-term {
  color: #ff6b6b;
  font-weight: 600;
}

.loading-state p {
  animation: pulse 2s infinite;
}

.error-state button {
  transition: all 0.3s ease;
}

.error-state button:hover {
  background: #ff5252 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
}

/* Smooth transitions for view switching */
#discoverView {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#discoverView.hiding {
  opacity: 0;
  transform: translateY(-20px);
}

#playerView {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#playerView.showing {
  opacity: 1;
  transform: translateY(0);
}