/* idealgpt-widget.css - Version corrigée et stable
* (c) 2025 Agence de communication Idealcom | Lausanne | Suisse
* https://www.idealcom.ch
* Proprietary - Usage, copying, modification or redistribution
* without explicit permission is prohibited. */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

:root {
    --idealgpt-primary:   #e91457;
    --idealgpt-secondary:      #ec2564;
    --idealgpt-secondary-r: 236;
    --idealgpt-secondary-g: 37;
    --idealgpt-secondary-b: 100;
    --idealgpt-success:        #28a745;
    --idealgpt-error:          #dc3545;
    --idealgpt-text:           #333333;
    --idealgpt-light:          #f7f8fa;
    --idealgpt-border:         #e0e0e0;
    --idealgpt-shadow:         0 12px 40px rgba(0,0,0,0.15);
    --idealgpt-radius:         16px;
    --idealgpt-transition:     all 0.3s cubic-bezier(0.4,0,0.2,1);
    --idealgpt-offset-left:    30px;
    --idealgpt-offset-bottom:  20px;
    --idealgpt-font:           'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    --visual-viewport-height: 100vh; /* Valeur par défaut */
    
    /* Variable pour la compensation de la barre de défilement, mise à jour par JS */
    --scrollbar-width: 0px;
}

/* ======================================================================== */
/* === STYLES GLOBAUX ET DE STABILITÉ === */
/* ======================================================================== */

/* 1. Modèle de boîte (Box Sizing) - Appliqué globalement */
/* Assure un calcul de largeur prévisible et intuitif pour tous les éléments. */

*, *::before, *::after {
  box-sizing: border-box;
}

/* 3. Compensation du "saut" de la page (pour desktop) */
/* Ajoute un padding pour remplacer l'espace de la barre de défilement disparue. */
@media (min-width: 769px) {
    body.igpt-body-lock {
        padding-right: var(--scrollbar-width);
    }
}

/* 4. Prévention de la "fuite de défilement" sur le widget */
/* Empêche le défilement de se propager à l'arrière-plan. */
#idealgpt-widget.igpt-window {
    overscroll-behavior: contain;
}

/* ======================================================================== */
/* === STYLES DU WIDGET - CORRECTION POUR LE BUREAU === */
/* ======================================================================== */

/* Ces règles s'appliquent uniquement sur les écrans larges (tablettes et bureau) */
@media (min-width: 769px) {

    #idealgpt-widget .igpt-window {
        /* DÉFINITION DE LA TAILLE */
        width: 350px;
        position: fixed;
        left: var(--idealgpt-offset-left);  /* Utilise votre variable pour le décalage */
        bottom: calc(var(--idealgpt-offset-bottom) + 85px); /* Se place au-dessus de la bulle */
        min-height: 200px;
        max-height: 80vh; /* Ne doit pas dépasser 70% de la hauteur de l'écran */
        z-index: 10000004 !important;
    }
}

/* ======================================================================== */
/* === STYLES GÉNÉRAUX DU WIDGET (APPLICABLES PARTOUT) === */
/* ======================================================================== */

/* Appliquer la police DM Sans globalement au widget */
#idealgpt-widget,
#idealgpt-widget * {
  font-family: var(--idealgpt-font);
  font-weight: 400;
}
/* Couleur de l'avatar IdealGPT */

.igpt-avatar,
.igpt-bubble-icon,
.igpt-message-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--idealgpt-primary);
  overflow: hidden;
}

/* SVG dimensionné, mais sans Flex */
.igpt-avatar svg,
.igpt-bubble-icon svg,
.igpt-message-avatar svg {
 width: 30px; 
  height: auto;
  fill: currentColor;
  background: none;
}
.igpt-avatar    { color: white;     background: var(--idealgpt-primary); }
.igpt-bubble-icon { color: white;   background: var(--idealgpt-primary); }
.igpt-message-avatar { color: var(--idealgpt-primary); }

/* Animation de pulsation */
@keyframes igpt-pulse {
  0%, 100% {
    box-shadow:
      var(--idealgpt-shadow),
      /* secondaire à 70% d’opacité */
      0 0 0 0 rgba(
        var(--idealgpt-secondary-r),
        var(--idealgpt-secondary-g),
        var(--idealgpt-secondary-b),
        0.7
      );
  }
  50% {
    box-shadow:
      var(--idealgpt-shadow),
      0 0 0 10px rgba(
        var(--idealgpt-secondary-r),
        var(--idealgpt-secondary-g),
        var(--idealgpt-secondary-b),
        0
      );
  }
}

