/* ============================================================
   style.css — Design sombre & moderne — Pleymove Tools
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --bg-base:       #0f1117;
  --bg-surface:    #1a1d27;
  --bg-elevated:   #232638;
  --bg-hover:      #2a2e42;
  --border:        #2e3249;
  --accent:        #6c63ff;
  --accent-hover:  #5a52e0;
  --accent-soft:   rgba(108, 99, 255, 0.15);
  --text-primary:  #e8eaf0;
  --text-secondary:#8b90a8;
  --text-muted:    #555b76;
  --danger:        #e05c5c;
  --success:       #50c878;
  --warning:       #f0a940;
  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     18px;
  --shadow-md:     0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg:     0 8px 40px rgba(0, 0, 0, 0.6);
  --transition:    0.2s ease;
  --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
  --header-h:      60px;
  --toolbar-h:     52px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  font-size: 16px;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── En-tête ──────────────────────────────────────────────── */
.header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
}

.header__inner {
  max-width: 900px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header__logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.header__tagline {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.header__tagline::before { content: '/'; margin-right: 0.75rem; color: var(--text-muted); }

/* ── Contenu principal ────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* En mode éditeur, .main prend toute la largeur sans padding */
.main--editor {
  max-width: 100%;
  padding: 0;
}

/* ── Pages (SPA) ──────────────────────────────────────────── */
.page { display: none; }
.page--active { display: block; }

.page__title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page__subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 600px;
  font-size: 0.95rem;
}

/* ── Grille des outils ────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              transform var(--transition), box-shadow var(--transition);
  text-align: left;
  color: inherit;
  font-family: inherit;
  width: 100%;
}

.tool-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tool-card:active { transform: translateY(0); }

.tool-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tool-card__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.tool-card__icon svg { width: 22px; height: 22px; }
.tool-card__body { flex: 1; }
.tool-card__name { font-size: 1rem; font-weight: 600; margin-bottom: 0.2rem; }
.tool-card__desc { font-size: 0.825rem; color: var(--text-secondary); line-height: 1.4; }
.tool-card__arrow { color: var(--text-muted); font-size: 1.2rem; transition: color var(--transition); }
.tool-card:hover .tool-card__arrow { color: var(--accent); }

/* ── Bouton Retour (page upload) ──────────────────────────── */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.4rem 0;
  margin-bottom: 1.5rem;
  transition: color var(--transition);
}
.btn-back:hover { color: var(--text-primary); }

/* ── Zone de drop ─────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  margin-bottom: 1.5rem;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.drop-zone__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  pointer-events: none;
}

.drop-zone__inner label { pointer-events: auto; }

.drop-zone__icon { width: 48px; height: 48px; color: var(--accent); opacity: 0.8; }
.drop-zone__text { font-size: 1rem; font-weight: 500; }
.drop-zone__hint { font-size: 0.825rem; color: var(--text-muted); }
.drop-zone__limit { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Boutons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--secondary { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border); }
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--accent); }

.btn--ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn--ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }

.btn--sm { padding: 0.4rem 0.9rem; font-size: 0.825rem; }

.btn--icon {
  padding: 0.4rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Loader ───────────────────────────────────────────────── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.loader__spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Message box ──────────────────────────────────────────── */
.message-box {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid;
}

.message-box--error   { background: rgba(224,92,92,.12); border-color: var(--danger);  color: #f0a0a0; }
.message-box--info    { background: rgba(80,200,120,.10); border-color: var(--success); color: #90d8aa; }
.message-box--warning { background: rgba(240,169,64,.10); border-color: var(--warning); color: #f5c980; }

/* ── Badge ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ── Phase upload ─────────────────────────────────────────── */
#upload-phase { padding: 2.5rem 1.5rem; max-width: 900px; margin: 0 auto; }

/* ── Phase éditeur ─────────────────────────────────────────── */
.editor-phase {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h));
  position: relative;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.75rem;
  height: var(--toolbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  position: sticky;
  top: var(--header-h);
  z-index: 150;
}

.toolbar::-webkit-scrollbar { height: 3px; }
.toolbar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.toolbar__sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 0.2rem;
}

.toolbar__spacer { flex: 1; }

.toolbar__group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.toolbar__group--typo { gap: 0.4rem; }

.toolbar__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  flex-shrink: 0;
  font-family: inherit;
  font-size: 0.85rem;
}

