/* SignagePDF — application */

body { background: var(--surface); min-height: 100dvh; }
.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  height: 64px; padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-left));
  background: rgb(255 255 255 / 88%); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 900px) { .topbar { padding: 0 32px; } }
.plan-chip {
  border: 0; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 650;
  background: var(--surface); color: var(--ink-2); font-variant-numeric: tabular-nums;
  transition: background-color var(--t-fast) var(--ease-out);
}
.plan-chip:hover { background: var(--surface-2); color: var(--ink); }
.plan-chip.is-pro { background: var(--ink); color: #fff; letter-spacing: 0.06em; }
.topbar__actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink);
  transition: background-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--surface); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn--quiet { color: var(--ink-2); }
.icon-btn--quiet:hover { color: var(--onair-text); background: #fdecea; }
.icon--fill { fill: currentColor; stroke: none; }

/* Espace de travail */
.workspace {
  flex: 1; width: 100%; max-width: 1360px; margin: 0 auto;
  display: grid; gap: 24px; padding: 24px 16px 48px;
}
@media (min-width: 1000px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; padding: 32px 32px 64px; align-items: start; }
  .broadcast { position: sticky; top: 96px; }
}

.playlist__head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.playlist__head h1 { font-size: 30px; }
.playlist__summary { color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.add-btn { margin-left: auto; align-self: center; }
.is-empty .add-btn, .is-empty .playlist__summary { display: none; }

/* Zone de dépôt : grande quand la playlist est vide, discrète ensuite */
.dropzone {
  display: grid; justify-items: center; gap: 8px; text-align: center; cursor: pointer;
  padding: 18px; border-radius: var(--radius-l); border: 1.5px dashed var(--line-strong); background: var(--paper);
  transition: border-color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.dropzone:hover, .dropzone:focus-within { border-color: var(--ink); }
.dropzone__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--surface); }
.dropzone__title { font: 700 18px/1.2 var(--font-title); letter-spacing: -0.01em; }
.dropzone__hint { color: var(--ink-2); font-size: 15px; max-width: 46ch; }
body:not(.is-empty) .dropzone { display: none; }
.is-empty .dropzone { padding: clamp(48px, 10vh, 96px) 24px; }
.is-empty .dropzone__icon { width: 64px; height: 64px; }
.is-empty .dropzone__title { font-size: clamp(22px, 2.4vw, 28px); }
.dropzone__formats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.dropzone__formats span { padding: 3px 9px; border-radius: 6px; background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 650; }
body:not(.is-empty) .dropzone__formats { display: none; }
.sample { display: none; margin-top: 14px; color: var(--ink-2); font-size: 15px; text-align: center; }
.is-empty .sample { display: block; }
.sample__btn {
  border: 0; padding: 2px 0; background: none; color: var(--ink); font-weight: 650;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px;
  transition: text-decoration-color var(--t-fast) var(--ease-out);
}
.sample__btn:hover { text-decoration-color: var(--onair); }
.sample__btn:disabled { opacity: 0.5; cursor: progress; }