#idealgpt-widget .igpt-bubble {
  animation: igpt-pulse 2s infinite;
}

/* Réappliquer l’animation sur la bulle */
#idealgpt-widget .igpt-bubble {
  animation: igpt-pulse 2s infinite;
}


/* Widget principal */
#idealgpt-widget {
  position: fixed;
  left: var(--idealgpt-offset-left);
  bottom: var(--idealgpt-offset-bottom);
  z-index: 10000004 !important;
  font-family: var(--idealgpt-font); /* Utilise DM Sans */
  font-size: 14px;
  line-height: 1.5;
  pointer-events: none;
}
/* FOOTER*/

#idealgpt-widget .igpt-footer {
  text-align: center;
  padding-top: 0px;
  padding-left: 16px;
  padding-right: 16px;
  /*background: #fafafa;*/
  /* marges internes gauche/droite */
  

  /* rapproche le footer du champ de saisie */
  margin-top: 0px; /* si tu veux remonter davantage, mets 0 ou même -4px */

  /* espace en bas du footer */
  padding-bottom: 12px; /* augmente si tu veux plus d’air */
}
@media (max-width: 768px) {
  #idealgpt-widget .igpt-footer {
    margin-top: 0px; /* mobile : moins agressif */
  }
}

#idealgpt-widget .igpt-footer-line1,
#idealgpt-widget .igpt-footer-line2 {
  color: rgb(73, 73, 73);       /* gris souhaité */
  text-align: center;              /* centrage horizontal */
}

#idealgpt-widget .igpt-footer-line1 {
  font-size: 0.7em;                  /* réduit la taille */

  margin-bottom: 4px;
  font-weight: 400;
}

#idealgpt-widget .igpt-footer-line2 {
  font-size: 0.65em;                  /* réduit la taille */
  line-height: 1.52;
   color: rgb(73, 73, 73);       /* gris souhaité */
  opacity: 0.85;
}

/* Bulle de notification */
#idealgpt-widget .igpt-bubble {
  position: fixed;
  left: var(--idealgpt-offset-left);
  bottom: var(--idealgpt-offset-bottom);
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--idealgpt-primary), var(--idealgpt-secondary));
  border-radius: 50%;
  box-shadow: var(--idealgpt-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--idealgpt-transition);
  pointer-events: auto;
  z-index: 10000004 !important;
}

#idealgpt-widget .igpt-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 16px 50px rgba(0,0,0,0.2);
}

.igpt-bubble-icon {
  font-size: 24px;
  color: white;
}

/* Masque la bulle IdealGPT quand l'iframe Tawk.to est ouvert (a la classe .open) */
body:has(iframe[title="chat widget"].open) #idealgpt-widget .igpt-bubble {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.8); /* Optionnel : pour une petite animation */
}

/* rend la bulle invisible quand ouvert */
/*.igpt-bubble.igpt-hidden {
  transform: scale(0) rotate(180deg);
  opacity: 0;
}*/

/* Masque la bulle quand plein écran */

#idealgpt-widget .igpt-window.igpt-fullscreen ~ .igpt-bubble {
    display: none !important;
}

/* Avatar du header (profil) */
.igpt-header .igpt-avatar {
  width: 36px;    /* réduit la taille */
  height: 36px;
}

/* SVG à l’intérieur dans le header*/
.igpt-header .igpt-avatar svg {
  width: 22px;
  height: 22px;
}

/* 1. Supprimer le cercle de fond pour les avatars de message */
.igpt-message.igpt-user .igpt-message-avatar,
.igpt-message.igpt-bot .igpt-message-avatar {
  background: none !important;
  border-radius: 0 !important;
}

/* 2. Ajuster la taille si besoin */
.igpt-message-avatar {
  width: 15px;   /* ou la taille souhaitée */
}

/* 3. Redimensionner le SVG à l’intérieur */
.igpt-message-avatar svg {
  width: 100%;
  height: auto;
  fill: currentColor; /* conserve la couleur primary */
}

