/* public/css/main.css */

:root {
  --bg:        #0A0A0E;
  --bg1:       #141418;
  --bg2:       #1C1C22;
  --bg3:       #26262E;
  --accent:    #E50914;
  --accent2:   #F40612;
  --text1:     #FFFFFF;
  --text2:     #B3B3B3;
  --text3:     #666672;
  --border:    #2A2A34;
  --r:         8px;
  --rlg:       12px;
  --nav-h:     56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select, textarea { font-family: inherit; }

img { max-width: 100%; }

.hidden { display: none !important; }

/* ── Boutons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r);
  border: none;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--text1); color: var(--bg); }
.btn-primary:hover { background: rgba(255,255,255,.85); }
.btn-accent { background: var(--accent); color: var(--text1); }
.btn-accent:hover { background: var(--accent2); }
.btn-secondary { background: rgba(255,255,255,.12); color: var(--text1); }
.btn-secondary:hover { background: rgba(255,255,255,.2); }
.btn-danger { background: transparent; color: #ff5a5f; border: 1px solid #ff5a5f44; }
.btn-danger:hover { background: #ff5a5f22; }
.btn-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(42,42,42,.6); color: var(--text1); border: 1px solid var(--border);
  cursor: pointer; font-size: 16px;
}
.btn-icon:hover { background: rgba(255,255,255,.15); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Formulaires ─────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; text-align: left; }
.field label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text1); font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--text2);
}
.field textarea { resize: vertical; min-height: 80px; }
.error-msg { color: #ff5a5f; font-size: 13px; margin: 8px 0; min-height: 18px; }

/* ── Navbar catégories ───────────────────────────────────────────────── */
.category-nav {
  display: flex; align-items: center; gap: 4px;
  height: var(--nav-h);
  padding: 0 48px;
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(to bottom, var(--bg) 80%, transparent);
  backdrop-filter: blur(8px);
}
.category-nav .brand {
  font-size: 20px; font-weight: 800; color: var(--accent);
  margin-right: 24px; white-space: nowrap; cursor: pointer;
  letter-spacing: -.5px;
}
.category-nav .nav-links { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.category-nav a {
  padding: 12px 14px;
  font-size: 14px; color: var(--text2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  white-space: nowrap; cursor: pointer;
}
.category-nav a:hover, .category-nav a.active {
  color: var(--text1); border-bottom-color: var(--accent);
}
.category-nav .nav-right { display: flex; align-items: center; gap: 12px; margin-left: 12px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; transition: width .2s;
}
.search-box input {
  background: transparent; border: none; color: var(--text1); font-size: 13px;
  width: 160px; outline: none;
}
.profile-chip {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 4px 8px 4px 4px; border-radius: 6px;
}
.profile-chip:hover { background: rgba(255,255,255,.08); }
.profile-chip .avatar { font-size: 20px; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.profile-chip .avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-chip .name { font-size: 13px; color: var(--text2); }

/* ── Hero ────────────────────────────────────────────────────────────── */
.hero {
  height: 56vh; min-height: 380px;
  position: relative;
  background-size: cover; background-position: center top;
  display: flex; align-items: flex-end;
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(to right, rgba(10,10,14,.95) 30%, transparent 70%),
    linear-gradient(to top, var(--bg) 0%, transparent 40%);
}
.hero-content { position: relative; z-index: 1; padding: 0 48px 48px; max-width: 620px; }
.hero-title { font-size: 42px; font-weight: 800; margin: 0 0 12px; line-height: 1.1; }
.hero-meta { display: flex; gap: 10px; align-items: center; color: var(--text2); font-size: 14px; margin-bottom: 14px; }
.hero-synopsis {
  color: var(--text1); font-size: 15px; line-height: 1.5; margin-bottom: 20px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-actions { display: flex; gap: 12px; }

/* ── Rows de titres ──────────────────────────────────────────────────── */
.title-row { padding: 0 48px; margin-bottom: 32px; }
.title-row h2 {
  font-size: 18px; font-weight: 600; color: var(--text2); margin: 0 0 12px; cursor: pointer;
}
.title-row h2:hover { color: var(--text1); }
.cards-track {
  display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; padding-bottom: 8px;
}
.cards-track::-webkit-scrollbar { display: none; }

.title-card {
  flex: 0 0 200px; scroll-snap-align: start;
  border-radius: var(--r); overflow: hidden;
  cursor: pointer; position: relative;
  transition: transform .2s ease;
  background: var(--bg2);
}
.title-card:hover { transform: scale(1.08); z-index: 10; box-shadow: 0 8px 32px rgba(0,0,0,.8); }
.title-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--bg3); }
.title-card .card-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 24px 8px 8px;
  background: linear-gradient(to top, rgba(0,0,0,.9), transparent);
  opacity: 0; transition: opacity .15s;
}
.title-card:hover .card-info { opacity: 1; }
.title-card .card-title {
  font-size: 12px; font-weight: 600; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.title-card .card-buttons { display: flex; gap: 6px; }
.title-card .card-buttons button {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.6);
  background: rgba(20,20,20,.7); color: var(--text1); font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.title-card .card-buttons button:hover { background: var(--text1); color: var(--bg); }

.card-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: rgba(255,255,255,.2); }
.card-progress-fill { height: 100%; background: var(--accent); }

.card-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,.7); color: var(--text1);
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
}

