:root {
  --bg: #0a0a0f;
  --surface: #13131c;
  --card: #1a1a28;
  --border: #2a2a40;
  --accent: #e8b94f;
  --accent2: #c0392b;
  --text: #e8e6e0;
  --muted: #7a7a9a;
  --radius: 14px;
  --green: #27ae60;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* ── HEADER ─────────────────────────────────────────────────── */
.sticky-top-block {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}

header {
  padding: 1.2rem 0 0.8rem;
  border-bottom: none;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { font-family: 'Playfair Display', serif; font-size: clamp(1.6rem, 5vw, 2.8rem); font-weight: 700; letter-spacing: -1px; line-height: 1 }
.brand span { color: var(--accent) }
.tagline { font-size: .78rem; color: var(--muted); letter-spacing: 3px; text-transform: uppercase; margin-top: .3rem }

/* ── USER AREA ──────────────────────────────────────────────── */
.user-area { display: flex; gap: .5rem; align-items: center; flex-shrink: 0 }

.btn-auth {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: .4rem .9rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .82rem;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.btn-auth:hover { border-color: var(--accent); color: var(--accent) }
.btn-register { border-color: var(--accent); color: var(--accent) }
.btn-register:hover { background: var(--accent); color: #0a0a0f }

/* USER PILL (logueado) */
.user-pill {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: .3rem .8rem .3rem .4rem;
  cursor: pointer;
  transition: border-color .2s;
  user-select: none;
}
.user-pill:hover { border-color: var(--accent) }

.user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover }
.user-avatar-initials {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #c0392b);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #0a0a0f;
}
.user-name { font-size: .82rem; font-weight: 500 }
.user-points { font-size: .75rem; color: var(--accent); display: flex; align-items: center; gap: .2rem }

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 190px;
  overflow: hidden;
  z-index: 500;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
  animation: dropIn .18s ease;
}
@keyframes dropIn { from { opacity:0; transform:translateY(-6px) } to { opacity:1; transform:translateY(0) } }
.user-dropdown a {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem; font-size: .85rem; color: var(--text);
  text-decoration: none; transition: background .15s;
}
.user-dropdown a:hover { background: rgba(255,255,255,.05) }
.user-dropdown .dropdown-sep { height: 1px; background: var(--border); margin: .3rem 0 }
.user-dropdown .logout-link { color: #e07060 }
.user-pill.open .user-dropdown { display: block }

/* ── FILTERS ────────────────────────────────────────────────── */
.filters-wrap { background: var(--surface); border-bottom: 1px solid var(--border); padding: 1.1rem 0 }
.filter-row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; justify-content: center }

.filter-select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .9rem;
  font-family: 'DM Sans', sans-serif;
  font-size: .88rem;
  cursor: pointer;
  transition: border-color .2s;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7a9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem;
}
.filter-select:hover, .filter-select:focus { border-color: var(--accent); outline: none }
.filter-select option { background: var(--card) }

.btn-spin {
  background: var(--accent); color: #0a0a0f;
  font-family: 'DM Sans', sans-serif; font-weight: 500; font-size: .9rem;
  border: none; border-radius: 8px; padding: .5rem 1.4rem;
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.btn-spin:hover { background: #f5c96b; transform: translateY(-1px) }
.btn-spin.loading { opacity: .7; pointer-events: none }
.btn-spin.loading .spin-icon { animation: spin 1s linear infinite }
@keyframes spin { to { transform: rotate(360deg) } }

/* ── STAGE / MOVIE CARD ─────────────────────────────────────── */
#stage { min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 3rem 1rem }

.empty-state { text-align: center; max-width: 380px }
.empty-state .big-icon { font-size: 4rem; color: var(--border); margin-bottom: 1rem; display: block }
.empty-state h2 { font-family: 'Playfair Display', serif; font-size: 1.5rem; margin-bottom: .5rem }
.empty-state p { color: var(--muted); font-size: .9rem; line-height: 1.6 }

.movie-card {
  width: 100%; max-width: 800px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: row;
  animation: cardIn .4s cubic-bezier(.22,1,.36,1);
  position: relative;
}
@keyframes cardIn { from { opacity:0; transform:translateY(24px) scale(.98) } to { opacity:1; transform:translateY(0) scale(1) } }

.movie-poster { width: 220px; min-height: 320px; flex-shrink: 0; object-fit: cover; background: var(--surface) }
.movie-poster img { width: 100%; height: 100%; object-fit: cover; display: block }
.poster-placeholder {
  width: 220px; min-height: 320px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--border) 100%);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.poster-placeholder i { font-size: 3rem; color: var(--border) }

.movie-info { padding: 1.8rem; flex: 1; display: flex; flex-direction: column; gap: .6rem }
.movie-meta-top { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .2rem }

.badge-year { background: var(--border); color: var(--muted); font-size: .75rem; padding: .2rem .6rem; border-radius: 4px }
.badge-genre { background: rgba(232,185,79,.12); color: var(--accent); border: 1px solid rgba(232,185,79,.3); font-size: .75rem; padding: .2rem .6rem; border-radius: 4px }
.badge-platform { background: rgba(192,57,43,.12); color: #e07060; border: 1px solid rgba(192,57,43,.3); font-size: .75rem; padding: .2rem .6rem; border-radius: 4px }

.movie-title { font-family: 'Playfair Display', serif; font-size: clamp(1.4rem,3vw,2rem); line-height: 1.15; color: var(--text) }
.movie-rating { display: flex; align-items: center; gap: .4rem }
.stars { color: var(--accent); font-size: .9rem }
.rating-num { font-weight: 500; font-size: 1rem }
.rating-count { color: var(--muted); font-size: .8rem }
.movie-overview { color: #b0aec8; font-size: .9rem; line-height: 1.65; flex: 1; display: -webkit-box; -webkit-line-clamp: 5; line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden }

.movie-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .4rem }

.btn-watch {
  background: var(--accent); color: #0a0a0f; border: none; border-radius: 8px;
  padding: .5rem 1.2rem; font-family: 'DM Sans', sans-serif; font-weight: 500; font-size: .88rem;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; transition: all .2s;
}
.btn-watch:hover { background: #f5c96b; color: #0a0a0f }

.btn-like, .btn-dislike, .btn-skip, .btn-watchlater {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: .5rem .9rem; font-size: .88rem; cursor: pointer;
  transition: all .2s; display: inline-flex; align-items: center; gap: .3rem;
}
.btn-like:hover { border-color: var(--green); color: var(--green) }
.btn-like.active { background: rgba(39,174,96,.15); border-color: var(--green); color: var(--green) }
.btn-dislike:hover { border-color: var(--accent2); color: #e07060 }
.btn-watchlater:hover { border-color: #5b8cff; color: #5b8cff }
.btn-watchlater.active { background: rgba(91,140,255,.15); border-color: #5b8cff; color: #5b8cff }
.btn-skip:hover { border-color: var(--muted); color: var(--text) }

/* ── PROFILE STRIP ──────────────────────────────────────────── */
.profile-strip { background: var(--surface); border-top: 1px solid var(--border); padding: 1rem 0 }
.profile-inner { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; justify-content: center }
.profile-stat { display: flex; flex-direction: column; align-items: center; gap: .1rem }
.profile-stat .num { font-family: 'Playfair Display', serif; font-size: 1.4rem; color: var(--accent) }
.profile-stat .lbl { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px }
.profile-genres { display: flex; gap: .4rem; flex-wrap: wrap }
.micro-badge { background: rgba(232,185,79,.1); border: 1px solid rgba(232,185,79,.2); color: var(--accent); font-size: .72rem; padding: .15rem .5rem; border-radius: 4px }

/* ── HISTORY ────────────────────────────────────────────────── */
.history-section { padding: 2rem 0 3rem }
.section-title { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: var(--text); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border) }

.history-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(110px,1fr)); gap: .7rem }
.history-thumb { border-radius: 8px; overflow: hidden; aspect-ratio: 2/3; background: var(--card); position: relative; cursor: pointer; transition: transform .2s }
.history-thumb:hover { transform: scale(1.04) }
.history-thumb img { width: 100%; height: 100%; object-fit: cover }
.history-thumb .overlay { position: absolute; inset: 0; background: linear-gradient(to top,rgba(0,0,0,.8) 0%,transparent 50%); display: flex; align-items: flex-end; padding: .4rem }
.history-thumb .htitle { font-size: .68rem; line-height: 1.2; color: #fff }
.history-thumb .liked-badge { position: absolute; top:.3rem; right:.3rem; background: rgba(39,174,96,.9); border-radius: 50%; width:20px; height:20px; display:flex; align-items:center; justify-content:center; font-size:.6rem }
.history-thumb .wl-badge { position: absolute; top:.3rem; right:.3rem; background: rgba(91,140,255,.9); border-radius: 50%; width:20px; height:20px; display:flex; align-items:center; justify-content:center; font-size:.6rem }

/* LISTS TABS */
.lists-tabs { display: flex; gap: .5rem; margin: 1.5rem 0 1rem; flex-wrap: wrap }
.list-tab {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: .45rem 1rem; font-size: .85rem; cursor: pointer; transition: all .2s;
  display: flex; align-items: center; gap: .35rem; font-family: 'DM Sans', sans-serif;
}
.list-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(232,185,79,.08) }

/* ── AUTH MODAL ─────────────────────────────────────────────── */
.auth-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.75); backdrop-filter: blur(6px);
  z-index: 1000; align-items: center; justify-content: center; padding: 1rem;
}
.auth-overlay.open { display: flex }

.auth-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%; max-width: 420px;
  position: relative;
  animation: modalIn .3s cubic-bezier(.22,1,.36,1);
  max-height: 95vh; overflow-y: auto;
}
@keyframes modalIn { from { opacity:0; transform:scale(.94) translateY(20px) } to { opacity:1; transform:scale(1) translateY(0) } }

.auth-close {
  position: absolute; top: 1rem; right: 1rem;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer; padding: .3rem;
  transition: color .2s;
}
.auth-close:hover { color: var(--text) }

.auth-logo { font-family: 'Playfair Display', serif; font-size: 1.6rem; font-weight: 700; text-align: center; margin-bottom: 1.5rem }
.auth-logo span { color: var(--accent) }

.auth-tabs { display: flex; background: var(--surface); border-radius: 10px; padding: .25rem; margin-bottom: 1.5rem; gap: .25rem }
.auth-tab {
  flex: 1; background: transparent; border: none; color: var(--muted);
  padding: .5rem; border-radius: 8px; font-family: 'DM Sans', sans-serif;
  font-size: .88rem; cursor: pointer; transition: all .2s;
}
.auth-tab.active { background: var(--card); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3) }

