* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
  padding: 20px;
}

body.dark-mode {
  background-color: #121212;
  color: #e0e0e0;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

/* Container for search and dark mode toggle */
.search-toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 20px auto;
  flex-wrap: wrap;
  justify-content: center;
}

.search-box {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 12px 20px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 50px;
  outline: none;
  background-color: white;
  color: #333;
}

body.dark-mode .search-box input {
  background-color: #2a2a2a;
  color: #e0e0e0;
  border-color: #555;
}

/* Dark Mode Toggle Button */
.toggle-btn {
  background: #333;
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, transform 0.2s;
}

.toggle-btn:hover {
  transform: scale(1.05);
}

.toggle-btn.dark-mode {
  background: #ffcc00;
  color: #121212;
}

/* Responsive: Stack on small screens */
@media (max-width: 500px) {
  .search-toggle-container {
    flex-direction: column;
    align-items: stretch;
  }

  .toggle-btn {
    order: -1;
    align-self: center;
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
  max-width: 1400px;
  margin: 0 auto;
}

.video-item {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s, box-shadow 0.3s;
  cursor: pointer;
}

.video-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

body.dark-mode .video-item {
  background: #1e1e1e;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 */
  background-size: cover;
  background-position: center;
  overflow: hidden; /* Prevents content from spilling out */
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70px;
  height: 70px;
  background: rgba(232, 17, 42, 0.9); /* YouTube red */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  z-index: 10;
  cursor: pointer;
}

.play-overlay i {
  font-size: 1.8rem;
  color: white; /* White icon for contrast */
}

.video-title {
  padding: 15px;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.pagination button {
  background: #eee;
  border: 1px solid #ccc;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}

body.dark-mode .pagination button {
  background: #333;
  color: #e0e0e0;
  border-color: #555;
}

.pagination button.active {
  background: #0066ff;
  color: white;
  border-color: #0066ff;
}

.pagination button:hover:not(.active) {
  background: #ddd;
}

/* Loading Spinner */
.loader {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #0066ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

body.dark-mode .spinner {
  border-top: 4px solid #4dabf7;
  border-bottom: 4px solid #333;
}

/* Lightbox Modal */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  width: 90%;
  max-width: 900px;
  aspect-ratio: 16 / 9;
}

.close-btn {
  position: absolute;
  top: -50px;
  right: 0;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  background: none;
  border: none;
}

.share-btn {
  position: absolute;
  top: -50px;
  left: 0;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  background: #25c25c;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lightbox iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
}

/* Responsive Design */
@media (max-width: 600px) {
  h1 {
    font-size: 2rem;
  }

  .gallery {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .pagination button {
    padding: 6px 10px;
    font-size: 0.9rem;
  }

  .search-toggle-container {
    gap: 10px;
  }
}