/* ── Panneau détail (colonne droite) ────────────────────────────────── */
.detail-panel {
  width: 420px; max-width: 92vw;
  position: fixed; right: 0; top: 0; bottom: 0;
  background: var(--bg1);
  border-left: 0.5px solid var(--border);
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow-y: auto;
  z-index: 200;
  box-shadow: -20px 0 60px rgba(0,0,0,.5);
}
.detail-panel.open { transform: translateX(0); }
.detail-panel .dp-close {
  position: absolute; top: 14px; right: 14px; z-index: 5;
}
.detail-panel .dp-player { width: 100%; aspect-ratio: 16/9; background: #000; }
.detail-panel .dp-player video { width: 100%; height: 100%; display: block; }
.dp-body { padding: 20px 24px 40px; }
.dp-title { font-size: 22px; font-weight: 800; margin: 4px 0 8px; }
.dp-meta { color: var(--text2); font-size: 13px; margin-bottom: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.dp-synopsis { font-size: 14px; line-height: 1.6; color: var(--text1); margin-bottom: 16px; }
.dp-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.dp-tag {
  padding: 4px 10px; border-radius: 20px; background: var(--bg3); color: var(--text2);
  font-size: 12px; cursor: pointer; border: 1px solid var(--border);
}
.dp-tag:hover { color: var(--text1); border-color: var(--text2); }
.dp-actions { display: flex; gap: 10px; margin-bottom: 20px; }

.dp-season { font-size: 13px; font-weight: 700; color: var(--text2); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .5px; }
.dp-episode {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: var(--r); cursor: pointer;
}
.dp-episode:hover { background: var(--bg2); }
.dp-episode .ep-num { width: 26px; color: var(--text2); font-size: 13px; text-align: center; }
.dp-episode .ep-thumb {
  width: 88px; height: 50px; object-fit: cover; border-radius: 4px;
  background: var(--bg3); flex-shrink: 0;
}
.dp-episode .ep-info { flex: 1; min-width: 0; }
.dp-episode .ep-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-episode .ep-sub { font-size: 12px; color: var(--text3); }
.dp-episode .ep-check { color: var(--accent); font-size: 14px; }
.dp-episode .dir-poster-upload {
  width: 28px; height: 28px; font-size: 13px; flex-shrink: 0; cursor: pointer;
}
.dp-episode .ep-progress { height: 2px; background: var(--bg3); border-radius: 2px; margin-top: 4px; }
.dp-episode .ep-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }

.overlay-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 190; opacity: 0; pointer-events: none; transition: opacity .25s;
}
.overlay-scrim.open { opacity: 1; pointer-events: auto; }

/* ── États vides / chargement ────────────────────────────────────────── */
.loading, .empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; color: var(--text3); text-align: center; gap: 14px;
}
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--bg3); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg3); color: var(--text1); padding: 12px 20px; border-radius: var(--r);
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 999;
  border: 1px solid var(--border);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Grille de catégorie (page /browse/:category) ───────────────────── */
.category-grid {
  padding: 24px 48px 60px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px;
}
.category-grid .title-card { flex: none; }

/* ── Mode répertoire ─────────────────────────────────────────────────── */
.dir-breadcrumbs {
  font-size: 20px; color: var(--text2); margin-bottom: 4px;
}
.dir-breadcrumbs a { cursor: pointer; color: var(--text2); }
.dir-breadcrumbs a:hover { color: var(--text1); text-decoration: underline; }
.dir-breadcrumbs a:last-child { color: var(--text1); font-weight: 600; }

.dir-folder-card { background: var(--bg2); }
.dir-folder-card.dir-folder-fallback {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16/9;
}
.dir-folder-card .dir-folder-icon {
  display: none; font-size: 40px;
}
.dir-folder-card.dir-folder-fallback .dir-folder-icon { display: block; }
.dir-folder-card:not(.dir-folder-fallback) .dir-folder-icon { display: none; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .category-nav { padding: 0 16px; }
  .hero-content, .title-row { padding-left: 16px; padding-right: 16px; }
  .hero-title { font-size: 28px; }
  .detail-panel { width: 100%; }
  .search-box input { width: 100px; }
}
