:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #232733;
  --text: #e8eaed;
  --muted: #9aa0aa;
  --accent: #4f8cff;
  --danger: #ff5c5c;
  --success: #4cff91;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── Topbar ─────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid #000;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.2rem; margin: 0; }
.session { color: var(--muted); font-size: 0.85rem; }

/* ── Layout ─────────────────────────────────── */

.container { max-width: 1500px; margin: 0 auto; padding: 20px; }
.hidden { display: none !important; }

.workspace {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.content { flex: 1; min-width: 0; }

/* ── Search ─────────────────────────────────── */

.search-bar { margin-bottom: 14px; }
#search {
  width: 100%;
  padding: 11px 16px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
#search:focus { border-color: var(--accent); }
.status { color: var(--muted); margin-bottom: 12px; font-size: 0.88rem; }

/* ── Breadcrumb ─────────────────────────────── */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.crumb {
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 5px;
}
.crumb:hover { background: var(--surface-2); }
.crumb-active { color: var(--text); cursor: default; font-weight: 600; }
.crumb-active:hover { background: none; }
.crumb-sep { color: var(--muted); }

/* ── Folder cards ───────────────────────────── */

.folder-card {
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.folder-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.folder-card .thumb {
  height: 96px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2f3547, #1c2029);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  margin-bottom: 10px;
}
.folder-card .title { font-weight: 600; font-size: 0.9rem; word-break: break-word; }

/* ── Video grid ─────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 12px;
  padding: 14px;
}
.video-card {
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.video-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.video-card .thumb {
  height: 96px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2a2f3d, #171a21);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem;
  margin-bottom: 10px;
}
.video-card .title { font-weight: 600; font-size: 0.88rem; word-break: break-word; }
.video-card .meta  { color: var(--muted); font-size: 0.74rem; margin-top: 4px; }
.badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  margin-top: 6px;
}

/* ── Gate ───────────────────────────────────── */

.gate-card { max-width: 480px; margin: 60px auto; text-align: center; }
.gate-card h2 { color: var(--danger); }

/* ── Storage widget ─────────────────────────── */

.storage-widget {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.storage-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
}
.storage-title { font-weight: 600; }
.storage-text  { color: var(--muted); }

.storage-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.storage-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  width: 0%;
  transition: width .6s ease, background .3s;
}
.storage-fill.warning { background: #ffb347; }
.storage-fill.danger  { background: var(--danger); }

.storage-limit {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
}

/* ── Upload sidebar ─────────────────────────── */

.upload-sidebar {
  width: 290px;
  flex-shrink: 0;
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 94px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}

.sidebar-header {
  font-weight: 700;
  font-size: 0.92rem;
}

/* ── Drop zone ──────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--surface-2);
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(79,140,255,.07);
}
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.dz-icon  { font-size: 1.7rem; }
.dz-text  { color: var(--muted); font-size: 0.8rem; margin: 0; }

.btn-select {
  padding: 6px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.btn-select:hover { background: #6fa3ff; }

/* ── Upload cards ───────────────────────────── */

.upload-list { display: flex; flex-direction: column; gap: 10px; }

.upload-card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 10px;
  padding: 11px;
  transition: border-color .15s;
}
.upload-card.uploading { border-color: var(--accent); }
.upload-card.done      { border-color: var(--success); }
.upload-card.errored   { border-color: var(--danger); }

/* Card header */
.uc-header {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 9px;
}
.uc-file-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 1px; }
.uc-file-info { flex: 1; min-width: 0; }
.uc-filename {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.uc-filesize { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

.uc-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
}
.uc-remove:hover { color: var(--danger); }

/* Setup */
.uc-setup { display: flex; flex-direction: column; gap: 7px; }

.uc-zip-hint {
  font-size: 0.7rem;
  color: var(--accent);
  background: rgba(79,140,255,.1);
  padding: 5px 8px;
  border-radius: 6px;
  line-height: 1.35;
}

.uc-type-toggle { display: flex; gap: 5px; }
.uc-type-btn {
  flex: 1;
  padding: 5px 4px;
  border: 1px solid var(--surface-2);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.72rem;
  transition: all .12s;
}
.uc-type-btn.active { border-color: var(--accent); background: transparent; color: var(--text); }

.uc-name-input {
  width: 100%;
  padding: 6px 9px;
  border-radius: 7px;
  border: 1px solid var(--surface-2);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
  transition: border-color .12s;
}
.uc-name-input:focus { border-color: var(--accent); }

/* Fila temporada + capítulo (vídeos de serie) */
.uc-series-meta { display: flex; flex-direction: column; gap: 5px; }
.uc-meta-row    { display: flex; align-items: center; gap: 5px; }
.uc-meta-label  { font-size: 0.7rem; color: var(--muted); white-space: nowrap; min-width: 14px; text-align: center; font-weight: 600; }
.uc-season-input,
.uc-episode-input {
  flex: 1;
  padding: 5px 7px;
  border-radius: 7px;
  border: 1px solid var(--surface-2);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  outline: none;
  transition: border-color .12s;
  min-width: 0;
}
.uc-season-input:focus,
.uc-episode-input:focus { border-color: var(--accent); }

/* Temporada forzada opcional para archivos comprimidos */
.uc-archive-season .uc-season-input { width: 100%; }
.uc-archive-season .uc-season-input::placeholder { color: var(--muted); }

.uc-start-btn {
  width: 100%;
  padding: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.uc-start-btn:hover { background: #6fa3ff; }

/* Progress */
.uc-progress-wrap { display: flex; flex-direction: column; gap: 4px; }
.progress-bar {
  height: 5px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width .25s linear;
}
.uc-progress-stats { font-size: 0.7rem; color: var(--muted); text-align: right; }

/* Done / Error */
.uc-done  { font-size: 0.83rem; color: var(--success); font-weight: 600; }
.uc-error { font-size: 0.8rem;  color: var(--danger); }

/* ── Player modal ───────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-content {
  background: var(--surface);
  border-radius: 14px;
  padding: 20px;
  width: min(920px, 100%);
  position: relative;
}
.modal-content h3 { margin: 0 0 12px; padding-right: 40px; word-break: break-word; }
.modal video {
  width: 100%;
  border-radius: 10px;
  background: #000;
  max-height: 70vh;
}
.close {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--surface-2);
  border: none;
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: background .12s, color .12s;
}
.close:hover { background: rgba(255,92,92,.2); color: var(--danger); }

/* ── Topbar del reproductor + navegación de playlist ─ */

.player-topbar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}
.modal-content .player-topbar h3 {
  flex: 1; min-width: 0;
  margin: 0; padding-right: 0;
  font-size: 1rem; word-break: break-word;
}
.player-nav-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
/* Dentro del nav-row el close ya no necesita posición absoluta */
.player-nav-row .close { position: static; }
.player-index {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 34px;
  text-align: center;
}
/* Selector de pista de audio */
.audio-track-wrap { display: flex; align-items: center; }
.audio-track-sel {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--surface-2);
  border-radius: 7px;
  padding: 4px 7px;
  font-size: 0.74rem;
  cursor: pointer;
  outline: none;
  max-width: 150px;
  transition: border-color .12s;
}
.audio-track-sel:focus { border-color: var(--accent); }
.player-nav-btn {
  background: var(--surface-2);
  border: none;
  color: var(--text);
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  transition: background .12s;
  flex-shrink: 0;
}
.player-nav-btn:hover:not(:disabled) { background: var(--accent); }
.player-nav-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Mi Playlist (sidebar) ──────────────────── */

.cpl-section {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cpl-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.cpl-header-right { display: flex; align-items: center; gap: 4px; }
.cpl-count { font-size: 0.75rem; color: var(--muted); font-weight: normal; }
.cpl-clear-btn {
  background: none; border: none; cursor: pointer;
  font-size: 0.8rem; padding: 1px 3px; border-radius: 4px; color: var(--muted);
  line-height: 1;
}
.cpl-clear-btn:hover { color: var(--danger); }

.cpl-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 210px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}
.cpl-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 5px;
  border-radius: 6px;
  font-size: 0.74rem;
  min-width: 0;
}
.cpl-item:hover { background: var(--surface-2); }
.cpl-num   { color: var(--muted); min-width: 18px; text-align: right; flex-shrink: 0; font-size: 0.67rem; }
.cpl-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpl-actions { display: flex; gap: 1px; flex-shrink: 0; }
.cpl-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 0.62rem; padding: 2px 4px;
  border-radius: 4px; line-height: 1;
}
.cpl-btn:hover:not([disabled]) { background: var(--surface-2); color: var(--text); }
.cpl-btn[disabled] { opacity: .3; cursor: not-allowed; }
.cpl-rm:hover:not([disabled]) { color: var(--danger) !important; }

