/* =========================================================
   IDD — Template Global (Front SaaS shell) + Tools bridge
   File: /assets/css/idd-template-global.css (ou ton fichier actuel)
   Scope: .idd-tpl (SAFE) + .idd-tool (tokens only)
   Objectifs:
   - Zéro conflit avec styles.css (global)
   - Tokens branchés sur variables.css (:root)
   - Admin bar: PAS de double offset (WP gère déjà html margin-top)
   - Topbar/Rail/Canvas/Backdrop stables (desktop/tablette/mobile)
   ========================================================= */

/* =========================================================
   0) TOKEN BRIDGE (thème -> IDD) — minimal, sans doublons
   - Si tu as déjà tools-global.css qui mappe --idd-*, tu peux
     garder celui-ci seulement pour .idd-tpl/.idd-tool pages.
   ========================================================= */
.idd-tool,
.idd-tpl{
  /* Typography */
  --idd-font-sans: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
  --idd-font-head: var(--font-head, var(--idd-font-sans));
  --idd-lh:        var(--lh, 1.55);

  /* Brand */
  --idd-brand-green:   var(--brand-green, #17A051);
  --idd-brand-green-2: var(--brand-green-2, #64CA4F);
  --idd-brand-lime:    var(--brand-lime, #9FCC2E);
  --idd-brand-yellow:  var(--brand-yellow, #F2C94C);
  --idd-brand-navy:    var(--brand-navy, #101323);

  /* Neutrals */
  --idd-white:   var(--white, #ffffff);
  --idd-black:   var(--black, #000000);

  --idd-bg:      var(--bg, #ffffff);
  --idd-bg-soft: var(--bg-soft, #F2F3F4);

  --idd-surface:   var(--surface, #ffffff);
  --idd-surface-2: var(--surface-2, #F7F8FA);

  --idd-text:    var(--text, #111827);
  --idd-text-2:  var(--text-2, #2B2F3A);
  --idd-muted:   var(--muted, #666672);
  --idd-muted-2: var(--muted-2, #98999D);

  --idd-line:   var(--line, #E6E8EE);
  --idd-line-2: var(--line-2, #D6DAE4);

  /* Radius / Shadows */
  --idd-r-10: var(--r-10, 10px);
  --idd-r-12: var(--r-12, 12px);
  --idd-r-14: var(--r-14, 14px);
  --idd-r-16: var(--r-16, 16px);
  --idd-r-18: var(--r-18, 18px);
  --idd-r-20: var(--r-20, 20px);

  --idd-shadow-sm: var(--shadow-sm, 0 10px 24px rgba(16,19,35,.08));
  --idd-shadow-md: var(--shadow-md, 0 14px 34px rgba(16,19,35,.12));
  --idd-shadow-lg: var(--shadow-lg, 0 24px 60px rgba(16,19,35,.16));

  /* Buttons / Focus */
  --idd-btn-h: var(--btn-h, 46px);
  --idd-btn-r: var(--btn-r, 12px);
  --idd-focus: var(--focus, 0 0 0 3px rgba(23,160,81,.25));

  /* Admin bar height (WP var if present) */
  --idd-adminbar-h: var(--wp-admin--admin-bar--height, 0px);
}

/* Fallback WP admin bar heights */
body.admin-bar{
  --idd-adminbar-h: var(--wp-admin--admin-bar--height, 32px);
}
@media (max-width: 782px){
  body.admin-bar{
    --idd-adminbar-h: var(--wp-admin--admin-bar--height, 46px);
  }
}
body:not(.admin-bar){
  --idd-adminbar-h: 0px;
}

/* =========================================================
   1) TEMPLATE TOKENS (SaaS shell)
   ========================================================= */
.idd-tpl{
  --tpl-nav-h: 64px;

  --tpl-bg:     var(--idd-bg);
  --tpl-line:   var(--idd-line);
  --tpl-navy:   var(--idd-brand-navy);
  --tpl-green:  var(--idd-brand-green);
  --tpl-green2: var(--idd-brand-green-2);

  --tpl-shadow: 0 16px 40px rgba(16,19,35,.10);

  /* SaaS rail */
  --tpl-rail-w: 64px;
  --tpl-gutter: var(--gutter, clamp(14px, 2vw, 26px));

  /* Single source of truth: topbar real height */
  --tpl-topbar-h: var(--tpl-nav-h);
}

/* =========================================================
   2) FULL WIDTH MODE
   Ajoute .idd-tpl--full sur .idd-tpl
   ========================================================= */
.idd-tpl.idd-tpl--full .idd-tpl__topbarInner,
.idd-tpl.idd-tpl--full .idd-tpl__container{
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

/* =========================================================
   3) TOPBAR (sticky)
   IMPORTANT:
   - On laisse top:0 (WP admin-bar gère déjà le décalage via html margin-top)
   - Sinon tu doubles la hauteur/offset
   ========================================================= */
.idd-tpl__topbar{
  position: sticky;
  top: 0; /* ✅ PAS var(--idd-adminbar-h) => sinon double offset */
  z-index: 1000;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--tpl-line);
}

/* TopbarInner: layout 3 colonnes (burger | brand | actions) */
.idd-tpl__topbarInner{
  box-sizing: border-box;
  height: var(--tpl-topbar-h);
  min-height: var(--tpl-topbar-h);

  /* Full width by design */
  width: 100%;
  max-width: none;
  margin: 0;

  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) max-content;
  align-items: center;
  column-gap: 12px;

  padding-inline: var(--tpl-gutter);
}

/* Brand */
.idd-tpl__brand{ min-width: 0; }
.idd-tpl__brandTitle{
  font-weight: 950;
  letter-spacing: -.02em;
  color: var(--tpl-navy);
  font-size: 16px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.idd-tpl__brandSub{
  font-size: 12px;
  color: var(--idd-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Actions à droite */
.idd-tpl__topbarActions{
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Icon buttons (hamburger, notif, user…) */
.idd-tpl__iconBtn{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--tpl-green) 18%, var(--tpl-line));
  background: rgba(255,255,255,.92);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(16,19,35,.06);
  color: var(--tpl-navy);
  position: relative;
  -webkit-appearance: none;
  appearance: none;
}
.idd-tpl__iconBtn .dashicons{ font-size: 20px; width: 20px; height: 20px; }
.idd-tpl__iconBtn:hover{
  border-color: color-mix(in srgb, var(--tpl-green) 32%, var(--tpl-line));
  background: color-mix(in srgb, var(--tpl-green) 8%, rgba(255,255,255,.92));
}
.idd-tpl__iconBtn.is-small{
  width: 38px;
  height: 38px;
  border-radius: 12px;
}

/* Badge notif */
.idd-tpl__badge{
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  background: var(--tpl-green);
  color: #fff;
  border: 2px solid #fff;
}

/* =========================================================
   4) CONTENT
   ========================================================= */
.idd-tpl__content{
  background:
    radial-gradient(900px 380px at 10% 0%, rgba(23,160,81,.10), rgba(255,255,255,0) 55%),
    radial-gradient(720px 320px at 90% 0%, rgba(16,19,35,.06), rgba(255,255,255,0) 60%);
}

.idd-tpl__container{
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2vw, 22px);
}

.idd-tpl.idd-tpl--full .idd-tpl__container{
  padding-left: var(--tpl-gutter);
  padding-right: var(--tpl-gutter);
}

/* =========================================================
   5) RAIL (mini sidebar)
   IMPORTANT:
   - fixed doit tenir compte de l’admin bar (car fixed n'est PAS compensé par html margin-top)
   - et du header height
   ========================================================= */
.idd-tpl__rail{
  position: fixed;
  left: 0;

  top: calc(var(--idd-adminbar-h) + var(--tpl-topbar-h));
  height: calc(100vh - (var(--idd-adminbar-h) + var(--tpl-topbar-h)));

  width: var(--tpl-rail-w);
  z-index: 900;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--tpl-line);

  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px 8px;
}

.idd-tpl__railNav{
  display: grid;
  gap: 10px;
}

.idd-tpl__railItem{
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--tpl-navy) 10%, var(--tpl-line));
  background: rgba(255,255,255,.92);
  display: grid;
  place-items: center;
  text-decoration: none;
  color: var(--tpl-navy);
  box-shadow: 0 10px 22px rgba(16,19,35,.06);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.idd-tpl__railItem .dashicons{ font-size: 18px; width: 18px; height: 18px; }

.idd-tpl__railItem:hover{
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--tpl-green) 35%, var(--tpl-line));
  background: color-mix(in srgb, var(--tpl-green) 8%, rgba(255,255,255,.92));
}
.idd-tpl__railItem.is-active{
  border-color: var(--tpl-green);
  background: rgba(23,160,81,.10);
}

/* Décale le contenu pour laisser place au rail */
@media (min-width: 821px){
  .idd-tpl__content{ padding-left: var(--tpl-rail-w); }
}

/* Tablette: rail présent, compact */
@media (max-width: 820px) and (min-width: 521px){
  .idd-tpl{ --tpl-rail-w: 58px; }
  .idd-tpl__content{ padding-left: var(--tpl-rail-w); }
  .idd-tpl__railItem{ width: 42px; height: 42px; border-radius: 14px; }
}

/* Mobile: pas de rail */
@media (max-width: 520px){
  .idd-tpl__rail{ display: none; }
  .idd-tpl__content{ padding-left: 0; }
  .idd-tpl__topbarInner{ padding-inline: var(--tpl-gutter); }
}

/* =========================================================
   6) HERO + SECTIONS
   ========================================================= */
.idd-tpl__hero{
  border: 1px solid var(--tpl-line);
  border-radius: var(--idd-r-20);
  background: rgba(255,255,255,.78);
  box-shadow: 0 12px 28px rgba(16,19,35,.08);
  padding: 14px;
  margin-bottom: 14px;
}

.idd-tpl__h1{
  margin: 0;
  font-size: clamp(22px, 2.4vw, 34px);
  font-weight: 950;
  letter-spacing: -.02em;
  color: var(--tpl-navy);
}

.idd-tpl__p{
  margin-top: 8px;
  color: var(--idd-muted);
  font-size: 14px;
}

.idd-tpl__section{
  border: 1px solid var(--tpl-line);
  border-radius: 22px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 14px 34px rgba(16,19,35,.10);
  padding: 14px;
  margin-bottom: 14px;
}

.idd-tpl__sectionHead{
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.idd-tpl__sectionIcon{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--tpl-green) 18%, var(--tpl-line));
  background: rgba(23,160,81,.10);
  display: grid;
  place-items: center;
  color: var(--tpl-green);
}
.idd-tpl__sectionIcon .dashicons{ font-size: 20px; width: 20px; height: 20px; }

.idd-tpl__sectionTitle{
  font-weight: 950;
  color: var(--tpl-navy);
  letter-spacing: -.01em;
}
.idd-tpl__sectionDesc{
  font-size: 13px;
  color: var(--idd-muted);
  margin-top: 2px;
}
.idd-tpl__sectionBody{ min-width: 0; }

/* =========================================================
   7) CANVAS (slide panels)
   IMPORTANT:
   - fixed => top doit tenir compte admin bar
   - height => vh - adminbar
   ========================================================= */
.idd-tpl__canvas{
  position: fixed;
  top: var(--idd-adminbar-h);
  height: calc(100vh - var(--idd-adminbar-h));

  width: min(340px, 86vw);
  background: rgba(255,255,255,.98);

  box-shadow: var(--tpl-shadow);
  z-index: 1400;

  display: flex;
  flex-direction: column;

  transition: transform .22s cubic-bezier(.2,.8,.2,1);
  will-change: transform;
}

/* LEFT / RIGHT positions */
.idd-tpl__canvas.is-left{
  left: 0;
  right: auto;
  border-right: 1px solid var(--tpl-line);
  transform: translateX(-102%);
}
.idd-tpl__canvas.is-right{
  left: auto;
  right: 0;
  border-left: 1px solid var(--tpl-line);
  transform: translateX(102%);
}
.idd-tpl__canvas.is-open{ transform: translateX(0); }

.idd-tpl__canvasHead{
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--tpl-line);
}
.idd-tpl__canvasTitle{
  font-weight: 950;
  color: var(--tpl-navy);
  letter-spacing: -.01em;
}

.idd-tpl__canvasBody{
  padding: 12px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.idd-tpl__nav{
  padding: 10px;
  display: grid;
  gap: 8px;
  overflow: auto;
}
.idd-tpl__navItem{
  border: 1px solid var(--tpl-line);
  border-radius: 16px;
  background: rgba(255,255,255,.98);
  padding: 10px;
  text-decoration: none;
  color: inherit;
}
.idd-tpl__navItem:hover{
  border-color: color-mix(in srgb, var(--tpl-green) 28%, var(--tpl-line));
  background: rgba(23,160,81,.06);
}
.idd-tpl__navItem.is-active{
  border-color: var(--tpl-green);
  background: rgba(23,160,81,.10);
}
.idd-tpl__navLabel{
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 900;
  color: var(--tpl-navy);
}
.idd-tpl__navDesc{
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--idd-muted);
}

.idd-tpl__canvasFoot{
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--tpl-line);
  color: var(--idd-muted);
  font-size: 12.5px;
}
.idd-tpl__footLine{ display: flex; gap: 8px; align-items: center; }

/* Backdrop: fixed => top adminbar */
.idd-tpl__backdrop{
  position: fixed;
  left: 0;
  right: 0;
  top: var(--idd-adminbar-h);
  height: calc(100vh - var(--idd-adminbar-h));
  z-index: 1300;
  background: rgba(16,19,35,.52);
  backdrop-filter: blur(4px);
}

/* Lock scroll when canvas open */
.idd-tpl--lock{ overflow: hidden; }

/* Empty state */
.idd-tpl__empty{
  border: 1px dashed color-mix(in srgb, var(--tpl-navy) 16%, var(--tpl-line));
  border-radius: 18px;
  padding: 14px;
  background: rgba(16,19,35,.02);
}
.idd-tpl__emptyTitle{
  font-weight: 950;
  color: var(--tpl-navy);
  letter-spacing: -.01em;
  margin-bottom: 6px;
}
.idd-tpl__emptyText{
  color: var(--idd-muted);
  font-size: 13px;
  line-height: 1.45;
}

/* User card */
.idd-tpl__userCard{
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--tpl-line);
  border-radius: 18px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 10px 22px rgba(16,19,35,.06);
  margin-bottom: 12px;
}
.idd-tpl__avatar{
  width: 56px;
  height: 56px;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(16,19,35,.04);
  border: 1px solid color-mix(in srgb, var(--tpl-navy) 10%, var(--tpl-line));
}
.idd-tpl__avatarImg{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.idd-tpl__userMeta{ min-width: 0; }
.idd-tpl__userName{
  font-weight: 950;
  color: var(--tpl-navy);
  letter-spacing: -.01em;
  line-height: 1.15;
}
.idd-tpl__userEmail{
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--idd-muted);
  overflow-wrap: anywhere;
}
.idd-tpl__userRole{
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 900;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--tpl-green) 25%, var(--tpl-line));
  background: rgba(23,160,81,.10);
  color: var(--tpl-navy);
}

/* Disabled links (bientôt) */
.idd-tpl__navItem[data-disabled="1"]{
  opacity: .65;
  cursor: not-allowed;
}
.idd-tpl__navItem[data-disabled="1"]:hover{
  border-color: var(--tpl-line);
  background: rgba(255,255,255,.98);
}

/* Responsive topbar */
@media (max-width: 520px){
  .idd-tpl__topbarActions{ gap: 8px; }
}

/* =========================================================
   8) ALIGNEMENT BURGER = RAIL (desktop/tablette)
   - On aligne visuellement le burger avec les boutons du rail
   - Pas de padding-left "calc(gutter + rail)" ici (sinon double logique)
   ========================================================= */
@media (min-width: 521px){
  .idd-tpl__topbarInner{
    /* rail padding horizontal = 8px (padding: 12px 8px) */
    padding-left: 8px;
    padding-right: var(--tpl-gutter);
  }
}
/* =========================================================
   9) TOOLS BASE COMPONENTS (shared)
   Scope: .idd-tool
   ========================================================= */
.idd-tool{
  font-family: var(--idd-font-sans);
  color: var(--idd-text);
  line-height: var(--idd-lh);
}

/* Panels / blocks helpers */
.idd-tool .idd-panel{
  background: rgba(255,255,255,.86);
  border: 1px solid var(--idd-line);
  border-radius: var(--idd-r-20);
  box-shadow: var(--idd-shadow-sm);
}
.idd-tool .idd-block{
  border: 1px solid var(--idd-line);
  border-radius: var(--idd-r-16);
  background: rgba(16,19,35,.02);
}

/* Fields */
.idd-tool input,
.idd-tool select,
.idd-tool textarea{
  width: 100%;
  min-height: var(--idd-btn-h);
  padding: 0 12px;
  border-radius: var(--idd-r-12);
  border: 1px solid var(--idd-line);
  background: #fff;
  color: var(--idd-text);
}
.idd-tool input:focus,
.idd-tool select:focus,
.idd-tool textarea:focus{
  outline: none;
  box-shadow: var(--idd-focus);
  border-color: var(--idd-brand-green);
}

/* Buttons (neutral by default) */
.idd-tool .button,
.idd-tool button,
.idd-tool a.button{
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: var(--idd-btn-h);
  padding: 0 14px;
  border-radius: var(--idd-btn-r);

  border: 1px solid color-mix(in srgb, var(--idd-brand-navy) 12%, var(--idd-line));
  background: #fff;
  color: var(--idd-brand-navy);

  font-weight: 900;
  letter-spacing: -.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(16,19,35,.06);
}
.idd-tool .button:hover,
.idd-tool button:hover,
.idd-tool a.button:hover{
  border-color: color-mix(in srgb, var(--idd-brand-green) 35%, var(--idd-line));
  background: color-mix(in srgb, var(--idd-brand-green) 8%, #fff);
}

/* Primary */
.idd-tool .button.button-primary,
.idd-tool button.button-primary,
.idd-tool a.button.button-primary{
  background: var(--idd-brand-green);
  border-color: var(--idd-brand-green);
  color: #fff;
}

/* Secondary */
.idd-tool .button.button-secondary,
.idd-tool button.button-secondary,
.idd-tool a.button.button-secondary{
  background: #fff;
  border-color: rgba(23,160,81,.28);
  color: var(--idd-brand-green);
}

/* Disabled (visible) */
.idd-tool .button[disabled],
.idd-tool button:disabled{
  pointer-events: none;
  background: rgba(16,19,35,.04);
  border-color: color-mix(in srgb, var(--idd-brand-navy) 10%, var(--idd-line));
  color: color-mix(in srgb, var(--idd-brand-navy) 62%, var(--idd-muted));
  box-shadow: none;
}

/* Mobile full width in action rows (safe) */
@media (max-width: 520px){
  .idd-tool .idd-og-td__actions .button,
  .idd-tool .idd-og-td__actions button{
    width: 100%;
  }
}



