/* ==========================================================================
   ECN GROUP — LUXURY AI CHATBOT COMPONENT ("ECN IA")
   Theme: Obsidian Glass, 24K Metallic Gold, Cinzel / Outfit Typography
   Fully responsive with mobile retractable bottom-sheet drawer
   100% White-Label (Zero "Powered by" branding)
   ========================================================================== */

/* Variables spécifiques au Chatbot ECN IA */
:root {
  --ecn-chat-gold: #d4af37;
  --ecn-chat-gold-light: #f5d77f;
  --ecn-chat-gold-dark: #8a6515;
  --ecn-chat-gold-glow: rgba(212, 175, 55, 0.35);
  --ecn-chat-bg-dark: #07090e;
  --ecn-chat-bg-panel: rgba(9, 12, 18, 0.96);
  --ecn-chat-border: rgba(212, 175, 55, 0.28);
  --ecn-chat-border-hover: rgba(212, 175, 55, 0.6);
  --ecn-chat-text: #f1f5f9;
  --ecn-chat-text-muted: #94a3b8;
  --ecn-chat-radius: 20px;
  --ecn-chat-zindex: 99990;
}

/* Offset du bouton Retour en Haut pour ne jamais se chevaucher */
body.ecn-chat-loaded .back-to-top-btn {
  bottom: 96px !important;
  right: 28px !important;
  transition: bottom 0.3s ease, right 0.3s ease, opacity 0.3s ease;
}

/* ==========================================================================
   1. BOUTON FLOTTANT (LAUNCHER FAB)
   ========================================================================== */
.ecn-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--ecn-chat-zindex);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #182030, #07090e 85%);
  border: 2px solid var(--ecn-chat-gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75), 0 0 25px var(--ecn-chat-gold-glow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  user-select: none;
  outline: none;
}

.ecn-chat-launcher:hover {
  transform: translateY(-4px) scale(1.06);
  border-color: var(--ecn-chat-gold-light);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85), 0 0 35px rgba(212, 175, 55, 0.6);
}

.ecn-chat-launcher:active {
  transform: translateY(-1px) scale(0.98);
}

/* Anneau de pulsation prestige autour du bouton */
.ecn-chat-launcher-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid var(--ecn-chat-gold);
  opacity: 0;
  animation: ecnLauncherPulse 3s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
}

@keyframes ecnLauncherPulse {
  0% {
    transform: scale(0.92);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.15);
    opacity: 0;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

/* Blason / Icône dans le bouton */
.ecn-chat-launcher-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.ecn-chat-launcher-close-icon {
  position: absolute;
  width: 22px;
  height: 22px;
  color: var(--ecn-chat-gold-light);
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* État quand la fenêtre est ouverte */
.ecn-chat-launcher.is-active .ecn-chat-launcher-icon {
  opacity: 0;
  transform: scale(0.5) rotate(90deg);
}

.ecn-chat-launcher.is-active .ecn-chat-launcher-close-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Badge Statut Vert "En ligne" sur le bouton */
.ecn-chat-launcher-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #07090e;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
}

/* Tooltip prestigieux sur hover */
.ecn-chat-launcher-tooltip {
  position: absolute;
  right: calc(100% + 14px);
  background: rgba(10, 14, 22, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--ecn-chat-border);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
  transition: all 0.25s ease;
}

.ecn-chat-launcher-tooltip strong {
  color: var(--ecn-chat-gold);
}

.ecn-chat-launcher:hover .ecn-chat-launcher-tooltip {
  opacity: 1;
  transform: translateX(0);
}

/* ==========================================================================
   2. FENÊTRE DE DISCUSSION (CHAT WINDOW)
   ========================================================================== */
.ecn-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 420px;
  height: 640px;
  max-height: calc(100vh - 120px);
  min-height: 480px;
  background: var(--ecn-chat-bg-panel);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--ecn-chat-border);
  border-radius: var(--ecn-chat-radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.88), 0 0 45px rgba(212, 175, 55, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: calc(var(--ecn-chat-zindex) + 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.32s;
}

/* Quand la fenêtre est ouverte */
.ecn-chat-window.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ==========================================================================
   3. EN-TÊTE DE LA FENÊTRE (HEADER)
   ========================================================================== */
.ecn-chat-header {
  background: linear-gradient(180deg, rgba(22, 28, 40, 0.98) 0%, rgba(12, 16, 24, 0.98) 100%);
  border-bottom: 1px solid var(--ecn-chat-border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  user-select: none;
  flex-shrink: 0;
}

/* Poignée mobile retractable (en haut de l'en-tête) */
.ecn-chat-sheet-handle {
  display: none;
  width: 44px;
  height: 5px;
  background: rgba(212, 175, 55, 0.45);
  border-radius: 3px;
  margin: 0 auto 10px auto;
  cursor: grab;
  transition: background 0.2s ease, width 0.2s ease;
}

.ecn-chat-sheet-handle:hover {
  background: var(--ecn-chat-gold-light);
  width: 52px;
}

.ecn-chat-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ecn-chat-avatar-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1f2737, #07090e);
  border: 1.5px solid var(--ecn-chat-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--ecn-chat-gold-glow);
}

.ecn-chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ecn-chat-avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #07090e;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.9);
}

.ecn-chat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ecn-chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ecn-chat-title {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #ffffff 0%, #f5d77f 50%, #d4af37 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
  line-height: 1.2;
}

.ecn-chat-tag {
  font-family: 'Outfit', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ecn-chat-gold-light);
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.35);
  padding: 2px 7px;
  border-radius: 9999px;
  text-transform: uppercase;
}

