/* monFlix TV — 10-foot UI, dark theme, D-pad optimized */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a0a;
  --surface: #151515;
  --surface2: #1e1e1e;
  --text: #f0f0f0;
  --text2: #888;
  --accent: #a855f7;
  --blue: #3b82f6;
  --green: #22c55e;
  --orange: #f97316;
  --red: #ef4444;
  --cyan: #06b6d4;
  --yellow: #eab308;
  --focus-glow: 0 0 0 3px var(--accent), 0 0 20px rgba(168,85,247,0.4);
  --radius: 12px;
  --font: -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 20px;
  overflow: hidden;
}

/* Focus — critical for D-pad */
*:focus {
  outline: none;
  box-shadow: var(--focus-glow);
  border-radius: var(--radius);
  z-index: 10;
}

.focusable:focus, .nav-item:focus, button:focus, input:focus, .poster-card:focus, .stream-row:focus {
  box-shadow: var(--focus-glow);
}

/* Sidebar */
#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 220px;
  background: var(--surface);
  display: flex; flex-direction: column;
  padding: 20px 0;
  z-index: 100;
  border-right: 1px solid #222;
}

.sidebar-logo {
  font-size: 28px; font-weight: 800;
  color: var(--accent);
  padding: 10px 24px 30px;
  letter-spacing: -0.5px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  color: var(--text2);
  text-decoration: none;
  font-size: 18px; font-weight: 500;
  transition: all 0.15s;
  border-radius: 0;
}

.nav-item:focus, .nav-item:hover {
  color: var(--text);
  background: rgba(168,85,247,0.1);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(168,85,247,0.08);
  border-left: 3px solid var(--accent);
}

.nav-icon { font-size: 22px; width: 28px; text-align: center; }

/* Main content */
#content {
  margin-left: 220px;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px 40px;
  scroll-behavior: smooth;
}

/* Headings */
.view-title {
  font-size: 32px; font-weight: 700;
  margin-bottom: 24px;
}

.section-title {
  font-size: 22px; font-weight: 600;
  margin: 30px 0 16px;
  color: var(--text);
}

/* Poster grid */
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}

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

.poster-card:focus, .poster-card:hover {
  transform: scale(1.08);
  box-shadow: var(--focus-glow);
}

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

.poster-card .poster-info {
  padding: 10px 12px;
}

.poster-card .poster-title {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.poster-card .poster-meta {
  font-size: 13px; color: var(--text2);
  margin-top: 4px;
  display: flex; gap: 8px; align-items: center;
}

.poster-card .poster-meta .star { color: var(--yellow); }

/* Horizontal scroll row */
.poster-row {
  display: flex; gap: 16px;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 10px;
  scroll-snap-type: x mandatory;
}

.poster-row .poster-card {
  flex: 0 0 170px;
  scroll-snap-align: start;
}

/* Search */
.search-bar {
  display: flex; gap: 12px;
  margin-bottom: 24px;
}

.search-bar input {
  flex: 1;
  background: var(--surface2);
  border: 2px solid #333;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 22px;
  padding: 14px 20px;
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-glow);
}

.search-bar button {
  background: var(--accent);
  color: white;
  border: none; border-radius: var(--radius);
  padding: 14px 28px;
  font-size: 18px; font-weight: 600;
  cursor: pointer;
}

/* Explore infinite menu (Miller columns) */

.explore-column {
  flex: 0 0 270px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid #222;
  height: 100%;
}

.explore-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.explore-item:hover, .explore-item:focus {
  background: rgba(168,85,247,0.08);
  box-shadow: var(--focus-glow);
}

.explore-item-icon { flex-shrink: 0; font-size: 20px; }

.explore-item-text { flex: 1; min-width: 0; }

.explore-item-label {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.explore-item-meta {
  display: flex; gap: 6px;
  font-size: 12px; color: var(--text2);
}

.explore-search {
  display: flex; gap: 12px; margin-bottom: 16px;
}

.explore-search input {
  flex: 1;
  background: var(--surface2);
  border: 2px solid #333;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 20px;
  padding: 12px 18px;
}

.explore-search input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan), 0 0 16px rgba(6,182,212,0.3);
}

.explore-suggestions {
  position: absolute;
  top: 70px; left: 40px; right: 40px;
  background: var(--surface);
  border: 1px solid #333;
  border-radius: var(--radius);
  max-height: 400px; overflow-y: auto;
  z-index: 50;
}

.explore-suggestion {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #222;
}

.explore-suggestion:focus, .explore-suggestion:hover {
  background: rgba(6,182,212,0.1);
}

.explore-suggestion img {
  width: 36px; height: 52px;
  object-fit: cover; border-radius: 4px;
}

