/* ============================================================
   Fixarr — thème sombre, mobile-first, zéro dépendance.
   Système : jetons ci-dessous (couleurs, rayons, vitesses).
   Échelle d'espacement : multiples de 4 px.
   ============================================================ */

:root {
  --bg: #101418;
  --bg-card: #1a2027;
  --bg-card-hover: #202832;
  --bg-inset: #141a20;
  --border: #29323d;
  --border-strong: #37424f;
  --text: #e6ecf2;
  --text-dim: #98a5b3;
  --text-faint: #6a7683;
  --accent: #4db8e8;
  --accent-hover: #6ac5ee;
  --accent-soft: rgba(77, 184, 232, 0.14);
  --on-accent: #0b1d29;
  --ok: #4cba7d;
  --warn: #dfa640;
  --err: #e26b6b;
  --err-soft: rgba(226, 107, 107, 0.12);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --speed: 130ms;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ------------------------------------------------ Base */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

::placeholder { color: var(--text-faint); opacity: 1; }
::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* ------------------------------------------------ Utilitaires */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.pad { padding: 10px 12px; }
.error-text { color: var(--err); }

.icon { display: inline-flex; flex: none; }
.icon svg { display: block; width: 18px; height: 18px; }

.boot {
  padding: 48px 16px;
  text-align: center;
}

/* ------------------------------------------------ Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--speed) ease, border-color var(--speed) ease,
    color var(--speed) ease;
}
.btn:hover:not(:disabled) { background: var(--bg-card-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-card);
  color: var(--text);
}

.btn-sm {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block { width: 100%; }

/* ------------------------------------------------ Formulaires */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

input[type="text"],
input[type="password"],
input[type="search"] {
  appearance: none;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.form-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--err);
  background: var(--err-soft);
  border: 1px solid var(--err);
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------ Login */
.view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.login-brand .icon { color: var(--accent); }
.login-brand .icon svg { width: 24px; height: 24px; }
.login-brand h1 {
  font-size: 26px;
  letter-spacing: 0.3px;
}

.login-sub {
  margin-bottom: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
}

/* ------------------------------------------------ En-tête */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand .icon { color: var(--accent); }
.brand .icon svg { width: 20px; height: 20px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.user-line strong {
  color: var(--text);
  font-weight: 600;
}

/* ------------------------------------------------ Recherche */
.search-box {
  position: relative;
  margin: 18px 0 22px;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  display: inline-flex;
  color: var(--text-faint);
  pointer-events: none;
}
.search-icon svg { display: block; width: 20px; height: 20px; }

#search-input {
  min-height: 52px;
  padding-left: 44px;
  font-size: 16px;
  border-radius: var(--radius);
}

.section-title {
  margin: 4px 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dim);
}

.page-title {
  margin: 20px 0 14px;
  font-size: 20px;
}

/* ------------------------------------------------ Cartes médias */
.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.media-card {
  display: flex;
  gap: 14px;
  padding: 12px;
}

.poster {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 64px;
  height: 96px;
  overflow: hidden;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-faint);
}
.poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-body {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.media-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.media-title {
  font-size: 16px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.media-year {
  font-size: 13px;
  color: var(--text-dim);
}

.badge {
  flex: none;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
}

.version {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.chip {
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
}

.release {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-faint);
}

.media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

/* ------------------------------------------------ Série : saisons + épisodes */
.series-head { margin: 16px 0 20px; }
.series-head .poster {
  width: 80px;
  height: 120px;
}
.series-head .media-title { font-size: 19px; }

.season-card { padding: 6px; }

.season-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.season-toggle {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--speed) ease;
}
.season-toggle:hover { background: var(--bg-card-hover); }

.season-toggle .chev {
  color: var(--text-faint);
  transition: transform var(--speed) ease;
}
.season-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }

.season-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
  min-width: 0;
}

.season-name {
  font-weight: 600;
  white-space: nowrap;
}

.season-count {
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-dim);
}

.episodes {
  margin-top: 4px;
  padding: 2px 6px 6px;
  border-top: 1px solid var(--border);
}

.ep-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.ep-row:last-child { border-bottom: 0; }

.ep-num {
  flex: none;
  width: 28px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-faint);
}

.ep-text {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.ep-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
}

/* ------------------------------------------------ Mes demandes */
.request-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.request-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.request-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.request-ts { flex: none; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.status-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.st-ok { color: var(--ok); }
.st-warn { color: var(--warn); }
.st-err { color: var(--err); }
.st-info { color: var(--accent); }

/* ------------------------------------------------ Journal admin */
.table-wrap {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.journal {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
}

.journal th,
.journal td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.journal th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

.journal tr:last-child td { border-bottom: 0; }

.cell-title {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------ Modale */
dialog.modal {
  width: min(calc(100vw - 32px), 430px);
  margin: auto;
  padding: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog.modal::backdrop { background: rgba(5, 8, 11, 0.65); }

.modal-inner { padding: 22px 20px 20px; }

.modal-inner h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.modal-target {
  margin-bottom: 12px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}

.modal-text {
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--text-dim);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

/* ------------------------------------------------ Toasts */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 14px;
  font-size: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--speed) ease, transform var(--speed) ease;
}
.toast.show {
  opacity: 1;
  transform: none;
}

.toast-success { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--err); }

/* ------------------------------------------------ Écrans plus larges */
@media (min-width: 640px) {
  .container { padding: 0 24px; }

  .media-card { padding: 16px; }

  .poster {
    width: 72px;
    height: 108px;
  }

  .series-head .poster {
    width: 96px;
    height: 144px;
  }

  .toasts {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 360px;
  }
}

/* ------------------------------------------------ Mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { transition: none !important; }
}

.status-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.status-detail {
  max-width: 60ch;
  line-height: 1.35;
}
