/* =====================================================================
   WORKSPACE — source de vérité (flat UI + séparations fines)
   ===================================================================== */

/* ---------- 0) Variables ---------- */
:root{
  --gw-toolbar-h: 56px;               /* hauteur de la toolbar */
  --gw-top-offset: 0px;               /* compensée si admin bar */
  --right-col: 420px;                  /* largeur de la colonne chat */
  --sep: #e5e7eb;                      /* couleur des séparations */
}

/* ---------- 1) Neutralisation thème autour de la page plugin ---------- */
:where(.entry-content, .wp-block-group, .wp-block-post-content,
       .container, .container-fluid, .site-content, .content-area, .wrap)
> .gw-page{ max-width:none !important; }

.gw-page :where(.has-global-padding){
  padding-top:0 !important; padding-bottom:0 !important;
  margin-top:0 !important;  margin-bottom:0 !important;
}
:where(.alignfull){ margin-left:0 !important; margin-right:0 !important; }
.gw-page :where(.site-header, .entry-header){ display:none !important; }

.gw-page{
	overflow: hidden;
}

/* =====================================================================
   GRID GLOBAL
   ===================================================================== */
.gw-grid.gw-workspace{
  display:grid;
  grid-template-columns:minmax(0,1fr) var(--right-col);
  gap:0 !important;
  column-gap:0 !important;
  row-gap:0 !important;
  --wp--style--block-gap:0 !important;
}
.gw-grid.gw-workspace > *{ margin:0 !important; }
.gw-grid.gw-workspace > .gw-right { margin: initial !important; }


/* =====================================================================
   COLONNE GAUCHE — ÉDITEUR
   ===================================================================== */

/* Conteneur de colonne : prend tout le viewport, seul le wrap scrolle */
.gw-left{
  position:sticky;
  top:var(--gw-top-offset);
  height:calc(100vh - var(--gw-top-offset));
  display:flex;
  flex-direction:column;
  overflow:auto;
}

/* ---------- Toolbar ---------- */
.gw-toolbar{
  position:sticky; top:var(--gw-top-offset); z-index:50;
  flex:0 0 auto;
  min-height:var(--gw-toolbar-h);
  display:flex; align-items:center; gap:.75rem; flex-wrap:wrap;
  background:#fff;
  border-bottom:1px solid var(--sep);
  margin:0;

}
.gw-group{ display:flex; gap:6px; align-items:center; }
.gw-btn{ border:none; background:transparent; color:#0f172a; padding:8px 10px; border-radius:8px; cursor:pointer; }
.gw-btn:hover{ background:#f1f5f9; }
.gw-btn.is-active{ background:#e5edff; }
#gw-heading,#gw-list{
  appearance:none; border:1px solid var(--sep); background:#fff; color:#0f172a;
  padding:8px 12px; cursor:pointer; font-weight:500; border-radius:10px;
}

/* ---------- Zone scrollable + surface d’édition ---------- */
.gw-editor-wrap{
  flex:1 1 auto;
  min-height:0;                   /* indispensable en flex */
  overflow:auto;                  /* c’est ICI que ça scrolle */
  background:#fff;
}

.gw-editor{
  min-height:100% !important;     /* remplace tout min-height fixe */
  height:auto;
  box-sizing:border-box;
  background:#fff !important;
  border:0 !important; border-radius:0 !important; box-shadow:none !important;
  margin-top:0 !important;
  padding:50px 75px !important;   /* air interne (ajuste au besoin) */
}



/* =====================================================================
   TOUS CHAT
   ===================================================================== */

.gwc{
  display:flex; flex-direction:column;
  font-size:14px;
  background: transparent;
}

.gwc-msg{
  max-width:85%; margin:8px 0; padding:10px 12px;
  border-radius:10px; line-height:1.45; font-size:14px;
}
.gwc-msg.is-user{
  background:#111827; color:#fff; margin-left:auto; border-bottom-right-radius:4px;
}
.gwc-msg.is-bot{
  background:#f3f4f6; color:#0f172a; border-bottom-left-radius:4px;
}
.gwc-typing{ opacity:.6; font-style:italic; }



/* =====================================================================
   COLONNE DROITE — CHAT
   ===================================================================== */

.gw-right{
  min-height:0;   
  border-left:1px solid var(--sep);      /* fine séparation verticale */
}

.gw-right .gw-right-head{
  position: sticky; top: 0; z-index: 3;
  align-items:center; justify-content:space-between; gap:8px;
  background:#fff; border-bottom:1px solid var(--sep);
  padding:10px 12px;
}

/* Style du bouton Clear (optionnel) */
.gw-right .gw-chat-clear{
  background: transparent; border:1px solid var(--sep);
  padding:6px 10px; border-radius:8px; cursor:pointer;
}
.gw-right .gw-chat-clear:hover{ background:#f3f4f6; }

#gw-chat-wrapper{
  display: grid !important;
  grid-template-rows: 1fr auto !important; /* log qui scrolle + compose fixe */
  min-height: 0;
  overflow: auto;           /* pas de scroll ici */
  background: #fff;
  padding: 0;
  border-left: 1px solid var(--sep); /* si tu veux la séparation verticale */
}

/* Dissout .gwc pour que log/compose deviennent 2 lignes de la grille */
#gw-chat-wrapper > .gwc{
  display: contents !important;
}

/* Le LOG = seul scroller */
#gw-chat-wrapper .gwc-log{
  min-height: 0;
  overflow: auto !important;
  padding: 12px;
}