.cpl-empty {
  font-size: 0.74rem; color: var(--muted);
  text-align: center; margin: 2px 0;
}
.cpl-play {
  width: 100%; padding: 7px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 7px;
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: background .12s;
}
.cpl-play:hover { background: #6fa3ff; }

/* ── Botón ❤️ en tarjetas de vídeo ─────────── */

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
  gap: 4px;
}
.fav-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; padding: 0 2px; line-height: 1;
  opacity: .55; transition: opacity .15s, transform .15s;
  flex-shrink: 0;
}
.fav-btn:hover  { opacity: 1; }
.fav-btn.active { opacity: 1; transform: scale(1.15); }

/* ── Playlist panel (dentro del modal) ──────── */

.playlist-panel {
  border-top: 1px solid var(--surface-2);
  margin-top: 10px;
  padding-top: 6px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background .1s;
  min-width: 0;
}
.pl-item:hover            { background: var(--surface-2); }
.pl-item.active           { background: rgba(79,140,255,.15); color: var(--accent); }
.pl-item.active .pl-num   { color: var(--accent); }
.pl-num   { color: var(--muted); min-width: 22px; text-align: right; font-size: 0.72rem; flex-shrink: 0; }
.pl-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-size  { color: var(--muted); font-size: 0.7rem; white-space: nowrap; flex-shrink: 0; }
  --surface: #1a1d24;
  --surface-2: #232733;
  --text: #e8eaed;
  --muted: #9aa0aa;
  --accent: #4f8cff;
  --danger: #ff5c5c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid #000;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { font-size: 1.2rem; margin: 0; }
