/* Fontes hospedadas junto com o app (funcionam offline, sem depender do Google Fonts) */
@font-face {
  font-family: 'Bebas Neue';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/bebas-neue-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/inter-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 800; font-display: swap;
  src: url('../fonts/inter-800.woff2') format('woff2');
}

:root {
  --bg: #0A0A0C;
  --surface: #17171C;
  --surface-solid: #1F1F26;
  --border: rgba(255,255,255,0.09);
  --text: #F6F6F8;
  --text-dim: #B0AFB8;
  --text-faint: #74737C;
  --accent: #E5241D;
  --accent-2: #FF4B3E;
  --accent-dim: #E5241D26;
  --gold: #F2C94C;
  --green: #46D369;
  --radius: 8px;
  --radius-sm: 6px;
  --font-display: 'Bebas Neue', Impact, 'Arial Narrow', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

[data-theme="claro"] {
  --bg: #F4F3F5;
  --surface: #FFFFFF;
  --surface-solid: #FFFFFF;
  --border: rgba(10,10,12,0.10);
  --text: #17171C;
  --text-dim: #57555F;
  --text-faint: #96949E;
  --accent: #D81920;
  --accent-2: #E5241D;
  --accent-dim: #D8192015;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body { padding-top: env(safe-area-inset-top); padding-bottom: calc(64px + env(safe-area-inset-bottom)); min-height: 100vh; }

h1, h2, h3 { font-family: var(--font-display); margin: 0; font-weight: 400; letter-spacing: 0.5px; }

button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px; padding-top: calc(13px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 22px; letter-spacing: 1px; color: var(--text); }
.topbar-spacer { flex: 1; }
.icon-btn { background: none; border: none; color: var(--text); font-size: 20px; padding: 4px 8px; line-height: 1; border-radius: var(--radius-sm); }
.icon-btn:active { background: var(--surface); }

/* Views */
#app { max-width: 560px; margin: 0 auto; padding: 16px; padding-bottom: 32px; }
.view { display: none; }
.view.active { display: block; animation: fade-in .2s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

/* Hero (home) */
.hero { position: relative; padding: 10px 2px 26px; overflow: hidden; }
.hero::before {
  content: ''; position: absolute; top: -60px; left: -40px; width: 260px; height: 200px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.28; filter: blur(10px); pointer-events: none;
}
.hero-kicker { position: relative; font-size: 46px; margin: 0; color: var(--text); line-height: 0.95; }
.hero-sub { position: relative; margin: 6px 0 0; color: var(--text-dim); font-size: 14px; font-weight: 500; }

.block { margin-bottom: 26px; }
.block:empty, .block.hidden { display: none; }
.block-title { font-size: 16px; color: var(--text); font-weight: 700; margin-bottom: 12px; font-family: var(--font-body); letter-spacing: 0.1px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-sub { color: var(--text-faint); font-size: 14px; margin-top: 6px; }

/* ---------- Linhas horizontais (estilo Netflix "continuar assistindo") ---------- */
.card-list.row-scroll {
  display: flex; flex-direction: row; gap: 12px; overflow-x: auto;
  scroll-snap-type: x proximity; padding: 2px 2px 8px; margin: 0 -2px;
  scrollbar-width: none;
}
.card-list.row-scroll::-webkit-scrollbar { display: none; }

.row-card { flex: 0 0 128px; scroll-snap-align: start; background: none; border: none; padding: 0; text-align: left; }
.row-poster-wrap {
  position: relative; width: 128px; height: 192px; border-radius: var(--radius);
  overflow: hidden; background: var(--surface-solid);
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}
.row-poster { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-poster-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 40px; color: rgba(255,255,255,0.92);
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.row-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,0.28); }
.row-progress-fill { height: 100%; background: var(--accent); }
.row-play-btn {
  position: absolute; left: 50%; bottom: -2px; transform: translate(-50%, 50%);
  width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--bg);
  background: var(--accent); color: #fff; font-size: 14px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(229,36,29,0.45);
}
.row-play-btn:active { transform: translate(-50%, 50%) scale(0.9); }
.row-badge {
  position: absolute; top: 6px; right: 6px; background: rgba(10,10,12,0.75); border-radius: 50%;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.row-title { margin: 9px 0 0; font-weight: 700; font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 11.5px; color: var(--text-dim); margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-streaming { font-size: 11px; color: var(--gold); margin: 3px 0 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Cards verticais (histórico, resultados alternativos) ---------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; align-items: center; text-align: left; width: 100%;
}
.card-poster { width: 56px; height: 84px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-solid); flex-shrink: 0; }
.card-poster-placeholder {
  width: 56px; height: 84px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 22px; color: #fff;
}
.card-body { flex: 1; min-width: 0; }
.card-title { font-family: var(--font-body); font-weight: 700; font-size: 15px; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 13px; color: var(--text-dim); margin: 0 0 6px; }

/* ---------- Grade de busca (estilo Netflix) ---------- */
.search-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.search-tile { background: none; border: none; padding: 0; text-align: left; }
.search-poster-wrap {
  position: relative; width: 100%; aspect-ratio: 2 / 3; border-radius: var(--radius);
  overflow: hidden; background: var(--surface-solid); box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}
.search-poster { width: 100%; height: 100%; object-fit: cover; display: block; }
.search-poster-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 46px; color: rgba(255,255,255,0.92);
}
.search-rating {
  position: absolute; top: 8px; left: 8px; background: rgba(10,10,12,0.75); color: var(--gold);
  font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
}
.search-tile-title { margin: 8px 0 0; font-weight: 700; font-size: 14px; }
.search-tile-meta { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }

.progress-track { height: 6px; background: var(--surface-solid); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; }

.card-actions { display: flex; gap: 8px; align-items: center; }

.btn { border: none; border-radius: var(--radius-sm); padding: 12px 18px; font-size: 14.5px; font-weight: 700; }
.btn-primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; box-shadow: 0 6px 16px rgba(229,36,29,0.35); }
.btn-secondary { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); width: 100%; margin-bottom: 10px; }
.btn-text { background: none; color: var(--text-dim); width: 100%; padding: 10px; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 999px; }
.btn:active { opacity: 0.8; transform: scale(0.98); }
.btn:disabled { opacity: .4; }

