/* idealgpt-widget.css - Version du Plugin 1.1.3
 * (c) 2025 Agence de communication Idealcom | Lausanne | Suisse
 * https://www.idealcom.ch
 * Proprietary - Usage, copying, modification or redistribution
 * without explicit permission is prohibited.
 *
 * v1.1.1 — Safari/DuckDuckGo privé : localStorage protégé
 * v1.1.2 — Icônes SVG boutons header + send + avatar utilisateur + accolades CSS
 * v1.1.3 — Plein écran : left:0 !important, fenêtre non coupée à gauche
 */

:root {
  --idealgpt-primary-rgb: 90 27 143;
  --idealgpt-primary: rgb(var(--idealgpt-primary-rgb));
  --idealgpt-secondary: #4a1578;
  --idealgpt-secondary: color-mix(in srgb, var(--idealgpt-primary), black 18%);
  --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;
  --visual-viewport-height: 100vh;
  --scrollbar-width: 0px;
}

*, *::before, *::after { box-sizing: border-box; }
body.igpt-body-lock { overflow: hidden; }

#idealgpt-widget,
#idealgpt-widget * {
  font-weight: 400;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
}

#idealgpt-widget {
  position: fixed;
  left: var(--idealgpt-offset-left);
  bottom: var(--idealgpt-offset-bottom);
  z-index: 2147483647 !important;
  pointer-events: none;
}

/* ====== Fenêtre principale ====== */
.igpt-window {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: var(--visual-viewport-height);
  height: 100dvh;
  background: white;
  border-radius: 0;
  box-shadow: var(--idealgpt-shadow);
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  transition: var(--idealgpt-transition);
  pointer-events: none;
  z-index: 1;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.igpt-window.igpt-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ====== Bulle flottante ====== */
#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: 2;
  animation: igpt-pulse 2s infinite;
}
#idealgpt-widget .igpt-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 16px 50px rgba(0,0,0,0.2);
}
body.igpt-active #idealgpt-widget .igpt-bubble {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.8) !important;
}
body.igpt-active iframe[title="chat widget"] { display: none !important; }
.ios #idealgpt-widget .igpt-bubble {
  bottom: calc(var(--idealgpt-offset-bottom) + env(safe-area-inset-bottom)) !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;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.igpt-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}
.igpt-header .igpt-avatar { width: 36px; height: 36px; }
.igpt-header .igpt-avatar svg { width: 22px; height: 22px; }

#idealgpt-widget .igpt-info h3 {
  color: #ffffff;
  font-size: 16px;
  line-height: 1.2;
  margin: 0;
  font-weight: 500;
}

/* ====== Status ====== */
.igpt-status {
  font-size: 0.5rem !important;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}
.igpt-status span { line-height: 1 !important; }
.igpt-status-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--idealgpt-success);
  animation: igpt-blink 1.5s infinite;
}

/* ====== Boutons header ====== */
.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;
  flex-shrink: 0;
}
.igpt-btn:hover { background: rgba(255,255,255,0.3); transform: scale(1.05); }

/* v1.1.2 — SVG dans les boutons header visibles sur tous navigateurs */
.igpt-btn svg {
  width: 16px !important;
  height: 16px !important;
  display: block !important;
  flex-shrink: 0;
  pointer-events: none;
  stroke: white;
  fill: none;
}

/* Bouton fullscreen : caché par défaut sur mobile, affiché sur desktop via media query */
#idealgpt-widget #igpt-fullscreen { display: none; }
#idealgpt-widget #igpt-minimize   { display: none !important; }

/* ====== Avatars ====== */
.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;
}
.igpt-avatar svg,
.igpt-bubble-icon svg,
.igpt-message-avatar svg {
  width: 30px;
  height: auto;
  fill: currentColor;
}
.igpt-avatar, .igpt-bubble-icon { color: white; }

/* Avatar BOT dans les messages */
.igpt-message-avatar {
  width: 15px;
  color: var(--idealgpt-primary);
  background: none !important;
  border-radius: 0 !important;
}
.igpt-message-avatar svg { width: 100%; }

/* v1.1.2 — Avatar UTILISATEUR */
#idealgpt-widget .igpt-message.igpt-user .igpt-message-avatar {
  width: 28px;
  height: 28px;
  background: var(--idealgpt-primary) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  color: white;
}
#idealgpt-widget .igpt-message.igpt-user .igpt-message-avatar::after {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 12c2.7 0 4.8-2.1 4.8-4.8S14.7 2.4 12 2.4 7.2 4.5 7.2 7.2 9.3 12 12 12zm0 2.4c-3.2 0-9.6 1.6-9.6 4.8v2.4h19.2v-2.4c0-3.2-6.4-4.8-9.6-4.8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
}

/* ====== Zone de messages ====== */
.igpt-messages {
  flex: 1;
  min-height: 0;
  padding: 16px;
  background: var(--idealgpt-light);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.igpt-message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  animation: igpt-message-in 0.3s ease-out;
}

