/* =============================================================================
   Myflix — shared styles
   ============================================================================= */

:root {
  --bg: #141414;
  --bg-elevated: #1f1f1f;
  --accent: #e50914;
  --accent-hover: #f6121d;
  --text: #ffffff;
  --text-muted: #b3b3b3;
  --card-radius: 6px;
  --nav-height: 68px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

[hidden] { display: none !important; }

/* ---------------------------------------------------------------------------
   Login gate
   --------------------------------------------------------------------------- */

#login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(rgba(0,0,0,.65), rgba(0,0,0,.85)),
    linear-gradient(135deg, #2b0a0a, #141414 60%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(0,0,0,.75);
  border-radius: 8px;
  padding: 48px 40px;
}

.login-card h1 {
  color: var(--accent);
  font-size: 32px;
  letter-spacing: 1px;
  margin: 0 0 28px;
  text-align: center;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin: 16px 0 6px;
}

.login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 4px;
  border: 1px solid #333;
  background: #333;
  color: var(--text);
  font-size: 15px;
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  background: #454545;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.login-card button[type="submit"]:hover { background: var(--accent-hover); }
.login-card button[type="submit"]:disabled { opacity: .6; cursor: default; }

.login-error {
  min-height: 20px;
  color: #ff6b6b;
  font-size: 13px;
  margin-top: 14px;
}

/* ---------------------------------------------------------------------------
   Nav bar
   --------------------------------------------------------------------------- */

.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  background: linear-gradient(rgba(20,20,20,.95), rgba(20,20,20,.4));
  z-index: 100;
}

.navbar .brand {
  color: var(--accent);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
}

.navbar .nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar input[type="search"] {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid #444;
  background: rgba(0,0,0,.6);
  color: var(--text);
  width: 220px;
}

.navbar a.nav-link, .navbar button.nav-link {
  background: none;
  border: 1px solid #555;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 14px;
}

.navbar a.nav-link:hover, .navbar button.nav-link:hover { border-color: var(--text); }

/* ---------------------------------------------------------------------------
   Hero
   --------------------------------------------------------------------------- */

.hero {
  position: relative;
  height: 78vh;
  min-height: 420px;
  background-size: cover;
  background-position: center 20%;
  display: flex;
  align-items: flex-end;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, var(--bg) 2%, rgba(20,20,20,0) 42%),
    linear-gradient(to right, rgba(20,20,20,.85) 0%, rgba(20,20,20,0) 60%);
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 0 40px 64px;
  max-width: 620px;
}

.hero-content h1 {
  font-size: 48px;
  margin: 0 0 16px;
  text-shadow: 2px 2px 6px rgba(0,0,0,.6);
}

.hero-meta {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.hero-content p {
  font-size: 16px;
  line-height: 1.5;
  color: #eee;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 1px 1px 4px rgba(0,0,0,.6);
}

.hero-buttons { margin-top: 20px; display: flex; gap: 12px; }

.btn {
  padding: 11px 26px;
  border-radius: 4px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-play { background: #fff; color: #000; }
.btn-play:hover { background: rgba(255,255,255,.8); }

.btn-info { background: rgba(109,109,110,.7); color: #fff; }
.btn-info:hover { background: rgba(109,109,110,.5); }

/* ---------------------------------------------------------------------------
   Rows of movie cards
   --------------------------------------------------------------------------- */

.rows-wrap { padding: 24px 0 80px; }

.row-block { margin-bottom: 38px; }

.row-title {
  padding: 0 40px;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 10px;
}

.row-track {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 40px 24px;
  scroll-behavior: smooth;
}

.row-track::-webkit-scrollbar { height: 0; }

.card {
  flex: 0 0 220px;
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
  background: var(--bg-elevated);
  position: relative;
}

.card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.card:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  z-index: 5;
}

.card-title-bar {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}

.empty-state {
  padding: 80px 40px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state a { color: var(--accent); font-weight: 700; }

/* ---------------------------------------------------------------------------
   Detail modal
   --------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: 8px;
}

.modal-backdrop {
  width: 100%;
  aspect-ratio: 16/9;
  background-color: #000;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(20,20,20,.8);
  border: none;
  color: #fff;
  font-size: 18px;
}

.modal-body { padding: 24px 32px 32px; }
.modal-body h2 { margin: 0 0 10px; font-size: 26px; }
.modal-body .hero-meta { margin-bottom: 14px; }
.modal-body p { line-height: 1.6; color: #ddd; }

/* ---------------------------------------------------------------------------
   Watch page
   --------------------------------------------------------------------------- */

.watch-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #000;
}

.watch-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
}

.watch-topbar .back-link { font-size: 15px; color: var(--text-muted); }
.watch-topbar .back-link:hover { color: #fff; }
.watch-topbar h2 { margin: 0; font-size: 18px; }

.player-frame-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 24px;
}

.player-frame-inner {
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 16/9;
}

.player-frame-inner iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------------------------------------------------------------------------
   Admin page
   --------------------------------------------------------------------------- */

.admin-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 32px) 24px 80px;
}