.toolbar__btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.toolbar__btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.toolbar__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toolbar__btn--back { color: var(--text-secondary); }

.toolbar__filename {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.toolbar__select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  height: 32px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.toolbar__select:focus { border-color: var(--accent); }

.toolbar__input--size {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.4rem;
  height: 32px;
  width: 52px;
  text-align: center;
  outline: none;
  transition: border-color var(--transition);
}
.toolbar__input--size:focus { border-color: var(--accent); }

.toolbar__unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.toolbar__color {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  padding: 2px;
  transition: border-color var(--transition);
  flex-shrink: 0;
}
.toolbar__color:hover { border-color: var(--accent); }
.toolbar__color:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Zone de scroll du canvas ─────────────────────────────── */
.editor-scroll {
  flex: 1;
  overflow: auto;
  background: #111318;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem 1rem;
  gap: 1.25rem;
}

/* Loader de rendu de page */
.render-loader {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 0.75rem 0;
}

/* Indication mode texte */
.text-mode-hint {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.4rem 1rem;
  font-size: 0.825rem;
  text-align: center;
  animation: fadeIn 0.2s ease;
  pointer-events: none;
}

/* ── Canvas empilés (PDF.js + Fabric.js) ─────────────────── */
.canvas-outer {
  position: relative;
  box-shadow: 0 8px 48px rgba(0,0,0,0.7);
  border-radius: 2px;
  /* width et height posés dynamiquement en JS */
  flex-shrink: 0;
}

#pdf-canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  border-radius: 2px;
}

/* Fabric.js crée un .canvas-container qu'on place par-dessus le PDF canvas */
.canvas-outer .canvas-container {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
}

/* Le canvas Fabric supérieur indique un curseur contextuel */
.canvas-outer .upper-canvas {
  border-radius: 2px;
}

/* Curseur texte en mode texte */
.canvas-outer.mode-text .upper-canvas {
  cursor: text !important;
}

/* ── Navigation entre pages ───────────────────────────────── */
.page-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0 1.5rem;
  flex-shrink: 0;
}

.page-nav__info {
  font-size: 0.875rem;
  color: var(--text-secondary);
  min-width: 90px;
  text-align: center;
}

/* ── Panneau AcroForm latéral ─────────────────────────────── */
.acro-panel {
  position: fixed;
  right: 0;
  top: calc(var(--header-h) + var(--toolbar-h));
  bottom: 0;
  width: 300px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  animation: slideIn 0.25s ease;
  overflow: hidden;
}

@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }

.acro-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.acro-panel__title {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.acro-panel__close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: color var(--transition);
  padding: 0.2rem;
}
.acro-panel__close:hover { color: var(--text-primary); }

.acro-fields-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.acro-field {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  transition: border-color var(--transition);
}
.acro-field:focus-within { border-color: var(--accent); }

.acro-field__label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.acro-field__name { font-size: 0.78rem; font-weight: 500; word-break: break-all; }

.acro-field__type {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 0.05rem 0.4rem;
}

.acro-field__input {
  width: 100%;
  background: var(--bg-hover);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  outline: none;
  transition: border-color var(--transition);
}
.acro-field__input:focus { border-color: var(--accent); }

.acro-field__checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.acro-field__checkbox {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 3px;
  background: var(--bg-hover);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
  position: relative;
}
.acro-field__checkbox:checked { background: var(--accent); border-color: var(--accent); }
.acro-field__checkbox:checked::after {
  content: '';
  position: absolute;
  left: 3px; top: 0px;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

.acro-panel__footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.acro-panel__note { font-size: 0.75rem; color: var(--text-muted); }

/* Bouton flottant d'accès au panneau AcroForm */
.acro-toggle {
  position: fixed;
  right: 1rem;
  bottom: 5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  font-family: inherit;
  box-shadow: var(--shadow-md);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  z-index: 90;
}
.acro-toggle:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--text-primary); }

/* ── Pied de page ─────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* En mode éditeur, le footer est masqué pour maximiser l'espace */
.footer--hidden { display: none; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Utilitaires ──────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .page__title   { font-size: 1.4rem; }
  .drop-zone     { padding: 2rem 1.25rem; }
  .toolbar__filename { display: none; }
  .acro-panel    { width: 100%; }
  .toolbar__group--typo .toolbar__select { max-width: 100px; }
}
