/* ═══════════════════════════════════════════════════════════════
   GENERATOR.CSS · Styles du Générateur d'étiquettes
   Dépend de common.css (variables, reset, boutons, modals)
   ═══════════════════════════════════════════════════════════════ */

/* ───── Layout principal ───── */
#generator-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ───── Header ───── */
#gen-header {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#gen-header .logo {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  letter-spacing: -.3px;
  white-space: nowrap;
}
#gen-header .logo a {
  color: var(--primary);
  text-decoration: none;
}
#gen-header .logo a:hover { opacity: .8; }
#gen-header h1 {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}
#gen-header .template-name {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-panel);
  padding: 4px 10px;
  border-radius: var(--radius);
}

/* ───── Contenu principal (2 colonnes) ───── */
#gen-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow: hidden;
}

/* ───── Panneau de saisie (gauche) ───── */
#gen-input {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* Description du template */
.gen-description {
  padding: 12px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Zone de configuration */
.gen-config {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.gen-config label {
  font-size: 11px;
  color: var(--text-dim);
}
.start-pos-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.start-pos-ctrl {
  display: flex;
  align-items: center;
  gap: 0;
}
.start-pos-ctrl input {
  width: 48px;
  text-align: center;
  border-radius: 0;
  -moz-appearance: textfield;
}
.start-pos-ctrl input::-webkit-inner-spin-button,
.start-pos-ctrl input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.start-pos-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
  transition: all .15s;
}
.start-pos-btn:first-child { border-radius: 4px 0 0 4px; }
.start-pos-btn:last-child { border-radius: 0 4px 4px 0; }
.start-pos-btn:hover:not(:disabled) { background: var(--primary-glow); color: var(--primary); }
.start-pos-btn:disabled { opacity: .3; cursor: default; }
.gen-config input, .gen-config select {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-light);
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 4px;
}
.gen-config input:focus, .gen-config select:focus {
  border-color: var(--primary);
  outline: none;
}
.gen-config input[type="number"] { width: 60px; }

/* ───── Date config ───── */
#gen-date-config {
  width: 100%;
  margin-top: 6px;
}
.date-config-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
  display: block;
}
.date-var-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.date-var-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  min-width: 70px;
}
.date-var-mode {
  font-size: 11px;
  min-width: 110px;
}
.date-var-input {
  font-size: 11px;
  min-width: 130px;
  color-scheme: dark;
}
[data-theme="light"] .date-var-input {
  color-scheme: light;
}
.date-var-format {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}

/* Couleur de fond des lignes */
.gen-config .color-option {
  display: flex;
  align-items: center;
  gap: 6px;
}
.gen-config .color-option input[type="color"] {
  width: 26px;
  height: 22px;
  padding: 1px;
  border-radius: 4px;
  cursor: pointer;
}

/* Zone de saisie texte */
.gen-text-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.gen-text-header {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
}
.gen-text-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
}
.gen-text-header .btn { font-size: 10px; height: 24px; }

#gen-textarea {
  flex: 1;
  width: 100%;
  resize: none;
  background: var(--bg-dark);
  border: none;
  color: var(--text-light);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 12px 16px;
  line-height: 1.6;
  outline: none;
}
#gen-textarea::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

/* Boutons d'import */
.gen-import {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* ───── Drag & drop sur la zone de données ───── */
.gen-text-area.dragover {
  position: relative;
}
.gen-text-area.dragover::after {
  content: '📂 Déposez votre fichier ici';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--primary-rgb, 59, 130, 246), .12);
  border: 2px dashed var(--primary);
  border-radius: 6px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  z-index: 10;
  backdrop-filter: blur(2px);
}

/* ───── Multiplicateur ───── */
.multiplier-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.multiplier-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}
.multiplier-ctrl input {
  width: 50px;
  text-align: center;
  -moz-appearance: textfield;
}
.multiplier-ctrl input::-webkit-inner-spin-button,
.multiplier-ctrl input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.multiplier-suffix {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ───── Panneau d'aperçu (droite) ───── */
#gen-preview {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-canvas);
}

.gen-preview-header {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.gen-preview-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  margin-right: 12px;
}
.gen-preview-stats {
  font-size: 10px;
  color: var(--text-dim);
}

/* Zoom controls */
.gen-zoom-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.gen-zoom-wrap label {
  font-size: 12px;
  cursor: default;
}
.gen-zoom-wrap input[type="range"] {
  width: 90px;
  height: 4px;
  accent-color: var(--primary);
  cursor: pointer;
}
.gen-zoom-wrap span {
  font-size: 10px;
  color: var(--text-dim);
  min-width: 32px;
  text-align: right;
}

#gen-preview-scroll {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

/* Aperçu d'une page */
.gen-page {
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
  margin: 0 auto 20px;
  position: relative;
}
.gen-page + .gen-page { margin-top: 16px; }