.ecn-chat-subtitle {
  font-family: 'Outfit', sans-serif;
  font-size: 0.74rem;
  color: var(--ecn-chat-text-muted);
  margin: 2px 0 0 0;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ecn-chat-subtitle-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: ecnDotBlink 2s infinite ease-in-out;
}

@keyframes ecnDotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Boutons d'action de l'en-tête (Refresh, Retract, Close) */
.ecn-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ecn-chat-action-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.18);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  padding: 0;
  outline: none;
}

.ecn-chat-action-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--ecn-chat-gold);
  color: #fff;
  transform: translateY(-1px);
}

.ecn-chat-action-btn:active {
  transform: translateY(0);
}

.ecn-chat-action-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

/* ==========================================================================
   4. SUGGESTIONS RAPIDES (QUICK PROMPT CHIPS)
   ========================================================================== */
.ecn-chat-chips-bar {
  background: rgba(14, 18, 28, 0.85);
  border-bottom: 1px solid rgba(212, 175, 55, 0.15);
  padding: 8px 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
}

.ecn-chat-chips-bar::-webkit-scrollbar {
  display: none;
}

.ecn-chat-chip {
  background: rgba(212, 175, 55, 0.07);
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: #f1f5f9;
  font-family: 'Outfit', sans-serif;
  font-size: 0.74rem;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  user-select: none;
}

.ecn-chat-chip:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--ecn-chat-gold-light);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Toast de notification instantanée quand une suggestion est cliquée */
.ecn-chat-toast {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(10, 14, 22, 0.95);
  border: 1px solid var(--ecn-chat-gold);
  color: var(--ecn-chat-gold-light);
  font-family: 'Outfit', sans-serif;
  font-size: 0.76rem;
  padding: 6px 14px;
  border-radius: 9999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

.ecn-chat-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   5. CORPS DU CHAT (IFRAME ET PLACEHOLDER DE CHARGEMENT)
   ========================================================================== */
.ecn-chat-body {
  flex: 1;
  position: relative;
  background: #080a10;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Placeholder de chargement prestigieux */
.ecn-chat-loading {
  position: absolute;
  inset: 0;
  background: #07090e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: opacity 0.4s ease, visibility 0.4s;
  padding: 24px;
  text-align: center;
}

.ecn-chat-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ecn-chat-spinner-wrap {
  position: relative;
  width: 68px;
  height: 68px;
  margin-bottom: 18px;
}

.ecn-chat-spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(212, 175, 55, 0.15);
  border-top-color: var(--ecn-chat-gold);
  border-right-color: var(--ecn-chat-gold-light);
  animation: ecnSpin 1s infinite linear;
}

@keyframes ecnSpin {
  to { transform: rotate(360deg); }
}

.ecn-chat-spinner-logo {
  position: absolute;
  inset: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  object-fit: contain;
  animation: ecnLogoPulse 2s infinite ease-in-out;
}

@keyframes ecnLogoPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.85; }
  50% { transform: scale(1.04); opacity: 1; }
}

.ecn-chat-loading-text {
  font-family: 'Cinzel', serif;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  color: var(--ecn-chat-gold-light);
  margin: 0 0 6px 0;
}

.ecn-chat-loading-sub {
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  color: var(--ecn-chat-text-muted);
  margin: 0;
}

/* L'Iframe du Chatbot Botpress */
.ecn-chat-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  flex: 1;
  display: block;
}

/* ==========================================================================
   6. MASQUAGE TOTAL DES WATERMARKS & "POWERED BY"
   ========================================================================== */
.bpComposerFooter,
.bp-powered-by,
[class*="poweredBy"],
[class*="watermark"],
[class*="footer"] a[href*="botpress"],
[class*="Footer"] a[href*="botpress"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ==========================================================================
   7. MODE MOBILE RETRACTABLE (DRAWER RETRACTABLE EN BAS)
   ========================================================================== */
@media (max-width: 768px) {
  /* Bouton Launcher sur mobile */
  .ecn-chat-launcher {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  .ecn-chat-launcher-icon {
    width: 32px;
    height: 32px;
  }

  .ecn-chat-launcher-tooltip {
    display: none !important;
  }

  /* Fenêtre Mobile en Bottom Sheet complète */
  .ecn-chat-window {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 88vh;
    height: 88dvh;
    max-height: 88dvh;
    min-height: auto;
    border-radius: 24px 24px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease;
  }

  .ecn-chat-window.is-open {
    transform: translateY(0);
  }

  /* Poignée tactile de rétractation visible sur mobile */
  .ecn-chat-sheet-handle {
    display: block;
  }

  .ecn-chat-header {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 16px 12px 16px;
    cursor: pointer;
  }

  .ecn-chat-header-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  /* ÉTAT RÉTRACTÉ SUR MOBILE (DOCKED EN BAS) */
  .ecn-chat-window.is-retracted {
    height: 68px !important;
    max-height: 68px !important;
    min-height: 68px !important;
    transform: translateY(0) !important;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.9), 0 0 20px rgba(212, 175, 55, 0.25);
  }

  .ecn-chat-window.is-retracted .ecn-chat-chips-bar,
  .ecn-chat-window.is-retracted .ecn-chat-body {
    display: none !important;
  }

  .ecn-chat-window.is-retracted .ecn-chat-subtitle {
    display: none;
  }

  .ecn-chat-window.is-retracted .ecn-chat-action-minimize svg {
    transform: rotate(180deg);
  }

  /* Safe Area iOS */
  .ecn-chat-body {
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
}