/* Fenêtre de chat */
.igpt-window {
  position: absolute;
  bottom: 80px;
  left: 0;
  width: 360px;
  height: 520px;
  background: white;
  border-radius: var(--idealgpt-radius);
  box-shadow: var(--idealgpt-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  transition: var(--idealgpt-transition);
  pointer-events: none; /* au repos */
}

.igpt-window.igpt-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto; /* ouverte */
}

.igpt-window.igpt-fullscreen {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  border-radius: 0;
  z-index: 10000004 !important;
}

/* Header */
.igpt-header {
  background: linear-gradient(135deg, var(--idealgpt-primary), var(--idealgpt-secondary));
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.igpt-header::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

.igpt-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.igpt-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.igpt-avatar svg {
  fill: currentColor; /* Hérite de la couleur blanche */
}

/* Titre IdealGPT*/
#idealgpt-widget .igpt-info h3 {
  color: #ffffff;  
  font-size: 12px!important;  
  line-height: 1.2!important;
  margin: 0;
  font-weight: 500;
  font-size: 16px;
}

.igpt-status {
  font-size: 8px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.igpt-status-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--idealgpt-success);
  animation: igpt-blink 1.5s infinite;
}

@keyframes igpt-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.igpt-controls {
  display: flex;
  gap: 8px;
}

.igpt-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--idealgpt-transition);
  font-size: 14px;
}

.igpt-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.05);
}

/* Rotation uniquement de l’icône du bouton “Nouveau chat” */
#igpt-reset:hover .igpt-btn-icon {
  display: inline-block;
  transform: rotate(180deg);
  transition: transform 0.3s ease;
}

/* Zone de messages */
.igpt-messages {
  flex: 1;
  padding: 16px;
  background: var(--idealgpt-light);
  overflow-y: hidden;
  scroll-behavior: smooth;
}

/* Autoriser le scroll vertical dans la zone de messages */
#idealgpt-widget .igpt-messages {
  overflow-y: auto !important;           /* ou scroll si tu préfères */
  -webkit-overflow-scrolling: touch;      /* inertie sous iOS/Android */
}

/* Facultatif : afficher la scrollbar sous Android Chrome */
#idealgpt-widget .igpt-messages::-webkit-scrollbar {
  width: 6px;
}
#idealgpt-widget .igpt-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

.igpt-message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
   align-items: center; 
  animation: igpt-message-in 0.3s ease-out;
}

@keyframes igpt-message-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.igpt-message.igpt-user {
  flex-direction: row-reverse;
}

.igpt-message-avatar {
  width: 15px;

  color: var(--idealgpt-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.igpt-message-avatar svg {
  fill: currentColor; /* Hérite de la couleur primary */
}

.igpt-message-bubble {
  max-width: 260px;
  padding: 12px 16px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
  line-height: 1.4;
}

.igpt-message.igpt-bot .igpt-message-bubble {
  background: white;
  color: var(--idealgpt-text);
  border: 1px solid var(--idealgpt-border);
  border-bottom-left-radius: 6px;
}

.igpt-message.igpt-user .igpt-message-bubble {
  padding: 8px 16px;          /* réduit la hauteur verticale */
  max-width: 260px;
  background: var(--idealgpt-primary);
  color: white;
  border-bottom-right-radius: 6px;
}

/* Indicateur de saisie : trois points seuls, sans arrière-plan ni bordure */
.igpt-typing {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: none;
}

/* Afficher l’indicateur quand il faut */
.igpt-typing.igpt-show {
  display: flex;
  animation: igpt-fade-in 0.3s ease-out;
}

/* Animation d’apparition */
@keyframes igpt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Conteneur des points */
.igpt-dots {
  display: flex;
  gap: 4px;
}

/* Style et animation des points */
.igpt-dot {
  width: 8px;
  height: 8px;
  background: var(--idealgpt-secondary);
  border-radius: 50%;
  animation: igpt-dot-bounce 1.4s infinite ease-in-out;
}

/* Décalages pour l’effet cascade */
.igpt-dot:nth-child(1) { animation-delay: -0.32s; }
.igpt-dot:nth-child(2) { animation-delay: -0.16s; }

/* Keyframes de rebond */
@keyframes igpt-dot-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40%           { transform: scale(1.2); opacity: 1;   }
}

/* Zone de saisie */
/* === ZONE DE SAISIE – FLEXBOX SIMPLE === */
.igpt-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 5px 16px !important;
  background: white;
  border-top: 1px solid var(--idealgpt-border);
  
  @media (max-width: 768px) {
    gap: 6px;
    padding: 12px;
  }
}