/* Le COMPOSE = fixe en bas (sans sticky) */
#gw-chat-wrapper .gwc-compose{
  position: static !important;
  background: #fff;
  border-top: 1px solid var(--sep);
  margin: 0;
  padding: 12px;
}

.gw-chatbox .gwc-field{
  background:#fff;
  border:1px solid var(--sep); border-radius:0;
  padding:8px 10px;
  border-radius: 12px;
}
.gw-chatbox .gwc-input{
  width:100%; min-height:56px; resize:vertical;
  border:0 !important; outline:0 !important; background:transparent !important;
  font:inherit; line-height:1.4; color:#0f172a;
}

/* Ligne d’actions : Insérer à gauche, Envoyer à droite */
.gw-chatbox .gwc-actions{ display:flex; align-items:center; gap:10px; margin-top:8px; }
.gw-chatbox .gwc-actions-left{ display:flex; gap:8px; }
.gw-chatbox .gwc-actions-right{ display:flex; gap:8px; margin-left:auto; }


.gw-btn.gw-secondary{
  background:#111827; color:#fff; border:none; border-radius:10px; padding:8px 12px; cursor:pointer;
}
.gw-btn.gw-secondary:hover{ opacity:.92; }

.gw-chatbox .gwc-send{
  margin-left:auto; width:auto; flex:0 0 auto;
  display:inline-flex; align-items:center; justify-content:center;
  height:42px; padding:0 16px;
  background:#111827 !important; color:#fff !important;
  border:0; border-radius:10; cursor:pointer;
}
.gw-chatbox .gwc-send:hover{ opacity:.92; }

/* Variante “icône” pour Envoyer (↑) */
.gw-chatbox .gwc-send.gwc-send--icon{
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e5e7eb !important; color:#111827 !important;
  border: 0 !important; border-radius: 10px !important;
  padding: 0; cursor: pointer;
}


/* ================== Chat "Générer" uniquement ================== */

/* ===== Box Générer : structure en colonne + hauteur contrainte ===== */
#gw-gen-inline.gw-gen-float{
  display: flex;
  flex-direction: column;
  /* contraint la hauteur globale pour que le body puisse scroller */
  max-height: 80vh;              /* ajuste: 70–85vh selon ton goût */
  width: min(560px, 70vw);       /* si besoin, garde ta largeur max */
}

/* tête et pied ne scrollent pas */
#gw-gen-inline .gw-gen-float-head,
#gw-gen-inline .gw-gen-float-actions{
  flex: 0 0 auto;
}

/* ===== Le SEUL scroller : le body ===== */
#gw-gen-inline .gw-gen-float-body{
  flex: 1 1 auto;                /* prend la place restante */
  min-height: 0;                 /* crucial pour autoriser le shrink en flex */
  overflow: auto !important;     /* c’est ICI que ça scrolle */
  padding: 12px;               /* remets ton padding ici */
  border-radius: 4px;
  border: 2px;
}

/* ===== À l’intérieur : pas de scroll concurrent ===== */
#gw-gen-inline .gw-chatbox--gen{
  position: relative;
  overflow: visible;             /* pas de scroll ici */
  display: block;
}
#gw-gen-inline .gw-chatbox--gen .gwc{
  height: auto !important;       /* neutralise height:100% éventuel */
  flex: initial; min-height: 0;
}
#gw-gen-inline .gw-chatbox--gen .gwc-log{
  overflow: visible !important;  /* pas de scroll ici (le scroller est le body) */
  padding: 12px;
  overflow:auto;
}
#gw-gen-inline .gw-chatbox--gen .gwc-compose{
  bottom: 0;
  z-index: 2;
  background: #fff;
  border-top: 1px solid var(--sep);
  margin: 0; padding: 12px;
  overflow:none;
}

/* Cacher les messages USER uniquement dans la box Générer */
#gw-gen-inline .gwc .gwc-msg.is-user{
  display: none !important;
}