.admin-wrap h1 { font-size: 26px; margin-bottom: 4px; }
.admin-wrap .subtitle { color: var(--text-muted); margin-bottom: 32px; }

.admin-form {
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 28px;
  margin-bottom: 48px;
}

.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="file"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid #333;
  background: #2a2a2a;
  color: var(--text);
  font-size: 14px;
}

.form-row textarea { min-height: 90px; resize: vertical; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 11px 24px;
  border-radius: 4px;
  border: none;
  font-weight: 700;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; }

.btn-secondary {
  background: transparent;
  border: 1px solid #555;
  color: var(--text);
  padding: 11px 24px;
  border-radius: 4px;
}

.form-status { font-size: 13px; color: var(--text-muted); }
.form-status.error { color: #ff6b6b; }
.form-status.success { color: #4caf50; }

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.admin-table th, table.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #2c2c2c;
}

table.admin-table th { color: var(--text-muted); font-weight: 600; }

table.admin-table img.thumb-sm {
  width: 80px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 4px;
}

.row-actions button {
  background: none;
  border: 1px solid #555;
  color: var(--text);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  margin-right: 6px;
}
.row-actions button:hover { border-color: var(--text); }
.row-actions button.danger:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------------------
   Admin tabs
   --------------------------------------------------------------------------- */

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid #2c2c2c;
}

.admin-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  padding: 10px 4px;
  margin-right: 24px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.admin-tab-btn:hover { color: var(--text); }

.admin-tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Grouped image-upload fields in the admin form
   --------------------------------------------------------------------------- */

.image-field-group {
  border: 1px solid #2c2c2c;
  border-radius: 6px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.image-field-group .group-heading {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.image-field-group .group-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.image-field-group .form-row:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------------------
   Admin search tab
   --------------------------------------------------------------------------- */

.admin-search-row { margin-bottom: 20px; }

.admin-search-row input[type="search"] {
  width: 100%;
  max-width: 420px;
  padding: 11px 14px;
  border-radius: 4px;
  border: 1px solid #333;
  background: #2a2a2a;
  color: var(--text);
  font-size: 14px;
}

/* ---------------------------------------------------------------------------
   Posters page
   --------------------------------------------------------------------------- */

/* Posters live in the same horizontally-scrolling .row-track rows as the
   browse page cards (see "Rows" above) — this just fixes every poster to the
   same contained size, whatever the source image's own dimensions are. */
.row-track .poster-card { flex: 0 0 170px; }

.poster-card {
  cursor: pointer;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: var(--bg-elevated);
  transition: transform .2s ease, box-shadow .2s ease;
}

.poster-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
}

.poster-card:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}

.poster-title-bar {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 700px) {
  .navbar { padding: 0 16px; }
  .navbar input[type="search"] { width: 120px; }
  .hero-content { padding: 0 16px 40px; }
  .hero-content h1 { font-size: 32px; }
  .row-title, .row-track { padding-left: 16px; padding-right: 16px; }
  .card { flex-basis: 150px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .row-track .poster-card { flex: 0 0 120px; }
}
