/* Twitch Hub - style sombre inspire de Twitch */

:root {
  --bg: #0e0e10;
  --bg-alt: #18181b;
  --bg-card: #1f1f23;
  --bg-hover: #26262c;
  --border: #35353b;
  --text: #efeff1;
  --text-dim: #adadb8;
  --purple: #9146ff;
  --purple-light: #a970ff;
  --purple-dark: #772ce8;
  --red: #eb0400;
  --green: #00f593;
  --radius: 10px;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- Ecran de connexion ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #1c1130 0%, var(--bg) 60%);
}

.login-card {
  text-align: center;
  max-width: 380px;
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.login-card h1 { font-size: 28px; }
.login-card p { color: var(--text-dim); font-size: 15px; line-height: 1.5; }

.btn-twitch {
  display: inline-block;
  background: var(--purple);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius);
  width: 100%;
  transition: background 0.15s;
}
.btn-twitch:hover { background: var(--purple-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-ghost.small { padding: 6px 12px; font-size: 13px; }

/* ---------- Barre du haut ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }

.demo-badge {
  background: var(--purple);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.06em;
}

.tabs { display: flex; gap: 4px; margin-left: auto; }

.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: var(--purple-light); background: rgba(145, 70, 255, 0.12); }

.pill {
  background: var(--red);
  color: #fff;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
}

.user-zone { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--purple); }

/* ---------- Vues ---------- */

main { padding: 20px 16px 60px; max-width: 1400px; margin: 0 auto; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.view-header h2 { font-size: 20px; }
.title-block { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }

.legend { display: flex; gap: 12px; }
.lg { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.lg::before { content: ""; width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.lg-past::before { background: #4a4a52; }
.lg-live::before { background: var(--red); }
.lg-planned::before { background: var(--green); }

.week-nav { display: flex; align-items: center; gap: 10px; }
#week-label { font-size: 14px; color: var(--text-dim); min-width: 150px; text-align: center; }

.status {
  color: var(--text-dim);
  font-size: 14px;
  padding: 24px;
  text-align: center;
  background: var(--bg-alt);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  margin-bottom: 16px;
}

/* ---------- Calendrier ---------- */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.day-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.day-head {
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}
.day-head .day-num { display: block; font-size: 17px; font-weight: 700; color: var(--text); }
.day-head.today { border-color: var(--purple); background: rgba(145, 70, 255, 0.1); }
.day-head.today .day-num { color: var(--purple-light); }

.slot {
  display: block;
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--purple);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  overflow: hidden;
}
.slot:hover { background: var(--bg-hover); transform: translateY(-1px); }
.slot .slot-time { font-size: 12px; font-weight: 700; color: var(--purple-light); }

/* Trois natures de creneau : passe, en direct, prevu. */
.slot.past { border-left-color: #4a4a52; }
.slot.past .slot-time { color: var(--text-dim); font-weight: 600; }
.slot.past.seen { opacity: 0.5; }
.slot.live { border-left-color: var(--red); background: rgba(235, 4, 0, 0.07); }
.slot.live .slot-time { color: var(--text); }
.slot.planned { border-left-color: var(--green); }
.slot.planned .slot-time { color: var(--green); }

.slot .slot-live {
  font-size: 10px; font-weight: 800; color: #fff; background: var(--red);
  padding: 1px 6px; border-radius: 4px; margin-right: 4px; vertical-align: 1px;
}
.slot .slot-tag {
  font-size: 10px; font-weight: 800; color: #000; background: var(--green);
  padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 1px;
}
.slot .slot-channel { font-size: 13px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .slot-title { font-size: 12px; color: var(--text-dim); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slot .slot-cat { font-size: 11px; color: var(--purple-light); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.day-empty { color: var(--text-dim); font-size: 12px; text-align: center; padding: 12px 4px; opacity: 0.5; }

/* ---------- VODs ---------- */

.filters { display: flex; gap: 8px; }

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--purple); border-color: var(--purple); color: #fff; }

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

.vod-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.1s, border-color 0.15s;
}
.vod-card:hover { transform: translateY(-2px); border-color: var(--purple); }
.vod-card.watched { opacity: 0.55; }

.vod-thumb-link { position: relative; display: block; aspect-ratio: 16 / 9; background: #000; cursor: pointer; text-decoration: none; }
.vod-thumb-link img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vod-thumb-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2a1a4a, #18181b);
  color: var(--purple-light); font-weight: 800; font-size: 24px;
}
.vod-duration {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0, 0, 0, 0.8); color: #fff;
  font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px;
}
.vod-new {
  position: absolute; top: 6px; left: 6px;
  background: var(--green); color: #000;
  font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 4px;
  letter-spacing: 0.04em;
}

.vod-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.vod-title {
  font-size: 14px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--text); text-decoration: none; cursor: pointer;
}
.vod-title:hover { color: var(--purple-light); }
.vod-meta { font-size: 12px; color: var(--text-dim); }
.vod-meta .vod-channel { color: var(--purple-light); font-weight: 600; }

.vod-actions { margin-top: auto; padding-top: 8px; }
.btn-watch-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px; padding: 5px 10px;
  border-radius: 6px; cursor: pointer;
}
.btn-watch-toggle:hover { color: var(--text); background: var(--bg-hover); }

/* ---------- Loader ---------- */

.loader {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg-alt); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 30px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-dim); z-index: 50;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--purple);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .calendar-grid { grid-template-columns: 1fr; gap: 14px; }
  .day-col { gap: 6px; }
  .day-head { text-align: left; padding: 8px 12px; display: flex; align-items: baseline; gap: 8px; }
  .day-head .day-num { display: inline; font-size: 15px; }
  .day-empty { text-align: left; padding: 4px 12px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tab { flex: 1; justify-content: center; }
  #week-label { min-width: 0; }
}