.gw-bubble.is-hidden{ display:none !important; }

#gw-gen-inline .gw-gen-float-close{
	border-radius: 4px;
	align-items: right;
}
	
/* Dissout .gwc pour que log/compose deviennent 2 lignes de la grille */
#gw-chat-wrapper > .gwc{
  display: contents !important;
}

/* Le LOG = seul scroller */
#gw-chat-wrapper .gwc-log{
  min-height: 0;
  overflow: auto !important;
  padding: 12px;
}

/* Le COMPOSE = fixe en bas (sans sticky) */
#gw-chat-wrapper .gwc-compose{
  position: static !important;
  background: #fff;
  border-top: 1px solid var(--sep);
  margin: 0;
  padding: 12px;
}

/* =====================================================================
   PROSEMIRROR (TipTap) — base flat, pleine hauteur, bon wrapping
   ===================================================================== */

.gw-editor .ProseMirror{
  min-height:100%;
  box-sizing:border-box;
  outline:0;
  color:#0f172a;
  font:inherit;
  line-height:1.6;
  overflow-wrap:anywhere; word-break:break-word;
}

.gw-editor .ProseMirror > *{ margin:0 0 .75rem; }
.gw-editor .ProseMirror > *:first-child{ margin-top:0; }
.gw-editor .ProseMirror > *:last-child{ margin-bottom:0; }

.gw-editor .ProseMirror h1{ font-size:1.875rem; font-weight:700; margin:.75rem 0 .5rem; }
.gw-editor .ProseMirror h2{ font-size:1.5rem;   font-weight:700; margin:.75rem 0 .5rem; }
.gw-editor .ProseMirror h3{ font-size:1.25rem;  font-weight:600; margin:.75rem 0 .5rem; }

.gw-editor .ProseMirror p{ margin:.5rem 0; }
.gw-editor .ProseMirror ul,
.gw-editor .ProseMirror ol{ padding-left:1.25rem; margin:.5rem 0; }
.gw-editor .ProseMirror li{ margin:.25rem 0; }

.gw-editor .ProseMirror blockquote{
  margin:.75rem 0; padding:.5rem .75rem;
  border-left:3px solid var(--sep); background:transparent;
}

.gw-editor .ProseMirror code{
  background:#f6f8fa; padding:.1rem .35rem; border:1px solid var(--sep);
  border-radius:0;
}
.gw-editor .ProseMirror pre{
  background:#f6f8fa; border:1px solid var(--sep); border-radius:0;
  padding:12px; overflow:auto; margin:.75rem 0;
}
.gw-editor .ProseMirror pre code{ background:transparent; border:0; padding:0; }

.gw-editor .ProseMirror hr{ border:0; border-top:1px solid var(--sep); margin:1rem 0; }
.gw-editor .ProseMirror img,
.gw-editor .ProseMirror video{ max-width:100%; height:auto; display:block; }

.gw-editor .ProseMirror.is-editor-empty:first-child::before{
  content: attr(placeholder);
  color:#94a3b8;
  pointer-events:none;
  float:left;
  height:0;
}

/* =====================================================================
   PANNEAU FLOTTANT “Générer” (si utilisé par editor.js)
   ===================================================================== */
.gw-float-root{ display:flex; flex-direction:column; gap:8px; }
.gw-float-root .gw-bubble{ background:#f0f0f0; color:#111111; padding:1px; border-radius: 4px}
.gw-float-root .gw-gen-btn{ background:transparent; border:none; color:#111111; padding:6px 10px; cursor:pointer; border-radius: 4px}
.gw-float-root .gw-gen-btn:hover{ background:rgba(255,255,255,.1); }

.gw-float-root .gw-gen-float{
  display:none; width:min(560px,70vw); max-width:580px; background:#fff;
  box-shadow:0 18px 50px rgba(2,6,23,.18); overflow:none;
}
.gw-float-root.is-open .gw-gen-float{ display:block; }
.gw-gen-float-head{ display:flex; justify-content:space-between; align-items:center; padding:10px 12px; border-bottom:1px solid var(--sep); }
.gw-gen-float-body{ max-height:50vh; overflow:none; padding:10px 12px; }
.gw-gen-float-actions{ display:hide;}
.gw-action{ border:none; background:#111827; color:#fff; padding:8px 12px; cursor:pointer; }
.gw-action:hover{ opacity:.92; }
#gw-gen-inline[hidden]{ display:none !important; }

/* =====================================================================
   UTILITAIRES / OVERRIDES
   ===================================================================== */

/* Flat total côté formulaires si le thème arrondit par défaut */
.gw-page button, .gw-page select, .gw-page textarea, .gw-page input{
  border-radius:0 !important;
}