.igpt-input-wrapper {
  flex: 1;
  min-width: 0;
}

.igpt-input {
  width: 100%;
  min-height: 44px;
  max-height: 88px;
  padding: 12px 16px;
  border: 2px solid var(--idealgpt-border);
  border-radius: 12px;
  background: var(--idealgpt-light);
  font-size: 14px;
  resize: none;
  outline: none;
  box-sizing: border-box;
}

.igpt-send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--idealgpt-primary);
  color: white;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0; 
}
.igpt-send-btn:hover:not(:disabled) {
  background: var(--idealgpt-secondary);
  transform: scale(1.05);
}
.igpt-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Responsive Mobile */
@media (max-width: 768px) {

  /* Masquer le bouton plein écran sur mobile */
  #idealgpt-widget #igpt-fullscreen {
    display: none !important;
  }

  /* Limiter la largeur des bulles sur mobile */
  .igpt-message-bubble {
    max-width: calc(100% - 120px);
  }
}

/* === RESPONSIVE MOBILE === */

@media (max-width: 768px) {

  /* === RÈGLE DE SÉCURITÉ ANTI-DÉBORDEMENT === */
#idealgpt-widget * {
  max-width: 100%;
  box-sizing: border-box;
}

  #idealgpt-widget .igpt-window {
    position: fixed !important;
    left: 0px !important;
    top: 0px !important;
    bottom: 0px !important;
    width: 100%;
    height: 100dvh;
    transform: none !important;
    border-radius: 0px;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow-x: hidden !important;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* Fallback pour les navigateurs ne supportant pas dvh */
@supports not (height: 100dvh) {
  #idealgpt-widget .igpt-window {
    height: var(--visual-viewport-height) !important;
  }
}

  /* Bulle centrée en bas */
  #idealgpt-widget .igpt-bubble {
    position: fixed;
    left: var(--idealgpt-offset-left);
  bottom: var(--idealgpt-offset-bottom);
    transform: none !important;
    width: 60px;
    height: 60px;
  }
  /* Zone de saisie – ajuste padding et tailles */

  #idealgpt-widget .igpt-file-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  /* Footer – remonte légèrement */
  #idealgpt-widget .igpt-footer {
    margin-top: -8px;
  }

/* === AJUSTEMENTS SPÉCIFIQUES À IOS === */
  /* 2. Correction du viewport pour iOS DEEPSEEK */
.ios #idealgpt-widget .igpt-window {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  transform: none !important;
  border-radius: 0 !important;
  
  /* On confine le scroll à l'intérieur (selon votre analyse) */
  overscroll-behavior: contain;
  
  /* On gère l'encoche et la barre du bas */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* 3. Ajustement de la zone de messages pour iOS DEEPSEEK */
.ios .igpt-messages {
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* 5. Plein écran amélioré pour iOS-DEEPSEEK */
.ios #idealgpt-widget .igpt-window.igpt-fullscreen {
  height: 100dvh !important;
  top: 0 !important;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

  /* === Ajustements iPhone & Safe-Area === */
.ios #idealgpt-widget {
  /* Assurez-vous que le widget parent occupe toute la largeur pour le centrage */
  width: 100%;
  left: 0;
  bottom: 0;
  transform: none;
  padding-bottom: env(safe-area-inset-bottom); /* prend en compte la barre du bas */
}

/* 4. Correction du positionnement de la bulle sur iOS DEEPSEEK */
.ios #idealgpt-widget .igpt-bubble {
  position: fixed !important;
  left: var(--idealgpt-offset-left) !important;
  bottom: calc(var(--idealgpt-offset-bottom) + env(safe-area-inset-bottom)) !important;
  transform: none !important;
}

/* Ne plus centrer la bulle sur iOS (garde l’ancrage) */
.ios #idealgpt-widget .igpt-bubble {
  left: var(--idealgpt-offset-left) !important;
  transform: none !important;
  bottom: calc(var(--idealgpt-offset-bottom) + env(safe-area-inset-bottom)) !important;
}