/* ====== Typing indicator ====== */
.igpt-typing {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: none;
}
.igpt-typing.igpt-show { display: flex; animation: igpt-fade-in 0.3s ease-out; }
.igpt-typing span { font-size: 0.52em !important; opacity: 0.9; }
.igpt-dots { display: flex; gap: 4px; }
.igpt-dot {
  width: 8px; height: 8px;
  background: var(--idealgpt-secondary);
  border-radius: 50%;
  animation: igpt-dot-bounce 1.4s infinite ease-in-out;
}
.igpt-dot:nth-child(1) { animation-delay: -0.32s; }
.igpt-dot:nth-child(2) { animation-delay: -0.16s; }

/* ====== Zone de saisie ====== */
.igpt-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 5px 16px;
  background: white;
  border-top: 1px solid var(--idealgpt-border);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.igpt-input-wrapper { flex: 1; min-width: 0; }
.igpt-input {
  width: 100%;
  min-height: 48px;
  line-height: 1.3;
  max-height: 88px;
  padding: 12px 16px;
  border: 2px solid var(--idealgpt-border);
  border-radius: 12px;
  background: var(--idealgpt-light);
  font-size: 16px;
  resize: none;
  outline: none;
}
.igpt-input:focus { border-color: var(--idealgpt-primary); background: white; }

.igpt-send-btn {
  width: 48px; height: 48px;
  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; }

/* v1.1.2 — SVG dans le bouton send */
.igpt-send-btn svg {
  width: 18px !important;
  height: 18px !important;
  display: block !important;
  pointer-events: none;
  stroke: white;
  fill: none;
  flex-shrink: 0;
}

/* ====== Footer ====== */
.igpt-footer {
  text-align: center;
  padding: 0 16px 12px;
  margin-top: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
#idealgpt-widget .igpt-footer-line1,
#idealgpt-widget .igpt-footer-line2 {
  color: rgb(73, 73, 73);
  text-align: center;
}
#idealgpt-widget .igpt-footer-line1 {
  font-size: 0.55rem !important;
  line-height: 1.2 !important;
  margin-bottom: 4px;
  font-weight: 400;
}
#idealgpt-widget .igpt-footer-line2 {
  font-size: 0.45rem !important;
  line-height: 1.2 !important;
  opacity: 0.90;
}

/* ====== Bulles de message ====== */
#idealgpt-widget .igpt-message.igpt-user {
  flex-direction: row-reverse !important;
}

#idealgpt-widget .igpt-message-bubble {
  max-width: 75% !important;
  padding: 12px 16px !important;
  border-radius: 18px !important;
  word-wrap: break-word !important;
  line-height: 1.4 !important;
  font-size: 14px !important;
}

#idealgpt-widget .igpt-message.igpt-bot .igpt-message-bubble {
  background: white !important;
  color: var(--idealgpt-text) !important;
  border: 1px solid var(--idealgpt-border) !important;
  border-bottom-left-radius: 6px !important;
}

#idealgpt-widget .igpt-message.igpt-user .igpt-message-bubble {
  background: var(--idealgpt-primary) !important;
  color: white !important;
  border-bottom-right-radius: 6px !important;
  padding: 8px 16px !important;
}

/* ====== Scrollbar ====== */
.igpt-messages::-webkit-scrollbar { width: 6px; }
.igpt-messages::-webkit-scrollbar-track { background: transparent; }
.igpt-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }

/* ====== Animations ====== */
@keyframes igpt-pulse {
  0%, 100% { box-shadow: var(--idealgpt-shadow), 0 0 0 0 rgb(from var(--idealgpt-secondary) r g b / 0.7); }
  50%       { box-shadow: var(--idealgpt-shadow), 0 0 0 10px rgb(from var(--idealgpt-secondary) r g b / 0); }
}
@keyframes igpt-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes igpt-message-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes igpt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes igpt-dot-bounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40%           { transform: scale(1.2); opacity: 1; }
}

/* ====== Desktop (≥769px) ====== */
@media (min-width: 769px) {

  /* Fenêtre normale : positionnée sur la bulle */
  #idealgpt-widget .igpt-window {
    width: 350px;
    height: auto;
    min-height: 200px;
    max-height: 80vh;
    position: fixed;
    top: auto;
    left: var(--idealgpt-offset-left);
    bottom: calc(var(--idealgpt-offset-bottom) + 85px);
    border-radius: var(--idealgpt-radius);
    padding: 0;
  }

  /* v1.1.3 — CORRECTIF PLEIN ÉCRAN : !important sur toutes les propriétés
     pour écraser left:var(--idealgpt-offset-left) hérité ci-dessus */
  #idealgpt-widget .igpt-window.igpt-fullscreen {
    width: 100% !important;
    height: 100vh !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 0 !important;
    max-height: 100vh !important;
  }

  body.igpt-active #idealgpt-widget .igpt-bubble {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: scale(1) !important;
  }

  /* Bouton plein écran visible sur desktop uniquement */
  #idealgpt-widget #igpt-fullscreen { display: flex !important; }

  .igpt-message-bubble { max-width: 280px; }
  body.igpt-body-lock { padding-right: var(--scrollbar-width); }
}
