/* ytui web — thème sombre (palette reprise de mobile/lib/theme.dart). */

:root {
  --bg: #101014;
  --surface: #1a1a20;
  --surface-2: #23232b;
  --surface-3: #2c2c36;
  --border: #33333e;
  --text: #e8e6ea;
  --text-dim: #a5a1ad;
  --accent: #e53935;      /* kBrandRed */
  --twitch: #9146ff;      /* kTwitchPurple */
  --tiktok: #fe2c55;      /* kTikTokRed */
  --ok: #4caf50;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --gutter: 16px;
  --sidebar-w: 200px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
img { display: block; }

/* ─── Layout ─── */

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-right: 1px solid var(--border);
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  padding: 8px 10px 16px;
}

.sidebar a[data-nav] {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}

.sidebar a[data-nav]:hover { background: var(--surface); color: var(--text); }
.sidebar a[data-nav].active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.nav-help {
  margin-top: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
}
.nav-help:hover { color: var(--text); background: var(--surface); }

.view {
  flex: 1;
  min-width: 0;
  padding: 20px var(--gutter) 48px;
  outline: none;
}

@media (max-width: 899px) {
  .app { flex-direction: column; }
  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    flex: none;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { padding: 4px 8px; font-size: 17px; }
  .sidebar a[data-nav] { padding: 6px 9px; font-size: 14px; }
  .nav-help { display: none; }
}

/* ─── En-têtes de page ─── */

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}
.page-head h1 { font-size: 22px; margin: 0; flex: 1; min-width: 200px; }
.page-head .sub { color: var(--text-dim); font-size: 13px; width: 100%; }

/* ─── Boutons / champs ─── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger:hover { border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 6px 8px; line-height: 1; }

.input, select.input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 0;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 7px 14px;
  cursor: pointer;
}
.seg button.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ─── Grille de cartes ─── */

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

.card {
  position: relative;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.card:focus-visible, .card.focused {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 26px;
}

.badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
}
.badge.live { background: var(--accent); font-weight: 700; }
.badge.live.twitch { background: var(--twitch); }
.badge.live.tiktok { background: var(--tiktok); }
.badge.watched { left: 6px; right: auto; background: rgba(0,0,0,.8); color: var(--ok); }
.badge.kind { left: 6px; right: auto; text-transform: uppercase; letter-spacing: .5px; }
.channel-banner {
  margin: 0 16px 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--twitch) 25%, transparent);
  border: 1px solid var(--twitch);
  color: var(--text);
}

.card .meta { display: flex; gap: 8px; padding: 8px 2px 0; }
.card .meta .txt { flex: 1; min-width: 0; }
.card .title {
  font-weight: 600;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.card .menu-btn {
  flex: 0 0 auto;
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 4px;
  visibility: hidden;
}
.card:hover .menu-btn, .card.focused .menu-btn, .card:focus-within .menu-btn { visibility: visible; }
.card .menu-btn:hover { color: var(--text); background: var(--surface-2); }

/* ─── Menu contextuel ─── */

.ctx-menu {
  position: fixed;
  z-index: 60;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.ctx-menu button:hover { background: var(--surface-3); }

/* ─── Listes (historique, chaînes, file d'attente) ─── */

.rows { display: flex; flex-direction: column; gap: 4px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.row:hover, .row.focused { background: var(--surface); }
.row .row-thumb {
  position: relative;
  flex: 0 0 140px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.row .row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.row .txt { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--text-dim); font-size: 13px; }
.row .actions { flex: 0 0 auto; display: flex; gap: 6px; }

.progressbar { height: 3px; background: var(--surface-3); border-radius: 2px; margin-top: 6px; }
.progressbar > div { height: 100%; background: var(--accent); border-radius: 2px; }

/* ─── Bandeaux / états ─── */

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 14px;
  white-space: pre-wrap;
}

.empty { color: var(--text-dim); text-align: center; padding: 60px 0; }
.spinner { display: flex; justify-content: center; padding: 60px 0; color: var(--text-dim); }
.spinner::after {
  content: "";
  width: 28px; height: 28px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section-title { font-size: 16px; font-weight: 700; margin: 22px 0 10px; }

/* ─── Toasts ─── */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  align-items: center;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  animation: toast-in .18s ease-out;
  max-width: 90vw;
}
.toast.error { border-color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ─── Modales ─── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-width: 320px;
  max-width: min(480px, 92vw);
  max-height: 80vh;
  overflow: auto;
}
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal .field { width: 100%; margin-bottom: 8px; }
.modal .list-pick { display: flex; flex-direction: column; gap: 4px; }
.modal .list-pick button { text-align: left; }

.kbd-table { border-collapse: collapse; width: 100%; }
.kbd-table td { padding: 4px 8px; color: var(--text-dim); }
.kbd-table td:first-child { width: 110px; color: var(--text); }
kbd {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}

/* ─── Login ─── */

.login-wrap {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: min(380px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-box h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }

/* ─── Page lecture ─── */

.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  max-width: 1600px;
}
@media (min-width: 1100px) {
  .watch { grid-template-columns: minmax(0, 1fr) 340px; }
}

.player-box {
  position: relative;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.player-box video { width: 100%; height: 100%; }

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  z-index: 5;
  text-align: center;
  padding: 20px;
}
.player-overlay .big-play {
  font-size: 30px;
  background: var(--accent);
  border: none;
  color: #fff;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  cursor: pointer;
}

.watch-info h1 { font-size: 19px; margin: 14px 0 6px; }
.watch-info .channel-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-dim);
}
.watch-info .channel-line a:hover { color: var(--text); }
.watch-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.side-panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.side-panel .rows .row .row-thumb { flex-basis: 110px; }
.side-panel .comments {
  max-width: none;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}
.side-panel .comment-form { flex-wrap: wrap; }
.side-panel .comment-form .input { min-width: 0; }

/* ─── Chat en direct ─── */

.chat-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}
.chat-msg { font-size: 14px; line-height: 1.35; word-break: break-word; }
.chat-author { font-weight: 600; color: var(--accent); }
