/* ==========================================================================
   JDVC TOOLBOX - CPT BOX (CPTbox Manager + modules cpt-*)
   Chargé par cptbox-manager.php : admin (après apps.css si présent) et front (priorité 999, après le thème).

   Répartition (critère mesuré sur les modules) :
   - Ce fichier : styles réutilisés par au moins deux CPT (archives front, utilitaires), le gabarit
     commun des pages de Configuration et des sections Permaliens (helpers du manager :
     jdvc_cpt_settings_page, jdvc_cpt_permalinks_register) + les styles du CPTbox Manager.
   - Chaque module cpt-* : ses styles propres, dans /css/cpt/{cpt}.css, chargé par le module lui-même
     (après ce fichier), donc uniquement si ce CPT est actif — et mis en cache par le navigateur.

   Conventions :
   - Classes partagées : .jdvc-cpt-* ; propres à un CPT : .jdvc-{cpt}-{balise}{n} ; manager : .jdvc-cptbox-*
   - Classes issues d'anciens styles inline en !important (conservent la priorité de l'inline), sauf
     display / opacity / visibility / transform, animés en JS.
   - Champs et boutons : variante #wpbody pour repasser devant les surcharges d'admin.css.
   - Restent inline : valeurs dynamiques (dont celles construites par concaténation), display:none basculés
     en JS, e-mails et documents autonomes (impression des cartes fidélité, tickets d'atelier, document de
     signature, pages publiques autonomes).
   ========================================================================== */


/* ==========================================================================
   1. STYLES PARTAGÉS ENTRE CPT
   ========================================================================== */
/* Flex utilitaires */
.jdvc-cpt-flex-1, #wpbody .jdvc-cpt-flex-1 { flex: 1 !important; }
.jdvc-cpt-flex-full { flex: 100% !important; }
.jdvc-cpt-col-300 { flex: 1 !important; min-width: 300px !important; }

