/* ============================================================================
   GPP Flyer — v6 : inspecteur à onglets contextuels (façon Canva / DesignWiz)
   Chargé APRÈS app.css et v5.css. Ne modifie aucune règle existante, ajoute
   uniquement la couche de présentation du panneau de propriétés.
   ============================================================================ */

/* ---------- Conteneur général de l'inspecteur ---------- */
.inspector {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-left: 1px solid #e6ebf2;
  width: var(--insp, 320px);
  min-width: 0;
}

/* le titre historique "Propriétés" devient inutile : l'en-tête le remplace */
.inspector > h3 { display: none; }

/* ---------- Barre d'onglets (icônes + libellé court) ---------- */
.insp-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid #eef2f8;
  flex: 0 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.insp-tabs::-webkit-scrollbar { height: 0; }

.insp-tabs .itab {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 6px 1px 8px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: #8794a8;
  transition: color .12s, background .12s;
  position: relative;
}
.insp-tabs .itab .ic { font-size: 16px; line-height: 1; }
.insp-tabs .itab .lb {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
  font-family: Inter, system-ui, sans-serif;
}
.insp-tabs .itab:hover { background: #f6f8fc; color: #4a5a72; }
.insp-tabs .itab.active { color: #0A1628; }
.insp-tabs .itab.active::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px; bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: #F59E0B;
}

/* ---------- En-tête : nom de l'objet + actions rapides ---------- */
.insp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid #f1f4f9;
  flex: 0 0 auto;
}
.insp-head .ih-left {
  display: flex; align-items: center; gap: 7px; min-width: 0;
}
.insp-head .ih-ic {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: #f1f5fb;
  color: #51617a;
  font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.insp-head .ih-name {
  font-size: 12.5px; font-weight: 700; color: #2b3a52;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.insp-head .ih-right { display: flex; gap: 2px; flex: 0 0 auto; }
.insp-head .ih-btn {
  border: 0; background: transparent;
  width: 26px; height: 26px; border-radius: 7px;
  cursor: pointer; font-size: 12.5px; color: #5a6a82;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.insp-head .ih-btn:hover { background: #eef2f8; }
.insp-head .ih-btn.danger:hover { background: #fde8e8; color: #dc2626; }

/* ---------- Barre d'alignement rapide ---------- */
.insp-align {
  padding: 6px 8px 8px;
  border-bottom: 1px solid #f1f4f9;
  flex: 0 0 auto;
  display: flex; flex-direction: column; gap: 4px;
}
.insp-align .al-row {
  display: flex; align-items: center; gap: 2px;
}
.insp-align .al {
  flex: 1 1 0; min-width: 0;
  height: 26px;
  border: 1px solid transparent;
  background: #f7f9fc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px; color: #4a5a72;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, border-color .12s, color .12s;
}
.insp-align .al:hover { background: #eaf0f9; border-color: #dbe3ef; color: #0A1628; }
.insp-align .al:active { background: #0A1628; color: #fff; }
.insp-align .al-sep { width: 1px; height: 18px; background: #e6ebf2; margin: 0 3px; flex: 0 0 auto; }

/* ---------- Zone des panneaux ---------- */
.insp-panes {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 10px 28px;
}
.insp-panes::-webkit-scrollbar { width: 8px; }
.insp-panes::-webkit-scrollbar-thumb { background: #dde4ee; border-radius: 8px; }
.insp-panes::-webkit-scrollbar-track { background: transparent; }

.ipane { display: none; }
.ipane.active { display: block; }

/* harmonisation des contrôles à l'intérieur des onglets */
.insp-panes h3 {
  font-size: 10.5px !important;
  font-weight: 800 !important;
  letter-spacing: .55px;
  text-transform: uppercase;
  color: #93a0b4 !important;
  margin: 14px 0 7px !important;
}
.insp-panes h3:first-child { margin-top: 0 !important; }
.insp-panes .sep { height: 1px; background: #f1f4f9; margin: 12px 0; border: 0; }

/* champs plus compacts et lisibles */
.insp-panes .lbl {
  font-size: 10.5px;
  font-weight: 700;
  color: #7b8798;
  letter-spacing: .2px;
}
.insp-panes input[type="number"],
.insp-panes input[type="text"],
.insp-panes select.sel {
  height: 28px;
  font-size: 12px;
  border-radius: 7px;
  border: 1px solid #e3e8f0;
  background: #fbfcfe;
  color: #2b3a52;
  padding: 0 7px;
  transition: border-color .12s, box-shadow .12s;
}
.insp-panes input[type="number"]:focus,
.insp-panes input[type="text"]:focus,
.insp-panes select.sel:focus {
  outline: none;
  border-color: #F59E0B;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .13);
  background: #fff;
}
.insp-panes input[type="color"] {
  height: 28px; width: 100%;
  padding: 2px; border-radius: 7px;
  border: 1px solid #e3e8f0; background: #fff; cursor: pointer;
}
.insp-panes input[type="range"] {
  width: 100%; height: 18px; accent-color: #F59E0B; cursor: pointer;
}
.insp-panes .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.insp-panes .lbl { display: flex; flex-direction: column; gap: 3px; }

/* boutons de l'inspecteur */
.insp-panes .btn.ghost.sm,
.insp-panes .btn.sm {
  height: 28px;
  font-size: 11.5px;
  border-radius: 7px;
}
.insp-panes .btn.ghost {
  background: #f7f9fc;
  border: 1px solid #e3e8f0;
  color: #41526b;
}
.insp-panes .btn.ghost:hover { background: #eef2f8; border-color: #d6dfec; color: #0A1628; }

/* état "actif" partagé pour les boutons de style texte */
.insp-panes .btn.on,
.btn.on {
  background: #0A1628 !important;
  border-color: #0A1628 !important;
  color: #fff !important;
}

/* cases à cocher */
.insp-panes .chk {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 600; color: #4a5a72;
  padding: 5px 0;
  cursor: pointer;
}
.insp-panes .chk input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: #F59E0B; cursor: pointer; flex: 0 0 auto;
}

/* ---------- État vide ---------- */
#insp-empty {
  margin: 14px 10px;
  padding: 18px 14px;
  background: #f9fbfd;
  border: 1px dashed #dbe3ef;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #8794a8;
  text-align: center;
}
#insp-empty::before {
  content: "✥";
  display: block;
  font-size: 24px;
  margin-bottom: 8px;
  color: #c8d2e0;
}

/* ---------- Mobile : l'inspecteur devient un panneau glissant ---------- */
@media (max-width: 820px) {
  .inspector {
    position: fixed;
    right: 0; bottom: 0;
    top: var(--topbar, 54px);
    width: min(320px, 92vw);
    z-index: 60;
    box-shadow: -10px 0 34px rgba(10, 22, 40, .18);
    transform: translateX(100%);
    transition: transform .2s ease;
    display: flex !important;
  }
  .inspector.open { transform: translateX(0); }
  /* rien de sélectionné -> pas besoin du panneau */
  #view-app.insp-collapsed .inspector { transform: translateX(100%); }
  .insp-panes { padding-bottom: 90px; }
}

/* masque les anciens boutons d'ordre de l'onglet Position (doublons) */
.insp-panes .hidden-dup { display: none !important; }

/* champs X/Y/L/H : le libellé au-dessus, l'input en dessous, propre */
.insp-panes .row2 > .lbl > input,
.insp-panes .row2 > .lbl > select { width: 100%; }

/* ---------- Onglet Texte : bloc typographique ---------- */
.typo-block h3 {
  font-size: 10.5px !important;
  font-weight: 800 !important;
  letter-spacing: .55px;
  text-transform: uppercase;
  color: #93a0b4 !important;
  margin: 12px 0 6px !important;
}
.typo-block h3:first-child { margin-top: 0 !important; }
.typo-block .typo-row {
  display: flex; align-items: center; gap: 3px; flex-wrap: nowrap;
}
.typo-block .typo-btn {
  flex: 1 1 0; min-width: 0;
  height: 30px;
  border: 1px solid #e3e8f0;
  background: #f8fafc;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
  color: #41526b;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, border-color .12s, color .12s;
}
.typo-block .typo-btn:hover { background: #eef2f8; border-color: #d6dfec; color: #0A1628; }
.typo-block .typo-btn.on {
  background: #0A1628 !important;
  border-color: #0A1628 !important;
  color: #fff !important;
}
.typo-block .al-sep { width: 1px; height: 20px; background: #e6ebf2; margin: 0 2px; flex: 0 0 auto; }

/* ---------- Densification finale de l'onglet Texte (aspect fini) ---------- */
.insp-panes .ipane[data-tab="text"] .sep { display: none; }
.typo-block h3 {
  margin: 14px 0 7px !important;
  padding-bottom: 4px;
  border-bottom: 0;
}
.typo-block h3:first-child { margin-top: 0 !important; }
.typo-block .row2 { margin-bottom: 2px; }
.typo-block input[type="color"] {
  width: 100%;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e3e8f0;
  cursor: pointer;
  padding: 3px;
}
.typo-block .lbl { margin-bottom: 0; }

/* le select de police prend toute la largeur */
.typo-block #iv-font { width: 100%; height: 32px; font-weight: 600; }
.typo-block .typo-row { gap: 4px; margin-bottom: 2px; }

/* ---------- Suppression définitive des séparateurs fantômes ---------- */
.inspector .sep,
.insp-panes .sep,
.ipane .sep,
.typo-block .sep {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  background: none !important;
}
/* le panneau ne doit pas s'étirer au-delà de son contenu */
.inspector { justify-content: flex-start; }
#insp-body { height: auto !important; min-height: 0; }
.insp-panes { flex: 0 1 auto; }

/* ---------- Polissage pixel-perfect ---------- */
.insp-panes .row2 { grid-template-columns: 1fr 1fr; gap: 7px; }
.insp-panes .row2 > .lbl > input,
.insp-panes .row2 > .lbl > select { width: 100%; box-sizing: border-box; }

/* centrage vertical parfait des libellés dans les boutons typo */
.typo-block .typo-btn,
.insp-align .al,
.insp-tabs .itab { line-height: 1; }

/* le curseur reste fin, la poignée discrète */
.insp-panes input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  background: transparent;
}
.insp-panes input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px; background: #e3e8f0;
}
.insp-panes input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; margin-top: -5px;
  border-radius: 50%; background: #F59E0B;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(10,22,40,.25);
  cursor: pointer;
}

/* ---------- Bouton flottant mobile pour ouvrir les propriétés ---------- */
.insp-toggle {
  display: none;
  position: fixed;
  right: 14px;
  bottom: 78px;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 0;
  background: #0A1628;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  z-index: 55;
  box-shadow: 0 6px 20px rgba(10, 22, 40, .30);
  align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
}
.insp-toggle:active { transform: scale(.94); }
.insp-toggle.active { background: #F59E0B; color: #0A1628; }

@media (max-width: 820px) {
  .insp-toggle { display: inline-flex; }
  /* quand le drawer est ouvert, le bouton passe au-dessus */
  .insp-toggle.active { right: calc(min(320px, 92vw) - 42px); }
}