/* Liste */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item {
  display: grid; grid-template-columns: 28px 136px minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 12px; border-radius: var(--radius-m); background: var(--paper); border: 1px solid var(--line);
  transition: opacity var(--t-mid) var(--ease-out), transform var(--t-mid) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.item:hover { border-color: var(--line-strong); }
.item.is-off { opacity: 0.55; }
.item.is-entering { animation: item-in var(--t-slow) var(--ease-out) both; }
.item.is-leaving { opacity: 0; transform: translateX(-12px) scale(0.98); }
.item.is-dragging { opacity: 0.6; box-shadow: var(--shadow-pop); }
@keyframes item-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
.item__grip {
  align-self: center; display: grid; place-items: center; width: 28px; height: 44px; border: 0; border-radius: 8px;
  background: transparent; color: var(--line-strong); cursor: grab;
}
.item__grip:hover { color: var(--ink-2); background: var(--surface); }
.item__grip .icon { fill: currentColor; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000;
  box-shadow: inset 0 0 0 1px rgb(21 23 28 / 8%);
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb__type {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 7px; border-radius: 6px;
  background: rgb(21 23 28 / 78%); color: #fff; font-size: 11px; font-weight: 650;
}
.thumb--loading { background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0 / 300% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.item__body { min-width: 0; }
.item__name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__meta { color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.item__options { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; margin-top: 10px; }
.opt { display: grid; gap: 4px; font-size: 14px; }
.opt__label { color: var(--ink-2); font-size: 13px; }
.opt select {
  height: 36px; padding: 0 30px 0 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--paper);
  appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat;
}
.opt--check { display: flex; align-items: center; gap: 8px; height: 36px; cursor: pointer; }
.opt--check input { width: 18px; height: 18px; accent-color: var(--ink); }
.item__side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.item.is-pending { opacity: 0.8; }

/* Sélecteur de durée */
.stepper { display: inline-flex; align-items: center; height: 36px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--paper); }
.stepper[data-disabled] { opacity: 0.45; }
.stepper__btn { display: grid; place-items: center; width: 34px; height: 100%; border: 0; background: transparent; color: var(--ink-2); border-radius: 10px; }
.stepper__btn:hover:not(:disabled) { color: var(--ink); background: var(--surface); }
.stepper__btn .icon { width: 16px; height: 16px; }
.stepper__value { display: flex; align-items: baseline; gap: 2px; padding: 0 2px; }
.stepper input {
  width: 3.4ch; border: 0; background: transparent; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }
.stepper span { color: var(--ink-2); font-size: 14px; }

/* Interrupteur */
.switch {
  appearance: none; position: relative; width: 44px; height: 26px; margin: 0; border-radius: 999px; cursor: pointer;
  background: var(--line-strong); transition: background-color var(--t-mid) var(--ease-out);
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform var(--t-mid) var(--ease-out), width var(--t-fast) var(--ease-out);
}
.switch:active::after { width: 24px; }
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(18px); }
.switch:checked:active::after { transform: translateX(14px); }

/* Panneau de diffusion */
.broadcast { display: grid; gap: 12px; padding: 16px; border-radius: var(--radius-l); background: var(--paper); border: 1px solid var(--line); }
.screen {
  position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #0d0e11;
  box-shadow: 0 0 0 6px #1d1f25, 0 18px 40px -18px rgb(21 23 28 / 55%); margin: 6px 6px 14px;
}
.screen__media { position: absolute; inset: 0; transition: background-color var(--t-slow) var(--ease-out); }
.screen__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 500ms var(--ease-out); }
.screen__media img.is-in { opacity: 1; }
.screen__status {
  /* En haut à droite : la plupart des affiches ont leur titre en haut à gauche et leur prix en bas. */
  position: absolute; right: 10px; top: 10px; display: inline-flex; align-items: center; gap: 7px; max-width: calc(100% - 20px);
  padding: 4px 10px; border-radius: 999px; background: rgb(13 14 17 / 72%); color: #fff; font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(6px);
}
.screen__status .live-dot { flex: none; }
.screen__empty { position: absolute; inset: 24px 0 0; display: none; place-items: center; padding: 0 24px; color: #8b919c; font-size: 14px; text-align: center; }
.is-empty .screen__empty { display: grid; }
.broadcast__loop { color: var(--ink-2); font-size: 15px; }
.broadcast__go { min-height: 54px; font-size: 17px; }
.broadcast__tip { color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.upsell { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius-m); background: var(--surface); font-size: 14px; }
.upsell .btn { justify-self: start; }

/* Superposition de dépôt */
.drop-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; pointer-events: none;
  background: rgb(21 23 28 / 55%); opacity: 0; transition: opacity var(--t-mid) var(--ease-out);
}
.drop-overlay p {
  padding: 22px 30px; border-radius: var(--radius-l); background: var(--paper); font: 700 22px/1.2 var(--font-title);
  transform: scale(0.96); transition: transform var(--t-mid) var(--ease-out); box-shadow: var(--shadow-pop);
}
.drop-overlay.is-on { opacity: 1; }
.drop-overlay.is-on p { transform: none; }

