:root {
  --bg: #0b1020;
  --panel: #121a2b;
  --panel-2: #1b263d;
  --text: #edf2ff;
  --muted: #9aa9c7;
  --primary: #4f8cff;
  --primary-dark: #2d6ae6;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  background: linear-gradient(180deg, #0b1020 0%, #111827 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: rgba(11, 16, 32, 0.9);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
}

nav {
  display: flex;
  gap: 18px;
}

nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.layout {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.player-shell {
  position: relative;
  background: #000;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px var(--shadow);
  /* Limit height on small viewports so the player doesn't overflow */
  max-height: calc(100vh - 140px);
}

#mainVideo {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

#mainFrame {
  display: none;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  object-fit: contain;
}

.empty-player {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.25rem;
}

.sidebar {
  background: rgba(18, 26, 43, 0.88);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

.sidebar h2 {
  margin-top: 0;
  margin-bottom: 18px;
}

.video-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.video-item {
  display: flex;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.video-item:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 140, 255, 0.7);
}

.video-thumb {
  width: 128px;
  min-width: 128px;
  height: 72px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1f2937, #0f172a);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.video-meta h3 {
  margin: 0;
  font-size: 1rem;
}

.video-meta span {
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-wrap {
  max-width: 700px;
  margin: 30px auto;
  padding: 0 18px;
}

.admin-form {
  background: rgba(18, 26, 43, 0.88);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.admin-video-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.admin-video-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(14, 22, 34, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.delete-btn {
  background: #b91c1c;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.hidden {
  display: none;
}

.admin-form h1 {
  margin: 0;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
}

.admin-form input,
.admin-form textarea,
.admin-form button {
  font: inherit;
}

.admin-form input,
.admin-form textarea {
  width: 100%;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
}

.admin-form button {
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}

.status-message {
  min-height: 20px;
  margin: 0;
  color: #8ae6b8;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .main-panel {
    order: 1;
  }

  /* Make the player use the full width and limit height on narrow screens */
  .player-shell {
    aspect-ratio: 16 / 9;
    max-height: calc(60vh);
  }
}

@media (max-width: 500px) {
  .topbar {
    padding: 14px 16px;
  }

  nav {
    gap: 10px;
    font-size: 0.95rem;
  }

  .video-item {
    flex-direction: column;
  }

  .video-thumb {
    width: 100%;
    min-width: 100%;
    height: 160px;
  }

  /* Ensure the player remains usable on very small devices */
  .player-shell {
    border-radius: 12px;
    max-height: calc(55vh);
  }

  #mainVideo, #mainFrame {
    height: 100%;
    width: 100%;
  }
}