.status-pill { font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: var(--accent-dim); color: var(--accent-2); white-space: nowrap; border: 1px solid transparent; }
.status-pill.streaming-pill { background: var(--surface-solid); color: var(--gold); border: 1px solid var(--border); }

/* Search */
.search-bar { margin-bottom: 14px; }
.search-bar input, .settings-group input[type="url"], .settings-group input[type="text"] {
  width: 100%; padding: 13px 15px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px;
}
.search-bar input:focus, .settings-group input[type="url"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-status { color: var(--text-dim); font-size: 14px; padding: 8px 2px; min-height: 20px; }

/* Details / Serie view */
.detail-hero { position: relative; margin: -16px -16px 0; }
.detail-backdrop { width: 100%; height: 210px; object-fit: cover; display: block; }
.detail-backdrop-placeholder { width: 100%; height: 210px; }
.detail-hero::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 90px;
  background: linear-gradient(to bottom, transparent, var(--bg));
}
.detail-header { display: flex; gap: 14px; padding: 0 16px; margin-top: -52px; position: relative; z-index: 1; }
.detail-poster { width: 104px; height: 156px; border-radius: var(--radius); object-fit: cover; border: 3px solid var(--bg); background: var(--surface-solid); box-shadow: 0 8px 20px rgba(0,0,0,0.5); }
.detail-poster-placeholder { display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 36px; color: #fff; }
.detail-title-block { padding-top: 56px; }
.detail-title { font-size: 26px; margin: 0; letter-spacing: 0.5px; }
.detail-original { color: var(--text-faint); font-size: 13px; margin: 3px 0 0; font-family: var(--font-body); }
.detail-meta-row { display: flex; gap: 10px; flex-wrap: wrap; color: var(--text-dim); font-size: 13px; margin: 14px 0; font-weight: 600; }
.detail-meta-row span:first-child { color: var(--gold); }
.detail-synopsis { color: var(--text-dim); font-size: 14.5px; line-height: 1.55; margin: 0 0 18px; }
.already-badge { display: flex; align-items: center; gap: 8px; padding: 13px 15px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--accent); margin-bottom: 16px; font-size: 14px; }

