/* =============================================================================
   GtPrestachat — Styles du widget chat
   Compatible avec les thèmes PS 1.7 / 8 / 9 (Classic, Hummingbird, etc.)
   ============================================================================= */

/* --- Variables CSS --- */
:root {
  --gtchat-primary:      #2563eb;
  --gtchat-primary-dark: #1d4ed8;
  --gtchat-bg:           #ffffff;
  --gtchat-bg-user:      #2563eb;
  --gtchat-bg-bot:       #f1f5f9;
  --gtchat-text-user:    #ffffff;
  --gtchat-text-bot:     #1e293b;
  --gtchat-border:       #e2e8f0;
  --gtchat-radius:       16px;
  --gtchat-shadow:       0 8px 32px rgba(0, 0, 0, 0.15);
  --gtchat-z:            9999;
  --gtchat-width:        360px;
  --gtchat-height:       480px;
}

/* --- Conteneur principal --- */
.gtchat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--gtchat-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
}

/* --- Bouton toggle --- */
.gtchat-toggle {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--gtchat-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--gtchat-shadow);
  transition: background 0.2s ease, transform 0.15s ease;
}

.gtchat-toggle:hover,
.gtchat-toggle:focus-visible {
  background: var(--gtchat-primary-dark);
  transform: scale(1.05);
  outline: 3px solid var(--gtchat-primary);
  outline-offset: 2px;
}

/* Badge notification */
.gtchat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}

/* --- Fenêtre de chat --- */
.gtchat-box {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: var(--gtchat-width);
  max-width: calc(100vw - 32px);
  height: var(--gtchat-height);
  max-height: calc(100vh - 120px);
  background: var(--gtchat-bg);
  border-radius: var(--gtchat-radius);
  box-shadow: var(--gtchat-shadow);
  border: 1px solid var(--gtchat-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: gtchat-fadeUp 0.2s ease;
}

@keyframes gtchat-fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Header --- */
.gtchat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--gtchat-primary);
  color: #fff;
  flex-shrink: 0;
}

.gtchat-title {
  font-weight: 600;
  font-size: 15px;
}

.gtchat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.gtchat-close:hover,
.gtchat-close:focus-visible {
  opacity: 1;
  outline: 2px solid rgba(255,255,255,0.6);
  border-radius: 4px;
}

/* --- Zone messages --- */
.gtchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* --- Message individuel --- */
.gtchat-message {
  display: flex;
  max-width: 85%;
}

.gtchat-message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.gtchat-message--assistant {
  align-self: flex-start;
}

.gtchat-bubble {
  padding: 10px 14px;
  border-radius: var(--gtchat-radius);
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.gtchat-message--user .gtchat-bubble {
  background: var(--gtchat-bg-user);
  color: var(--gtchat-text-user);
  border-bottom-right-radius: 4px;
}

.gtchat-message--assistant .gtchat-bubble {
  background: var(--gtchat-bg-bot);
  color: var(--gtchat-text-bot);
  border-bottom-left-radius: 4px;
}

/* --- Animation de saisie (3 points) --- */
.gtchat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 2px;
  border-radius: 50%;
  background: #94a3b8;
  animation: gtchat-bounce 1.2s infinite;
}
.gtchat-dot:nth-child(2) { animation-delay: 0.2s; }
.gtchat-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes gtchat-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* --- Zone de saisie --- */
.gtchat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--gtchat-border);
  flex-shrink: 0;
  background: var(--gtchat-bg);
}

.gtchat-input {
  flex: 1;
  border: 1px solid var(--gtchat-border);
  border-radius: 24px;
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  background: #f8fafc;
  color: #1e293b;
  transition: border-color 0.15s;
}
.gtchat-input:focus {
  border-color: var(--gtchat-primary);
  background: #fff;
}

.gtchat-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--gtchat-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.gtchat-send:hover,
.gtchat-send:focus-visible {
  background: var(--gtchat-primary-dark);
  transform: scale(1.05);
  outline: 3px solid var(--gtchat-primary);
  outline-offset: 2px;
}

/* --- Accessibilité : masque visuel --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --- Responsive mobile --- */
@media (max-width: 480px) {
  .gtchat-widget {
    bottom: 12px;
    right: 12px;
  }

  .gtchat-box {
    bottom: 68px;
    right: -12px;
    width: calc(100vw - 24px);
    max-width: 100vw;
    height: 60vh;
    max-height: 60vh;
    border-radius: 12px;
  }
}