/* Fenêtres (réglages, licence) */
.sheet {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: var(--radius-l);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-pop); overflow: auto;
}
.sheet::backdrop { background: rgb(21 23 28 / 45%); backdrop-filter: blur(2px); }
.sheet[open] { animation: sheet-in var(--t-slow) var(--ease-out); }
.sheet[open]::backdrop { animation: fade-in var(--t-mid) var(--ease-out); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }
.sheet__inner { display: grid; gap: 4px; padding: 22px 24px 24px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet__head h2 { font-size: 24px; }
.sheet__block { display: grid; gap: 10px; padding: 16px 0; border-top: 1px solid var(--line); }
.sheet__block h3 { font-size: 17px; letter-spacing: -0.01em; }
.sheet__foot { padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }
.muted { color: var(--ink-2); font-size: 14px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-row small { display: block; color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.switch-row .switch { flex: none; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field { position: relative; display: inline-flex; align-items: center; }
.field input {
  height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--paper); width: 110px;
  font-variant-numeric: tabular-nums; transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.field input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgb(21 23 28 / 10%); }
.field__unit { position: absolute; right: 12px; color: var(--ink-2); pointer-events: none; }
.field--grow { flex: 1 1 260px; }
.field--grow input { width: 100%; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 14px; letter-spacing: 0.02em; }
.danger { color: var(--onair-text); }

.lic-reason { margin-bottom: 14px; padding: 10px 14px; border-radius: 12px; background: #fdecea; color: #8d1d15; font-size: 15px; }
.lic-price { font-size: 18px; margin-bottom: 4px; }
.lic-price strong { font: 700 44px/1 var(--font-title); letter-spacing: -0.03em; margin-right: 6px; }
.ticks { list-style: none; padding: 0; margin: 10px 0 18px; display: grid; gap: 8px; }
.ticks li { display: flex; gap: 10px; align-items: center; }
.ticks .icon { color: var(--ok); }
.lic-buy { width: 100%; min-height: 56px; font-size: 17px; }
.lic-secure { margin-top: 8px; }
.lic-key { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.lic-key summary { cursor: pointer; font-weight: 650; padding: 4px 0; }
.lic-key form { margin-top: 10px; }
.form-error { margin-top: 8px; color: var(--onair-text); font-size: 14px; }
.shake { animation: shake 360ms var(--ease-out); }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

.waiting { display: flex; gap: 16px; align-items: flex-start; padding: 16px; margin-bottom: 14px; border-radius: var(--radius-m); background: var(--surface); }
.spinner { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--onair); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.lic-step[data-step="waiting"] > .muted { margin-top: 12px; }

.done { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 18px 0 6px; }
.done h3 { font-size: 24px; }
.done__badge { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--ok); color: #fff; }
.done__badge .icon { width: 36px; height: 36px; stroke-width: 2.4; stroke-dasharray: 30; stroke-dashoffset: 0; }
.is-celebrating .done__badge { animation: pop 520ms var(--ease-out) both; }
.is-celebrating .done__badge .icon { animation: draw 420ms 220ms var(--ease-out) both; }
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes draw { from { stroke-dashoffset: 30; } }

/* Notifications */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(520px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0;
  padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 15px; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(10px); transition: opacity var(--t-mid) var(--ease-out), transform var(--t-mid) var(--ease-out);
}
.toast.is-in { opacity: 1; transform: none; }
.toast--error { background: #8d1d15; }
.toast--warn { background: #3a2f12; }
.toast__action { border: 0; background: transparent; color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 4px; }

/* Lecteur plein écran */
.player { position: fixed; inset: 0; z-index: 100; background: #000; cursor: none; overflow: hidden; }
.player.show-ui { cursor: default; }
.player__layer { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity 600ms ease-in-out; }
.player__layer.is-front { opacity: 1; }
.player__layer > img, .player__layer > video { width: 100%; height: 100%; object-fit: contain; }
.player__layer > canvas { max-width: 100%; max-height: 100%; }
.player__empty { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa0aa; font-size: 20px; text-align: center; padding: 24px; }
.player__watermark {
  position: absolute; right: 24px; bottom: 20px; margin: 0; padding: 8px 14px; border-radius: 999px;
  background: rgb(0 0 0 / 55%); color: rgb(255 255 255 / 85%); font: 600 15px/1 var(--font-text); pointer-events: none;
}
.player__watermark.on-light { background: rgb(255 255 255 / 70%); color: rgb(21 23 28 / 75%); }
.player__bar {
  position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; opacity: 0; transform: translateY(-6px);
  transition: opacity var(--t-mid) var(--ease-out), transform var(--t-mid) var(--ease-out); pointer-events: none;
}
.player.show-ui .player__bar { opacity: 1; transform: none; pointer-events: auto; }
.player__btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 0; border-radius: 999px;
  background: rgb(13 14 17 / 78%); color: #fff; font-weight: 600; backdrop-filter: blur(8px);
}
.player__btn:hover { background: rgb(13 14 17 / 92%); }
.is-playing body { overflow: hidden; }
.screen-mode { background: #000; }

/* Mobile */
@media (max-width: 640px) {
  .item { grid-template-columns: 96px minmax(0, 1fr) auto; gap: 10px; }
  .item__grip { display: none; }
  .playlist__head h1 { font-size: 26px; }
}

/* Avant le démarrage du script (lecture de la playlist enregistrée) : on n'affiche ni l'état vide
   ni l'état rempli, pour éviter un saut de mise en page. */
.is-booting .dropzone, .is-booting .sample, .is-booting .add-btn, .is-booting .plan-chip, .is-booting .screen__empty { visibility: hidden; }

/* Clé affichée après l'achat */
.done__key { display: grid; gap: 8px; width: 100%; margin: 6px 0 8px; padding: 14px; border-radius: var(--radius-m); background: var(--surface); text-align: left; font-size: 15px; }
.done__keybox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.done__keybox code { flex: 1 1 auto; padding: 8px 10px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line-strong); font: 600 14px/1.3 ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: 0.02em; user-select: all; overflow-wrap: anywhere; }