/* Fenêtre ancrée (pas flottante) sur iOS */
.ios #idealgpt-widget .igpt-window {
  position: fixed !important;
  transform: none !important;
  padding-top: env(safe-area-inset-top); /* header toujours visible sous l’encoche */
}
  
}

/* États d'animation */
.igpt-fade-in {
  animation: igpt-fade-in 0.3s ease-out forwards;
}

.igpt-fade-out {
  animation: igpt-fade-out 0.3s ease-out forwards;
}

@keyframes igpt-fade-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(20px) scale(0.9); }
}

/* Scrollbar personnalisée */
.igpt-messages::-webkit-scrollbar {
  width: 4px;
}

.igpt-messages::-webkit-scrollbar-track {
  background: transparent;
}

.igpt-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 124, 186, 0.3);
  border-radius: 2px;
}

.igpt-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 124, 186, 0.5);
}


/* === ZONE DE SAISIE - VERSION FLEXBOX SIMPLE === */


.igpt-input {
  flex: 1;
  min-height: 44px;
  max-height: 88px;
  padding: 12px 16px;
  border: 2px solid var(--idealgpt-border);
  border-radius: 12px;
  background: var(--idealgpt-light);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  resize: none;
  outline: none;
  box-sizing: border-box;
}

.igpt-input:focus {
  border-color: var(--idealgpt-primary);
  background: white;
}

.igpt-file-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.8);
  color: #6b7280;
  cursor: pointer;
  font-size: 16px;
  font-weight: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.igpt-file-btn:hover {
  background: var(--idealgpt-light);
  color: var(--idealgpt-primary);
  transform: scale(1.1);
}


.igpt-send-btn:hover:not(:disabled) {
  background: var(--idealgpt-secondary);
  transform: scale(1.05);
}

.igpt-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Mobile */
  .igpt-file-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }


/* Quand IdealGPT est ouvert, Tawk.to se met en retrait ou disparaît (mobile) */
@media (max-width: 768px) {
  body.igpt-active #tawkchat-container,
  body.igpt-active #tawkchat-minified-wrapper,
  body.igpt-active #tawkchat-iframe-container,
  body.igpt-active [id^="tawkchat-"],
  body.igpt-active [id^="tawk_"],
  body.igpt-active [class*="tawk-"],
  body.igpt-active iframe[title="chat widget"] { /* On ajoute cette ligne ! */
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
    transition: opacity 0.3s ease; /* Ajoute une transition douce */
  }
}

/* === BOUTON RESET CHAT === */
.igpt-reset-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s ease;
  margin-left: 8px;
  opacity: 0.8;
}

/* Si vous souhaitez que la fenêtre occupe tout l'écran en fullscreen, gardez la règle existante */
#idealgpt-widget .igpt-window.igpt-fullscreen {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100vh !important;
  transform: none !important;
}

/* Règle 1 : Le conteneur principal gagne contre Tawk.to */
#idealgpt-widget {
  z-index: 10000004 !important;
}

/* Règle 2 : La fenêtre est à l'étage 1 */
#idealgpt-widget .igpt-window {
  z-index: 1;
}

/* Règle 3 : La bulle est à l'étage 2 (au-dessus de la fenêtre) */
#idealgpt-widget .igpt-bubble {
  z-index: 2;
}

/* ===== FIX Android – overrides ===== */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio:0) {

  #idealgpt-widget .igpt-messages {
    padding-bottom: 20px !important; /* Espace supplémentaire pour le clavier */
  }

  #idealgpt-widget .igpt-input-area {
    padding-bottom: 15px !important; /* Espace pour le clavier */
  }
}

/* Correction spécifique pour le scroll horizontal */
#idealgpt-widget .igpt-window,
#idealgpt-widget .igpt-messages {
  overflow-x: hidden !important;
  max-width: 100% !important;
}

/* Correction pour les versions Android plus anciennes */
@supports (-webkit-touch-callout: none) and (not (-webkit-overflow-scrolling: touch)) {
  #idealgpt-widget .igpt-window {
    transform: translateZ(0) !important; /* Force l'accélération matérielle */
  }
}

