/* ============================
   GLOBAL RESET & BODY
============================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
}

body {
  background: radial-gradient(circle at top, #220000, #000);
  color: #fff;
  min-height: 100vh;
}

/* ============================
   HEADER
============================ */
header {
  padding: 20px;
  text-align: center;
  font-size: 24px;
  letter-spacing: 2px;
  color: #ff2a2a;
  text-shadow: 0 0 15px #ff0000;
}

/* ============================
   NAVBAR
============================ */
.navbar {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  background: #000;
  overflow-x: auto;
  border-bottom: 1px solid #222;
}

.navbar button {
  padding: 8px 18px;
  border-radius: 30px;
  border: none;
  background: #111;
  color: #ccc;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.navbar button:hover,
.navbar button.active {
  background: #e50914;
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 0 10px #ff0000;
}

/* ============================
   GRID & VIDEO CARDS
============================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 20px;
}

.card {
  position: relative;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: scale(1.05);
  z-index: 10;
  box-shadow: 0 0 15px #ff0000;
}

.card video,
.card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}

.card video:not([src]) {
  opacity: 0;
}

/* Loading & error states */
.card.loading::after,
.card.error::after {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  z-index: 3;
  text-shadow: 1px 1px 2px black;
}

.card.loading::after {
  content: "Loading video...";
  color: white;
}

.card.error::after {
  content: "Failed to load";
  color: #ff6b6b;
}

/* Play icon overlay */
.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  background: rgba(0,0,0,0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 5;
  pointer-events: none;
}

.card:hover .play-icon {
  opacity: 1;
}

.play-icon::after {
  content: "▶";
  margin-left: 3px;
}

/* ============================
   MODAL
============================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 90%;
  max-width: 1000px;
  position: relative;
  animation: zoom 0.3s ease;
}

@keyframes zoom {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal video {
  width: 100%;
  border-radius: 12px;
  background: black;
}

#closeModal {
  position: absolute;
  top: -35px;
  right: 0;
  font-size: 30px;
  color: red;
  cursor: pointer;
}

.actions {
  margin-top: 10px;
  text-align: right;
}

#downloadBtn {
  padding: 8px 14px;
  background: red;
  color: white;
  border-radius: 20px;
  text-decoration: none;
  transition: background 0.3s ease;
}

#downloadBtn:hover {
  background: #ff4b4b;
}

/* ============================
   LOADER
============================ */
#loader {
  position: fixed;
  inset: 0;
  background: black;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  transition: 0.4s;
}

#loader.hide {
  opacity: 0;
  pointer-events: none;
}

.loader-box {
  text-align: center;
}

.ring {
  width: 60px;
  height: 60px;
  border: 4px solid #300000;
  border-top: 4px solid red;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.card .filename {
  position: relative;
  background: none;
  color: #fff;
  text-align: center;
  margin-top: 4px;
  font-size: 14px;
}