.session { color: var(--muted); font-size: 0.85rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 20px; }

.hidden { display: none !important; }

.search-bar { margin-bottom: 16px; }

#search {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
#search:focus { border-color: var(--accent); }

.status { color: var(--muted); margin-bottom: 12px; font-size: 0.9rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 12px;
  padding: 16px;
}

.video-card {
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.video-card:hover { transform: translateY(-3px); border-color: var(--accent); }

.video-card .thumb {
  height: 110px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2a2f3d, #171a21);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin-bottom: 10px;
}

.video-card .title { font-weight: 600; font-size: 0.95rem; word-break: break-word; }
.video-card .meta { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  margin-top: 6px;
}

.gate-card { max-width: 480px; margin: 60px auto; text-align: center; }
.gate-card h2 { color: var(--danger); }

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

.modal-content {
  background: var(--surface);
  border-radius: 14px;
  padding: 20px;
  width: min(900px, 100%);
  position: relative;
}
.modal-content h3 { margin: 0 0 12px; padding-right: 40px; word-break: break-word; }

.modal video { width: 100%; border-radius: 10px; background: #000; max-height: 70vh; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-upload {
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 600;
}
.btn-upload:hover { background: #6fa3ff; }

.upload-modal-content { max-width: 500px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group input[type="text"],
.form-group input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--surface-2);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.form-group input[type="text"]:focus { border-color: var(--accent); }
.hint { color: var(--muted); font-size: 0.75rem; margin-top: 4px; display: block; }

.type-toggle { display: flex; gap: 8px; }
.type-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--surface-2);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all .12s;
}
.type-btn.active { border-color: var(--accent); background: transparent; color: var(--text); }

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { background: #6fa3ff; }

.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width .2s;
}
.progress-text { color: var(--muted); font-size: 0.82rem; text-align: right; }

.upload-result {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.upload-result.ok { background: #1a3a2a; color: #4cff91; }
.upload-result.err { background: #3a1a1a; color: var(--danger); }