/* Classe appliquée quand le clavier est ouvert */
#idealgpt-widget.keyboard-open .igpt-window {
  bottom: auto !important;
  top: auto !important;
  /* on utilisera JS pour placer le bas de la fenêtre */
}

#idealgpt-widget.keyboard-open .igpt-window.igpt-fullscreen {
  top: auto !important;
  height: auto !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
}

/* Plein écran fiable avec 100dvh si supporté */
@supports (height: 100dvh) {
  #idealgpt-widget .igpt-window.igpt-fullscreen {
    height: 100dvh !important;
  }
}
/* Mobile – fullscreen limité à la zone visible sans clavier ni barre d’URL */
@media (max-width: 768px) {
  #idealgpt-widget .igpt-window.igpt-fullscreen {
    position: fixed !important;
    left: 0 !important;
    top: env(safe-area-inset-top) !important;
    width: 100% !important;
    height: calc(100vh - env(safe-area-inset-bottom) - env(safe-area-inset-top)) !important;
    border-radius: 0 !important;
  }

  /* État plein écran pour le widget */
.chat-fullscreen {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100vh;
  z-index: 10000004 !important;
  background: #fff;
  display: flex;
  flex-direction: column;
}


/* Verrouille le scroll arrière-plan */
/* Verrouille le scroll arrière-plan UNIQUEMENT SUR MOBILE */
@media (max-width: 768px) {
  body.chat-open {
    overflow: hidden;
  }
}

/* Masquer complètement le bouton "Réduire" */
#idealgpt-widget .igpt-controls #igpt-minimize {
    display: none !important;
}
/* ===== FIX iPhone/iPad – overrides ===== */

/* Empêcher tout débordement latéral et le rebond */
#idealgpt-widget, #idealgpt-widget * {
  box-sizing: border-box;
  overscroll-behavior: contain;
}
}

/* Plein écran fiable en 100dvh (iOS moderne) */
@supports (height: 100dvh) {
  #idealgpt-widget .igpt-window.igpt-fullscreen {
    height: 100dvh !important;
  }
}

/* Verrouillage arrière-plan UNIQUEMENT SUR MOBILE */
@media (max-width: 768px) {
  body.igpt-active {
    overflow: hidden;
  }
  /* On ajoute la deuxième règle ici aussi */
  body.igpt-body-lock {
    overflow: hidden;
  }

  @media (max-width: 768px) {
  /* Masque la bulle quand la fenêtre est ouverte, UNIQUEMENT sur mobile */
  body.igpt-active #idealgpt-widget .igpt-bubble {
      opacity: 0 !important;
      pointer-events: none !important;
      transform: scale(0.8) !important;
  }
}
@media (max-width: 768px) {
  /* Masque Tawk.to UNIQUEMENT SUR MOBILE quand IdealGPT est ouvert */
  body.igpt-active iframe[title="chat widget"] {
    display: none !important;
  }
}
/* ================================================================= */
/* === ARCHITECTURE MODERNE POUR LA VUE MOBILE (LA PLUS ROBUSTE) === */
/* ================================================================= */
@media (max-width: 768px) {
  
  /* 1. Le conteneur principal devient une colonne Flexbox */
  .igpt-window {
    /* Il occupe toute la hauteur visible grâce à nos variables JS */
    height: var(--visual-viewport-height, var(--fallback-height, 100vh));
    width: 100%;
    max-width: 100%;
    bottom: 0;
    left: 0;
    border-radius: 0;
    
    /* On active le mode colonne Flexbox */
    display: flex;
    flex-direction: column;
  }
  
  /* 2. Le header et la zone de saisie ont une taille fixe et ne doivent pas rétrécir */
  .igpt-header,
  .igpt-input-area,
  .igpt-footer {
    flex-shrink: 0; /* Empêche ces éléments de rétrécir */
  }
  
  /* 3. La zone des messages prend TOUTE la place restante et devient scrollable */
  .igpt-messages {
    flex-grow: 1; /* Permet à cet élément de s'étirer pour remplir l'espace vide */
    overflow-y: auto; /* C'EST LUI QUI SCROLLE, PAS LA FENÊTRE ENTIÈRE */
    
    /* Petite astuce pour que le scroll fonctionne bien sur mobile */
    -webkit-overflow-scrolling: touch;
  }
}
}