.explore-suggestion .sg-icon {
  width: 36px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  border-radius: 4px;
  background: var(--surface2);
}

.explore-back {
  position: absolute;
  top: 16px; left: 16px;
  background: rgba(255,255,255,0.1);
  border: none; border-radius: 50%;
  width: 44px; height: 44px;
  color: white; font-size: 22px;
  cursor: pointer;
  z-index: 20;
}

/* Detail view */
.detail-container {
  display: flex; gap: 40px;
  max-width: 1200px;
}

.detail-poster {
  width: 280px; flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-poster img {
  width: 100%; display: block;
}

.detail-info { flex: 1; }

.detail-title {
  font-size: 36px; font-weight: 700;
  margin-bottom: 8px;
}

.detail-meta {
  display: flex; gap: 16px; align-items: center;
  font-size: 18px; color: var(--text2);
  margin-bottom: 16px;
}

.detail-meta .star { color: var(--yellow); font-size: 20px; }

.detail-description {
  font-size: 17px; color: var(--text2);
  line-height: 1.6;
  margin-bottom: 20px;
}

.detail-tags {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 12px;
}

.tag {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}

.tag-genre { background: rgba(34,197,94,0.15); color: var(--green); }
.tag-director { background: rgba(239,68,68,0.15); color: var(--red); }
.tag-actor { background: rgba(249,115,22,0.15); color: var(--orange); }

.tag:focus { box-shadow: var(--focus-glow); }

/* Streams */
.streams-title {
  font-size: 22px; font-weight: 600;
  margin: 30px 0 16px;
}

.stream-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.stream-row:focus, .stream-row:hover {
  background: var(--surface2);
  box-shadow: var(--focus-glow);
}

.stream-quality {
  font-size: 14px; font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  min-width: 60px; text-align: center;
}

.q-4k { background: rgba(168,85,247,0.2); color: var(--accent); }
.q-1080 { background: rgba(59,130,246,0.2); color: var(--blue); }
.q-720 { background: rgba(34,197,94,0.2); color: var(--green); }
.q-other { background: rgba(136,136,136,0.2); color: var(--text2); }

.stream-title {
  flex: 1;
  font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.stream-size { font-size: 14px; color: var(--text2); min-width: 70px; }
.stream-seeds { font-size: 14px; color: var(--green); min-width: 50px; }

.stream-instant {
  font-size: 12px; font-weight: 700;
  color: var(--yellow); background: rgba(234,179,8,0.15);
  padding: 3px 8px; border-radius: 4px;
}

/* Season/episode picker */
.season-picker {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}

.season-btn, .episode-btn {
  padding: 8px 16px;
  background: var(--surface2);
  border: 2px solid #333;
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

.season-btn.active, .episode-btn.active {
  border-color: var(--accent);
  background: rgba(168,85,247,0.15);
  color: var(--accent);
}

.season-btn:focus, .episode-btn:focus {
  box-shadow: var(--focus-glow);
}

/* Player overlay */
#player-overlay {
  position: fixed; inset: 0;
  background: black;
  z-index: 1000;
  display: flex; flex-direction: column;
}

#player-overlay.hidden { display: none; }

#video-player {
  flex: 1;
  width: 100%; height: 100%;
  background: black;
}

#player-bar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
}

#player-back {
  background: rgba(255,255,255,0.15);
  border: none; border-radius: 8px;
  color: white; font-size: 16px;
  padding: 10px 20px;
  cursor: pointer;
}

#player-title {
  font-size: 20px; font-weight: 600;
  color: white;
}

/* Settings */
.settings-group {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  max-width: 700px;
}

.settings-group h3 {
  font-size: 20px; margin-bottom: 16px;
  color: var(--accent);
}

.setting-row {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 14px;
}

.setting-row label {
  min-width: 160px;
  font-size: 16px; color: var(--text2);
}

.setting-row input, .setting-row select {
  flex: 1;
  background: var(--surface2);
  border: 2px solid #333;
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  padding: 10px 14px;
}

.setting-row input:focus, .setting-row select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-glow);
}

.btn {
  padding: 12px 28px;
  border: none; border-radius: 8px;
  font-size: 17px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}

.btn:focus { box-shadow: var(--focus-glow); }
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--surface2); color: var(--text); }

/* Favorites */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 60vh; gap: 16px;
  color: var(--text2);
}

.empty-state .icon { font-size: 64px; opacity: 0.3; }
.empty-state .msg { font-size: 20px; }

/* Loading */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; color: var(--text2); font-size: 18px;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Badge */
.badge-history {
  font-size: 11px; font-weight: 700;
  color: var(--green);
  border: 1px solid var(--green);
  padding: 2px 6px; border-radius: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