.auth-error, .auth-success {
  border-radius: 8px; padding: .7rem 1rem; font-size: .85rem; margin-bottom: 1rem;
}
.auth-error { background: rgba(192,57,43,.15); border: 1px solid rgba(192,57,43,.4); color: #e07060 }
.auth-success { background: rgba(39,174,96,.15); border: 1px solid rgba(39,174,96,.4); color: #2ecc71 }

.form-group { margin-bottom: 1rem }
.form-group label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .4rem; text-transform: uppercase; letter-spacing: .5px }
.input-icon { position: relative; display: flex; align-items: center }
.input-icon > i { position: absolute; left: .85rem; color: var(--muted); font-size: .9rem; pointer-events: none }
.input-icon input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: .7rem .9rem .7rem 2.5rem;
  font-family: 'DM Sans', sans-serif; font-size: .9rem; transition: border-color .2s;
}
.input-icon input:focus { outline: none; border-color: var(--accent) }
.toggle-pass {
  position: absolute; right: .85rem; background: transparent; border: none;
  color: var(--muted); cursor: pointer; font-size: .9rem; transition: color .2s;
}
.toggle-pass:hover { color: var(--text) }

.pass-strength { display: flex; gap: .25rem; margin-top: .4rem }
.pass-strength .bar { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background .3s }
.pass-strength .bar.weak { background: #e07060 }
.pass-strength .bar.medium { background: var(--accent) }
.pass-strength .bar.strong { background: var(--green) }

.form-check-row { margin-bottom: .8rem; font-size: .82rem; color: var(--muted) }
.form-check-row input { margin-right: .4rem; accent-color: var(--accent) }

.btn-submit {
  width: 100%; background: var(--accent); color: #0a0a0f;
  border: none; border-radius: 10px; padding: .75rem;
  font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: .95rem;
  cursor: pointer; transition: all .2s; display: flex; align-items: center; justify-content: center; gap: .5rem;
}
.btn-submit:hover { background: #f5c96b; transform: translateY(-1px) }
.btn-submit:disabled { opacity: .6; pointer-events: none }

.auth-terms { font-size: .75rem; color: var(--muted); text-align: center; margin-top: .8rem; line-height: 1.5 }

.auth-sep { display: flex; align-items: center; gap: .8rem; margin: 1.4rem 0; color: var(--muted); font-size: .8rem }
.auth-sep::before, .auth-sep::after { content:''; flex:1; height:1px; background:var(--border) }

.btn-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: .7rem; font-family: 'DM Sans', sans-serif;
  font-size: .9rem; text-decoration: none; transition: all .2s; font-weight: 500;
}
.btn-google:hover { border-color: #4285F4; color: var(--text); background: rgba(66,133,244,.08) }

/* ── SIDE PANEL ─────────────────────────────────────────────── */
.side-panel-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:800; backdrop-filter:blur(4px) }
.side-panel-overlay.open { display:block }

.side-panel {
  position: fixed; top: 0; right: -420px; width: 420px; max-width: 100vw;
  height: 100vh; background: var(--card); border-left: 1px solid var(--border);
  z-index: 801; display: flex; flex-direction: column;
  transition: right .35s cubic-bezier(.22,1,.36,1);
}
.side-panel.open { right: 0 }

.side-panel-header { display:flex; align-items:center; justify-content:space-between; padding:1.5rem 1.5rem 1rem; border-bottom:1px solid var(--border) }
.side-panel-header h3 { font-family:'Playfair Display',serif; font-size:1.2rem }
.side-panel-close { background:transparent; border:none; color:var(--muted); font-size:1.1rem; cursor:pointer; padding:.3rem; transition:color .2s }
.side-panel-close:hover { color:var(--text) }

.side-panel-tabs { display:flex; gap:.5rem; padding:.75rem 1.5rem; border-bottom:1px solid var(--border) }
.sp-tab {
  background:transparent; border:1px solid var(--border); color:var(--muted);
  border-radius:8px; padding:.35rem .8rem; font-size:.8rem; cursor:pointer; transition:all .2s;
  display:flex; align-items:center; gap:.3rem; font-family:'DM Sans',sans-serif;
}
.sp-tab.active { border-color:var(--accent); color:var(--accent); background:rgba(232,185,79,.08) }

.side-panel-body { flex:1; overflow-y:auto; padding:1rem 1.5rem }
.sp-loading { text-align:center; padding:3rem 0; color:var(--muted) }

.sp-movie-item {
  display:flex; gap:1rem; padding:.8rem 0; border-bottom:1px solid rgba(42,42,64,.6);
  align-items:flex-start;
}
.sp-movie-item:last-child { border-bottom:none }
.sp-thumb { width:50px; height:75px; border-radius:6px; object-fit:cover; background:var(--surface); flex-shrink:0 }
.sp-info { flex:1; min-width:0 }
.sp-title { font-size:.88rem; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-bottom:.2rem }
.sp-meta { font-size:.75rem; color:var(--muted) }
.sp-remove { background:transparent; border:none; color:var(--muted); cursor:pointer; padding:.2rem; font-size:.85rem; transition:color .2s; flex-shrink:0 }
.sp-remove:hover { color:#e07060 }
.sp-empty { text-align:center; padding:3rem 1rem; color:var(--muted); font-size:.9rem }

/* ── TOAST ──────────────────────────────────────────────────── */
.toast-custom {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: .7rem 1.2rem; font-size: .85rem; color: var(--text); z-index: 9998;
  transform: translateY(80px); opacity: 0; transition: all .3s cubic-bezier(.22,1,.36,1);
  display: flex; align-items: center; gap: .5rem;
}
.toast-custom.show { transform: translateY(0); opacity: 1 }
.toast-custom.good i { color: var(--green) }
.toast-custom.bad i { color: #e07060 }
.toast-custom.info i { color: #5b8cff }

/* ── ERROR BOX ──────────────────────────────────────────────── */
.error-box {
  background: rgba(192,57,43,.1); border: 1px solid rgba(192,57,43,.3);
  border-radius: var(--radius); padding: 1.5rem 2rem; text-align: center; max-width: 480px;
}
.error-box i { font-size: 2rem; color: var(--accent2); margin-bottom: .6rem; display: block }
.error-box h3 { font-family: 'Playfair Display', serif; margin-bottom: .4rem }
.error-box p { color: var(--muted); font-size: .88rem }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media(max-width:600px) {
  .sticky-top-block { position:fixed; top:0; left:0; right:0; z-index:200; background:var(--bg) }
  .tagline { display:none }
  .btn-auth span { display:none }
  .movie-card { flex-direction:column; align-items:center }
  .movie-poster, .poster-placeholder { width:140px; min-height:unset; max-height:unset; flex-shrink:0; align-self:center; margin:1rem auto 0 }
  .movie-poster img { width:140px; height:auto; object-fit:contain; display:block; border-radius:8px }
  .movie-info { padding:1rem; width:100% }
  .movie-title { font-size:1.2rem }
  .side-panel { width:100%; right:-100vw }
  .auth-modal { padding:2rem 1.2rem }
}