/* Notes */
.jdvc-cpt-note { color: #64748b !important; font-size: 12px !important; }

/* Sous-titres */
.jdvc-cpt-subheading { margin: 0 0 15px 0 !important; color: #555 !important; }

/* Archives front (gabarits de liste publique) */
.jdvc-cpt-container { max-width: 1200px !important; margin: 0 auto !important; }
.jdvc-cpt-archive-title { font-size: 36px !important; margin: 0 0 10px 0 !important; font-weight: 800 !important; }
.jdvc-cpt-archive { padding: 60px 20px !important; background: #fcfcfc !important; min-height: 600px !important; box-sizing: border-box !important; }
.jdvc-cpt-archive-alt { padding: 60px 20px !important; background: #fdfdfd !important; min-height: 600px !important; box-sizing: border-box !important; }
.jdvc-cpt-archive-head { max-width: 1200px !important; margin: 0 auto 40px auto !important; text-align: center !important; font-family: system-ui, sans-serif !important; }
.jdvc-cpt-archive-head-lg { max-width: 1200px !important; margin: 0 auto 50px auto !important; text-align: center !important; font-family: system-ui, sans-serif !important; }
.jdvc-cpt-narrow { max-width: 400px !important; margin: 40px auto !important; }

/* Utilitaires (marges, largeurs, alignements, couleurs de texte, boutons) */
.jdvc-cpt-mt-0 { margin-top: 0 !important; }
.jdvc-cpt-text-right { text-align: right !important; }
.jdvc-cpt-text-muted { color: #64748b !important; }
.jdvc-cpt-empty-italic { color: #64748b !important; font-style: italic !important; }
.jdvc-cpt-d-block { display: block; }
.jdvc-cpt-text-wp-danger, #wpbody .jdvc-cpt-text-wp-danger { color: #b32d2e !important; }
.jdvc-cpt-text-warning { color: #b45309 !important; }
.jdvc-cpt-text-red, #wpbody .jdvc-cpt-text-red { color: red !important; }
.jdvc-cpt-actions-row { display: flex; gap: 10px !important; margin-top: 15px !important; flex-wrap: wrap !important; }
.jdvc-cpt-btn-split, #wpbody .jdvc-cpt-btn-split { flex: 1 !important; text-align: center !important; }
.jdvc-cpt-field-label { font-weight: bold !important; display: block; margin-bottom: 5px !important; }
.jdvc-cpt-mb-15 { margin-bottom: 15px !important; }
.jdvc-cpt-mb-25 { margin-bottom: 25px !important; }
.jdvc-cpt-mt-10, #wpbody .jdvc-cpt-mt-10 { margin-top: 10px !important; }


/* ==========================================================================
   2. PAGES DE CONFIGURATION (gabarit commun : jdvc_cpt_settings_page)
   Cartes de réglages à gauche, manuel sticky à droite. Palette admin.css.
   ========================================================================== */
.jdvc-cpt-page { max-width: 1320px; }

/* En-tête */
.jdvc-cpt-page-head { display: flex; align-items: center; gap: 16px; margin: 18px 0 22px; }
.jdvc-cpt-page-icon.dashicons { width: 48px; height: 48px; font-size: 26px; line-height: 48px; text-align: center; border-radius: 14px; background: #0f172a; color: #ffffff; flex-shrink: 0; box-shadow: 0 10px 20px -8px rgba(15,23,42,0.45); }
.wrap .jdvc-cpt-page-title { margin: 0; padding: 0; font-size: 22px; font-weight: 700; line-height: 1.25; color: #0f172a; }
.jdvc-cpt-page-intro { margin: 4px 0 0; font-size: 13px; color: #64748b; max-width: 760px; }

/* Mise en page deux colonnes */
.jdvc-cpt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.jdvc-cpt-layout.is-single { grid-template-columns: minmax(0, 1fr); max-width: 980px; }
.jdvc-cpt-layout-main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.jdvc-cpt-form { display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 1180px) { .jdvc-cpt-layout { grid-template-columns: minmax(0, 1fr); } }

/* Cartes */
.jdvc-cpt-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 16px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05); overflow: hidden; }
.jdvc-cpt-card-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 24px; border-bottom: 1px solid #f1f5f9; background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%); }
.jdvc-cpt-card-icon.dashicons { width: 34px; height: 34px; font-size: 18px; line-height: 34px; text-align: center; border-radius: 10px; background: #eff6ff; color: #2563eb; flex-shrink: 0; }
.wrap .jdvc-cpt-card-title { margin: 0; padding: 0; font-size: 15px; font-weight: 600; color: #0f172a; line-height: 34px; }
.jdvc-cpt-card-head .jdvc-cpt-card-desc { margin: -4px 0 0; font-size: 12.5px; color: #64748b; line-height: 1.5; }
.jdvc-cpt-card-body { padding: 20px 24px 24px; }
.jdvc-cpt-card-body > p:first-child { margin-top: 0; }

/* Champs */
.jdvc-cpt-fields { display: grid; gap: 18px 24px; }
.jdvc-cpt-fields-1 { grid-template-columns: minmax(0, 1fr); }
.jdvc-cpt-fields-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.jdvc-cpt-fields-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) { .jdvc-cpt-fields-2, .jdvc-cpt-fields-3 { grid-template-columns: minmax(0, 1fr); } }
.jdvc-cpt-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.jdvc-cpt-field.is-wide { grid-column: 1 / -1; }
.jdvc-cpt-field.is-inline { justify-content: center; }
.jdvc-cpt-field-name { font-size: 13px; font-weight: 600; color: #1e293b; }
.jdvc-cpt-field-help { font-size: 12px; color: #64748b; line-height: 1.5; }
.jdvc-cpt-field-help code { font-size: 11px; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
#wpbody .jdvc-cpt-input { box-sizing: border-box; width: 100%; max-width: 100%; min-height: 38px; font-size: 13px; }
#wpbody textarea.jdvc-cpt-input { min-height: 90px; line-height: 1.5; }
#wpbody .jdvc-cpt-input-num { max-width: 140px; }

/* Couleur : pastille native + code hexadécimal */
.jdvc-cpt-color { display: inline-flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; width: max-content; }
.jdvc-cpt-color input[type="color"] { width: 34px; height: 30px; padding: 0; border: none; border-radius: 8px; background: none; cursor: pointer; }
.jdvc-cpt-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.jdvc-cpt-color input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(15,23,42,0.12); border-radius: 8px; }
.jdvc-cpt-color input[type="color"]::-moz-color-swatch { border: 1px solid rgba(15,23,42,0.12); border-radius: 8px; }
.jdvc-cpt-color code { background: none; padding: 0; font-size: 12px; color: #475569; text-transform: uppercase; }

/* Interrupteur (case à cocher stylée) */
.jdvc-cpt-toggle { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 13px; color: #334155; line-height: 1.4; }
.jdvc-cpt-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.jdvc-cpt-toggle-track { position: relative; width: 40px; height: 22px; border-radius: 22px; background: #e2e8f0; flex-shrink: 0; transition: background 0.2s; }
.jdvc-cpt-toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #ffffff; box-shadow: 0 1px 3px rgba(0,0,0,0.15); transition: transform 0.2s; }
.jdvc-cpt-toggle input:checked + .jdvc-cpt-toggle-track { background: #2563eb; }
.jdvc-cpt-toggle input:checked + .jdvc-cpt-toggle-track::after { transform: translateX(18px); }
.jdvc-cpt-toggle input:focus-visible + .jdvc-cpt-toggle-track { box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }
.jdvc-cpt-toggle input:disabled + .jdvc-cpt-toggle-track { opacity: 0.45; }
.jdvc-cpt-toggle:has(input:disabled) { cursor: not-allowed; color: #94a3b8; }
.jdvc-cpt-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; }

/* Barre d'enregistrement */
.jdvc-cpt-savebar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 14px 20px; background: rgba(255,255,255,0.96); border: 1px solid #e2e8f0; border-radius: 14px; box-shadow: 0 -8px 20px -12px rgba(0,0,0,0.18); }
.jdvc-cpt-savebar-hint { font-size: 12px; color: #64748b; }

/* Manuel sticky */
.jdvc-cpt-manual { position: sticky; top: 46px; }
.jdvc-cpt-manual-inner { max-height: calc(100vh - 70px); overflow-y: auto; background: #0f172a; color: #cbd5e1; border-radius: 16px; padding: 22px; box-shadow: 0 20px 30px -12px rgba(15,23,42,0.35); scrollbar-width: thin; scrollbar-color: #334155 transparent; }
@media (max-width: 1180px) { .jdvc-cpt-manual { position: static; } .jdvc-cpt-manual-inner { max-height: none; } }
.wrap .jdvc-cpt-manual-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 0; font-size: 14px; font-weight: 600; color: #ffffff; text-transform: uppercase; letter-spacing: 0.6px; }
.jdvc-cpt-manual-title .dashicons { color: #60a5fa; }
.jdvc-cpt-manual-section { padding: 16px 0; border-bottom: 1px solid #1e293b; }
.jdvc-cpt-manual-section:last-child { border-bottom: none; padding-bottom: 0; }
.jdvc-cpt-manual h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: #f8fafc; }
.jdvc-cpt-manual p { margin: 0 0 10px; font-size: 12.5px; line-height: 1.55; color: #94a3b8; }
.jdvc-cpt-manual b, .jdvc-cpt-manual strong { color: #e2e8f0; }
.jdvc-cpt-manual code { background: #1e293b; color: #93c5fd; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.jdvc-cpt-manual .jdvc-cpt-manual-label { margin: 12px 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: #64748b; }
.jdvc-cpt-manual-list { margin: 0; padding-left: 18px; list-style: disc; font-size: 12.5px; line-height: 1.55; color: #94a3b8; }
.jdvc-cpt-manual-list li { margin-bottom: 4px; }
.jdvc-cpt-manual a { color: #93c5fd; }

/* Bloc de code copiable */
.jdvc-cpt-snippet { position: relative; display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 9px 44px 9px 12px; background: #020617; border: 1px solid #1e293b; border-radius: 10px; }
.jdvc-cpt-snippet code, .jdvc-cpt-manual .jdvc-cpt-snippet code { background: none; padding: 0; color: #a5f3fc; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.jdvc-cpt-copy { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: none; border-radius: 8px; background: #1e293b; color: #94a3b8; cursor: pointer; transition: background 0.2s, color 0.2s; }
.jdvc-cpt-copy:hover, .jdvc-cpt-copy:focus { background: #2563eb; color: #ffffff; outline: none; }
.jdvc-cpt-copy .dashicons { font-size: 16px; width: 16px; height: 16px; }
.jdvc-cpt-copy-ok { display: none; font-size: 11px; font-weight: 600; }
.jdvc-cpt-copy.is-copied { width: auto; padding: 0 10px; background: #16a34a; color: #ffffff; }
.jdvc-cpt-copy.is-copied .dashicons { display: none; }
.jdvc-cpt-copy.is-copied .jdvc-cpt-copy-ok { display: inline; }
.jdvc-cpt-copy-buffer { position: fixed; top: -1000px; left: -1000px; opacity: 0; }

/* Attributs de shortcode */
.jdvc-cpt-attrs { margin: 10px 0 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 12px; font-size: 12px; }
.jdvc-cpt-attrs dt { margin: 0; }
.jdvc-cpt-attrs dd { margin: 0; color: #94a3b8; line-height: 1.5; }

/* Astuce */
.jdvc-cpt-manual .jdvc-cpt-tip { display: flex; gap: 8px; margin: 12px 0 0; padding: 10px 12px; background: rgba(37,99,235,0.12); border: 1px solid rgba(96,165,250,0.25); border-radius: 10px; color: #bfdbfe; }
.jdvc-cpt-tip .dashicons { color: #fbbf24; flex-shrink: 0; font-size: 18px; width: 18px; height: 18px; }

/* Contenus libres dans les cartes (tableaux, répéteurs des pages annexes) */
.jdvc-cpt-card .form-table { margin-top: 0; }
.jdvc-cpt-card .widefat { box-shadow: none; }
.jdvc-cpt-card-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.jdvc-cpt-muted { color: #64748b; font-size: 12.5px; }
.jdvc-cpt-empty { padding: 18px; text-align: center; color: #64748b; font-style: italic; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 12px; }


/* Champ avec unité (« 30 jours », « 10 points ») */
.jdvc-cpt-input-suffix { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #475569; }
#wpbody .jdvc-cpt-input-suffix .jdvc-cpt-input-num { width: 100px; }

/* Média (aperçu + choisir / retirer) */
.jdvc-cpt-media { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.jdvc-cpt-media img { width: 38px; height: 38px; object-fit: contain; padding: 4px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; }
.jdvc-cpt-media img[hidden], .jdvc-cpt-media [hidden] { display: none; }

/* Liste de lignes (types de contenu, saisons…) */
.jdvc-cpt-row-list { border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.jdvc-cpt-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 260px); gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; }
.jdvc-cpt-row:last-child { border-bottom: none; }
.jdvc-cpt-row:nth-child(even) { background: #fbfcfe; }
.jdvc-cpt-row code { font-size: 11px; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; color: #64748b; }
@media (max-width: 782px) { .jdvc-cpt-row { grid-template-columns: minmax(0, 1fr); } }

/* Répéteur (paliers, étapes…) : la couleur d'accent arrive par --jdvc-accent (valeur dynamique, inline) */
.jdvc-cpt-repeater { display: flex; flex-direction: column; gap: 12px; }
.jdvc-cpt-repeat-item { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: #f8fafc; border: 1px solid #e2e8f0; border-left: 4px solid var(--jdvc-accent, #2563eb); border-radius: 12px; }
.jdvc-cpt-repeat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#wpbody .jdvc-cpt-repeat-grow { flex: 1; min-width: 220px; width: auto; }
.jdvc-cpt-repeat-del { color: #94a3b8; text-decoration: none; }
.jdvc-cpt-repeat-del:hover, .jdvc-cpt-repeat-del:focus { color: #ef4444; }
.jdvc-cpt-card-actions .button .dashicons { font-size: 16px; width: 16px; height: 16px; vertical-align: text-bottom; }


/* ==========================================================================
   3. SECTIONS PERMALIENS (Réglages > Permaliens)
   ========================================================================== */
.jdvc-cpt-perm-intro { max-width: 760px; color: #475569; }
.jdvc-cpt-perm-row { display: flex; flex-wrap: wrap; gap: 12px 16px; }
.jdvc-cpt-perm-field { display: flex; flex-direction: column; gap: 4px; min-width: 200px; flex: 0 1 240px; }
.jdvc-cpt-perm-field > span { font-size: 12px; font-weight: 600; color: #475569; }
#wpbody .jdvc-cpt-perm-field input { width: 100%; }
.jdvc-cpt-perm-note { max-width: 760px; margin-top: -4px; padding: 8px 12px; background: #fffbeb; border-left: 3px solid #f59e0b; border-radius: 6px; color: #78350f; }


/* ==========================================================================
   4. CPTBOX MANAGER (page de gestion des univers et post types)
   ========================================================================== */
.jdvc-cptbox-div1 { border-left-color: #9b59b6 !important; background: #fff !important; padding: 20px !important; margin-bottom: 20px !important; box-shadow: 0 2px 5px rgba(0,0,0,0.05) !important; font-family: sans-serif !important; }
.jdvc-cptbox-h31 { color: #9b59b6 !important; margin-top: 0 !important; margin-bottom: 15px !important; }
.jdvc-cptbox-div2 { background: #fdfbfd !important; padding: 15px !important; border: 1px solid #ebdcf2 !important; border-radius: 6px !important; margin-bottom: 25px !important; }
.jdvc-cptbox-h41 { margin: 0 0 12px 0 !important; color: #7d3c98 !important; display: flex; align-items: center !important; gap: 8px !important; }
.jdvc-cptbox-p1 { font-size: 12px !important; color: #666 !important; margin: 0 0 15px 0 !important; }
.jdvc-cptbox-p2 { font-size: 12px !important; color: #999 !important; font-style: italic !important; margin: 0 !important; }
.jdvc-cptbox-div3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important; gap: 15px !important; }
.jdvc-cptbox-div4 { display: grid; grid-template-columns: 1fr 1fr !important; gap: 20px !important; }
.jdvc-cptbox-div5 { background: #fafafa !important; padding: 15px !important; border: 1px solid #e5e5e5 !important; border-radius: 6px !important; }
.jdvc-cptbox-h51 { margin: 0 0 10px 0 !important; font-size: 13px !important; color: #444 !important; }
.jdvc-cptbox-table1, #wpbody .jdvc-cptbox-table1 { margin-bottom: 0 !important; box-shadow: none !important; border: 1px solid #e5e5e5 !important; }
.jdvc-cptbox-td1 { font-size: 12px !important; color: #999 !important; font-style: italic !important; }
.jdvc-cptbox-details1 { border-top: 1px solid #eee !important; padding-top: 15px !important; margin-top: 20px !important; }
.jdvc-cptbox-summary1 { font-weight: 600 !important; color: #0073aa !important; font-size: 13px !important; cursor: pointer !important; outline: none !important; user-select: none !important; }
.jdvc-cptbox-div6 { display: grid; grid-template-columns: 1fr 1fr !important; gap: 20px !important; margin-top: 15px !important; }
.jdvc-cptbox-div7 { background: #fff !important; padding: 15px !important; border: 1px solid #ddd !important; border-radius: 6px !important; box-shadow: 0 1px 3px rgba(0,0,0,0.02) !important; }
.jdvc-cptbox-h52 { margin: 0 0 10px 0 !important; font-size: 12px !important; color: #333 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important; }
.jdvc-cptbox-input1, #wpbody .jdvc-cptbox-input1 { width: 100% !important; margin-bottom: 5px !important; height: 28px !important; font-size: 12px !important; }
.jdvc-cptbox-input2, #wpbody .jdvc-cptbox-input2 { width: 100% !important; margin-bottom: 10px !important; height: 28px !important; font-size: 12px !important; }
.jdvc-cptbox-div8 { display: grid; grid-template-columns: 1fr !important; gap: 4px !important; margin-top: 8px !important; }
.jdvc-cptbox-label1 { font-size: 10px !important; color: #666 !important; font-weight: bold !important; }
.jdvc-cptbox-label2 { font-size: 10px !important; color: #666 !important; }
.jdvc-cptbox-label3 { font-size: 11px !important; display: block; margin-bottom: 3px !important; color: #666 !important; }
.jdvc-cptbox-div9 { max-height: 65px !important; overflow-y: auto !important; background: #fff !important; padding: 4px !important; border: 1px solid #ddd !important; margin-bottom: 10px !important; font-size: 11px !important; }
.jdvc-cptbox-label4 { display: block; font-weight: normal !important; margin-bottom: 2px !important; }