/* Étiquette dans l'aperçu */
.gen-label {
  position: absolute;
  border: 0.5px dashed #ccc;
  overflow: hidden;
}
/* Étiquettes vides/de remplissage */
.gen-label.placeholder {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 5px,
    rgba(200,200,200,.15) 5px,
    rgba(200,200,200,.15) 10px
  );
}
.gen-label.placeholder::after {
  content: '-';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ccc;
  font-size: 14px;
}
/* Marqueur FAKE : emplacement vide intentionnel (saut de case demandé) */
.gen-label.placeholder.placeholder-fake {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 5px,
    rgba(231, 76, 60, .14) 5px,
    rgba(231, 76, 60, .14) 10px
  );
}
.gen-label.placeholder.placeholder-fake::after {
  content: 'FAKE';
  color: rgba(231, 76, 60, .7);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ───── Popup d'instructions d'impression ───── */
.print-instructions {
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 10px;
}
.print-instructions h4 {
  color: var(--primary);
  font-size: 13px;
  margin-bottom: 10px;
}
.print-instructions ol {
  padding-left: 20px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 2;
}
.print-instructions li { color: var(--text-dim); }
.print-instructions strong { color: var(--text-light); }

/* ───── Sélecteur Excel ───── */
.excel-config {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 10px 0;
}
.excel-config h4 {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 8px;
}
.excel-config .field-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.excel-config label {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 60px;
}
.excel-config select, .excel-config input {
  flex: 1;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-light);
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 4px;
}

/* ───── Loader PDF (animation doc-stack) ───── */
#pdf-loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}
#pdf-loader-overlay.active {
  display: flex;
}
#pdf-loader-card {
  background: var(--surface, var(--bg-sidebar));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 56px 48px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s ease;
  min-width: 440px;
}
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 260px;
  height: 200px;
  flex-shrink: 0;
}
.doc-stack {
  position: relative;
  width: 120px;
  height: 150px;
}
.doc-page {
  position: absolute;
  width: 105px;
  height: 132px;
  background: linear-gradient(135deg, #1e1e2e, #252535);
  border: 1px solid rgba(110,231,183,0.3);
  border-radius: 4px;
  left: 50%;
  transform-origin: bottom center;
}
.doc-page::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 26px; height: 26px;
  background: var(--bg, var(--bg-dark));
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.doc-page::after {
  content: '';
  position: absolute;
  top: 32px; left: 14px; right: 20px;
  height: 3px;
  background: rgba(110,231,183,0.25);
  border-radius: 2px;
  box-shadow:
    0 9px 0 rgba(110,231,183,0.18),
    0 18px 0 rgba(110,231,183,0.12),
    0 27px 0 rgba(110,231,183,0.08),
    0 36px 0 rgba(110,231,183,0.06),
    0 45px 0 rgba(110,231,183,0.05),
    0 54px 0 rgba(110,231,183,0.04),
    0 63px 0 rgba(110,231,183,0.03);
}
.doc-page:nth-child(1) {
  transform: translateX(-50%) translateY(8px) rotate(-6deg);
  opacity: 0.4;
  animation: pageRise 2.4s ease-in-out infinite 0s;
}
.doc-page:nth-child(2) {
  transform: translateX(-50%) translateY(4px) rotate(3deg);
  opacity: 0.65;
  animation: pageRise 2.4s ease-in-out infinite 0.4s;
}
.doc-page:nth-child(3) {
  transform: translateX(-50%) translateY(0px) rotate(0deg);
  opacity: 1;
  animation: pageRise 2.4s ease-in-out infinite 0.8s;
}
@keyframes pageRise {
  0%   { transform: translateX(-50%) translateY(20px) scale(0.9); opacity: 0; }
  20%  { opacity: 1; }
  60%  { transform: translateX(-50%) translateY(0px) scale(1); }
  80%  { opacity: 1; }
  100% { transform: translateX(-50%) translateY(-10px) scale(0.95); opacity: 0; }
}
.doc-scan {
  position: absolute;
  width: 105px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent1, var(--primary)), transparent);
  left: 50%; transform: translateX(-50%);
  top: 20px;
  animation: scanMove 2s ease-in-out infinite;
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent1, var(--primary));
}
@keyframes scanMove {
  0%   { top: 15%; opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { top: 85%; opacity: 0; }
}

/* Console de progression */
.pdf-progress-console {
  width: 100%;
  background: #0d0d14;
  border: 1px solid rgba(110,231,183,0.15);
  border-radius: 10px;
  padding: 16px 18px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: rgba(110,231,183,0.7);
  max-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pdf-progress-log {
  overflow-y: auto;
  max-height: 110px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}
.pdf-progress-log .log-line {
  display: block;
}
.pdf-progress-log .log-line::before {
  content: '> ';
  color: rgba(110,231,183,0.4);
}
.pdf-progress-bar-wrap {
  height: 6px;
  background: rgba(110,231,183,0.1);
  border-radius: 3px;
  overflow: hidden;
}
.pdf-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #6ee7b7);
  border-radius: 3px;
  transition: width 0.15s ease;
}
.pdf-progress-pct {
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: #6ee7b7;
}

/* ───── Responsive : petits écrans ───── */
@media (max-width: 900px) {
  #gen-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  #gen-input { border-right: none; border-bottom: 1px solid var(--border); }
}