.serie-status-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.progress-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.progress-box h4 { font-family: var(--font-body); font-size: 12.5px; color: var(--text-dim); margin: 0 0 10px; font-weight: 700; letter-spacing: 0.3px; }
.progress-box .ep-line { font-family: var(--font-display); font-size: 22px; margin-bottom: 12px; letter-spacing: 0.4px; }
.progress-pct { color: var(--text-dim); font-size: 13px; margin-top: 8px; font-weight: 600; }

.season-block { margin-bottom: 20px; }
.season-title { font-size: 15px; font-weight: 700; margin: 0 0 8px; font-family: var(--font-body); }
.ep-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.ep-row:last-child { border-bottom: none; }
.ep-check { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.ep-row[data-assistido="1"] .ep-check { color: var(--accent-2); }
.ep-label { flex: 1; color: var(--text); }
.ep-label.watched { color: var(--text-dim); }
.ep-next-tag { font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; padding: 2px 9px; }

.notes-box textarea, #fim-serie-anotacao {
  width: 100%; min-height: 90px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 11px; font-size: 14px; resize: vertical;
}
.notes-box textarea:focus, #fim-serie-anotacao:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.history-year { font-family: var(--font-display); font-size: 22px; margin: 22px 0 10px; color: var(--text); letter-spacing: 0.5px; }
.history-year:first-child { margin-top: 0; }
.history-card { display: flex; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--border); text-align: left; width: 100%; background: none; border-top: none; border-left: none; border-right: none; }
.history-poster { width: 52px; height: 78px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; background: var(--surface-solid); }
.history-poster-placeholder { width: 52px; height: 78px; border-radius: var(--radius-sm); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 20px; color: #fff; }
.history-body { flex: 1; }
.history-title { font-family: var(--font-body); font-weight: 700; font-size: 15.5px; margin: 0 0 3px; }
.history-sub { font-size: 12.5px; color: var(--text-dim); margin: 0 0 4px; font-weight: 600; }
.history-stars { font-size: 12px; }

/* Settings */
.settings-group { margin-bottom: 26px; }
.settings-hint { color: var(--text-dim); font-size: 13px; margin: 0 0 10px; }
.segmented { display: flex; background: var(--surface); border-radius: 999px; padding: 3px; border: 1px solid var(--border); }
.segmented button { flex: 1; background: none; border: none; padding: 9px 0; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.segmented button.active { background: var(--accent); color: #fff; font-weight: 700; }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 7px; color: var(--text-faint); font-size: 11px; font-weight: 600; }
.nav-icon { font-size: 21px; }
.nav-btn.active { color: var(--accent-2); }
.nav-btn.active .nav-icon { filter: drop-shadow(0 0 6px rgba(229,36,29,0.55)); }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-overlay[hidden] { display: none; }
.modal-sheet { background: var(--surface-solid); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 82vh; overflow-y: auto; animation: sheet-up .22s ease; border-top: 3px solid var(--accent); }
@keyframes sheet-up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-sheet h3 { font-size: 17px; margin-bottom: 14px; font-family: var(--font-body); font-weight: 700; }

.status-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.status-opt { text-align: left; padding: 15px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px; font-weight: 600; }
.status-opt:active { border-color: var(--accent); background: var(--accent-dim); }

.picker-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 40vh; overflow-y: auto; }
.picker-item { text-align: left; padding: 13px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: 14px; font-weight: 600; }
.picker-item.selected { border-color: var(--accent); background: var(--accent-dim); }

.celebrate { font-family: var(--font-display); font-size: 24px; text-align: center; margin-bottom: 10px; letter-spacing: 0.4px; }
#modal-fim-temporada-next { text-align: center; color: var(--text-dim); margin-bottom: 16px; font-weight: 600; }

.stars { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.stars button { background: none; border: none; font-size: 32px; filter: grayscale(1) opacity(0.35); }
.stars button.active { filter: none; }

/* Toast */
.toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 50%; transform: translateX(-50%) translateY(-140%);
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--accent);
  padding: 12px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600; z-index: 100;
  transition: transform .25s ease; max-width: 90%; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.toast.show { transform: translateX(-50%) translateY(0); }
