/* Inline mode */

.chatkit-lpa-inline {
  position: relative;
  width: 100%;
  min-height: 500px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.chatkit-lpa-inline openai-chatkit {
  display: block;
  width: 100%;
  height: 100%;
}

/* Bubble mode */

/*
 * Desktop : z-index bas pour rester SOUS la bannière cookies Complianz (.cmplz-cookiebanner, souvent 99999+).
 * Mobile : z-index maximal (voir @media max-width 480px) pour passer au-dessus des menus plein écran.
 */
.chatkit-lpa-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99990;
}

.chatkit-lpa-launcher-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.chatkit-lpa-launcher-label {
  padding: 8px 12px;
  border-radius: 999px;
  background: #758ec9;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 10px 30px rgba(117, 142, 201, 0.28);
}

#chatkit-lpa-launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  padding: 0;
  background: #758ec9;
  border: 1px solid #758ec9;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(117, 142, 201, 0.32);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chatkit-lpa-launcher:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(117, 142, 201, 0.38);
}

#chatkit-lpa-launcher img,
#chatkit-lpa-launcher svg {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 50%;
}

.chatkit-lpa-launcher-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

/* Panel */

#chatkit-lpa-panel {
  position: absolute;
  bottom: 88px;
  right: 0;
  width: 420px;
  height: 680px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(17, 24, 39, 0.2);
  background: #fff;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform-origin: bottom right;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.chatkit-lpa-chat-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chatkit-lpa-panel openai-chatkit,
.chatkit-lpa-chat-wrapper openai-chatkit {
  flex: 1 1 0%;
  min-height: 0;
  display: block;
  width: 100%;
}

.chatkit-lpa-chat-wrapper iframe,
#chatkit-lpa-panel iframe {
  width: 100% !important;
  height: 100% !important;
  min-height: 400px !important;
}

/* Header */

.chatkit-lpa-custom-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #758ec9;
  color: #fff;
  flex-shrink: 0;
}

.chatkit-lpa-header-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.chatkit-lpa-header-end {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chatkit-lpa-header-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
  /* Assure un rendu blanc si le SVG n’est pas déjà en blanc */
  filter: brightness(0) invert(1);
}

.chatkit-lpa-header-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.95;
}

#chatkit-lpa-panel.chatkit-lpa-panel-visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

#chatkit-lpa-panel.chatkit-lpa-panel-hidden {
  opacity: 0;
  transform: scale(0.94) translateY(10px);
  pointer-events: none;
}

/* Responsive */

@media (max-width: 768px) {
  #chatkit-lpa-panel {
    width: min(420px, calc(100vw - 24px));
    max-width: 100%;
    height: min(680px, calc(100dvh - 64px));
    max-height: calc(100dvh - 64px);
  }
}

@media (max-width: 480px) {
  .chatkit-lpa-bubble {
    bottom: 16px;
    right: 16px;
    z-index: 2147483646;
  }

  .chatkit-lpa-launcher-label {
    font-size: 13px;
  }

  #chatkit-lpa-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    box-sizing: border-box;
    overflow: hidden;
    z-index: 2147483646;
  }

  .chatkit-lpa-custom-header {
    padding: 10px 12px;
    flex: 0 0 56px;
    height: 56px;
    box-sizing: border-box;
  }

  .chatkit-lpa-header-logo {
    width: 32px;
    height: 32px;
  }

  .chatkit-lpa-header-title {
    font-size: 14px;
  }

  .chatkit-lpa-chat-wrapper {
    position: relative;
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .chatkit-lpa-chat-wrapper openai-chatkit {
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    display: block;
  }

  .chatkit-lpa-chat-wrapper iframe,
  #chatkit-lpa-panel iframe {
    min-height: 0 !important;
    height: 100% !important;
  }

  .chatkit-lpa-inline {
    min-height: 400px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

/* Complianz : au-dessus du chat sur grand écran (si le thème / plugin met un z-index plus bas) */
@media (min-width: 481px) {
  #cmplz-cookiebanner-container .cmplz-cookiebanner,
  .cmplz-cookiebanner.cmplz-show {
    z-index: 100000;
  }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 480px) {
    #chatkit-lpa-panel {
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}

@supports not (height: 100dvh) {
  @media (max-width: 768px) {
    #chatkit-lpa-panel {
      height: min(680px, calc(100vh - 64px));
      max-height: calc(100vh - 64px);
    }
  }
}
