/* =========================================================
   WebProfs AI
   Style moderne / scientifique / responsive
   ========================================================= */

#webprofs-ai-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99999;
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* =========================================================
   BOUTON FLOTTANT — PLUS PETIT
   ========================================================= */

#webprofs-ai-toggle {
  width: 48px;
  height: 48px;

  border: none;
  border-radius: 50%;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  background:
    radial-gradient(
      circle at 30% 30%,
      #5eead4 0%,
      #22d3ee 24%,
      #2563eb 62%,
      #1e3a8a 100%
    );

  box-shadow:
    0 8px 20px rgba(15, 23, 42, 0.24),
    0 0 0 4px rgba(37, 99, 235, 0.08);

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

#webprofs-ai-toggle:hover {
  transform: translateY(-2px) scale(1.05);

  box-shadow:
    0 12px 26px rgba(15, 23, 42, 0.30),
    0 0 0 6px rgba(34, 211, 238, 0.10);

  filter: brightness(1.05);
}

#webprofs-ai-toggle:active {
  transform: scale(0.96);
}

#webprofs-ai-toggle:focus-visible {
  outline: 3px solid rgba(34, 211, 238, 0.50);
  outline-offset: 3px;
}

/* Texte AI + étoile */
.webprofs-ai-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;

  color: #ffffff;

  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1;
}

.webprofs-ai-toggle-star {
  position: relative;
  top: -5px;

  font-size: 9px;

  color: #fde68a;

  text-shadow:
    0 0 6px rgba(253, 230, 138, 0.8);
}

/* =========================================================
   PANNEAU PRINCIPAL
   ========================================================= */

#webprofs-ai-panel {
  position: absolute;

  right: 0;
  bottom: 66px;

  width: 390px;
  max-width: calc(100vw - 28px);

  height: 560px;
  max-height: calc(100vh - 110px);

  display: flex;
  flex-direction: column;

  overflow: hidden;

  border-radius: 22px;

  border:
    1px solid
    rgba(148, 163, 184, 0.28);

  background:
    rgba(255, 255, 255, 0.94);

  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.24),
    0 8px 24px rgba(15, 23, 42, 0.12);
}

.webprofs-ai-hidden {
  display: none !important;
}

/* =========================================================
   EN-TÊTE
   ========================================================= */

#webprofs-ai-header {
  position: relative;

  padding:
    18px 58px
    14px 18px;

  color: #ffffff;

  background:
    radial-gradient(
      circle at 80% 20%,
      rgba(34, 211, 238, 0.20),
      transparent 32%
    ),
    linear-gradient(
      135deg,
      #0f172a 0%,
      #153e75 45%,
      #1d4ed8 100%
    );

  border-bottom:
    1px solid
    rgba(255, 255, 255, 0.12);
}

#webprofs-ai-header strong {
  display: block;

  font-size: 18px;
  font-weight: 700;

  letter-spacing: 0.2px;
}

.webprofs-ai-subtitle {
  margin-top: 6px;

  display: inline-flex;
  align-items: center;
  gap: 8px;

  font-size: 12px;

  color:
    rgba(226, 232, 240, 0.95);
}

/* voyant vert */
.webprofs-ai-subtitle::before {
  content: "";

  width: 9px;
  height: 9px;

  border-radius: 50%;

  background: #34d399;

  box-shadow:
    0 0 8px rgba(52, 211, 153, 0.9),
    0 0 18px rgba(52, 211, 153, 0.45);
}

/* bouton fermeture */
#webprofs-ai-close {
  position: absolute;

  top: 12px;
  right: 12px;

  width: 38px;
  height: 38px;

  border: none;
  border-radius: 12px;

  background:
    rgba(255, 255, 255, 0.10);

  color: #ffffff;

  font-size: 24px;
  line-height: 1;

  cursor: pointer;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

#webprofs-ai-close:hover {
  background:
    rgba(255, 255, 255, 0.18);

  transform: scale(1.05);
}

#webprofs-ai-close:active {
  transform: scale(0.96);
}

/* =========================================================
   ZONE DE MESSAGES
   ========================================================= */

#webprofs-ai-messages {
  flex: 1;

  overflow-y: auto;

  overscroll-behavior: contain;

  padding: 18px;

  background:
    radial-gradient(
      circle at top left,
      rgba(96, 165, 250, 0.10),
      transparent 28%
    ),
    linear-gradient(
      180deg,
      #f8fbff 0%,
      #eef4fb 100%
    );

  scrollbar-width: thin;

  scrollbar-color:
    rgba(148, 163, 184, 0.45)
    transparent;
}

#webprofs-ai-messages::-webkit-scrollbar {
  width: 8px;
}

#webprofs-ai-messages::-webkit-scrollbar-track {
  background: transparent;
}

#webprofs-ai-messages::-webkit-scrollbar-thumb {
  background:
    rgba(148, 163, 184, 0.45);

  border-radius: 10px;
}

/* =========================================================
   BULLES DE DIALOGUE
   ========================================================= */

.webprofs-ai-message {
  max-width: 84%;

  padding: 12px 14px;

  margin: 10px 0;

  border-radius: 18px;

  line-height: 1.5;

  white-space: pre-wrap;

  word-wrap: break-word;
  overflow-wrap: anywhere;

  font-size: 14px;

  box-shadow:
    0 6px 16px
    rgba(15, 23, 42, 0.06);
}

/* message assistant */
.webprofs-ai-message.bot {
  background:
    rgba(255, 255, 255, 0.94);

  color: #0f172a;

  border:
    1px solid
    rgba(203, 213, 225, 0.8);

  border-top-left-radius: 8px;
}

/* message utilisateur */
.webprofs-ai-message.user {
  margin-left: auto;

  color: #ffffff;

  background:
    linear-gradient(
      135deg,
      #2563eb 0%,
      #1e40af 100%
    );

  border-top-right-radius: 8px;

  box-shadow:
    0 7px 18px
    rgba(37, 99, 235, 0.18);
}

/* message réflexion */
.webprofs-ai-message.pending {
  font-style: italic;

  color: #475569;

  background:
    rgba(255, 255, 255, 0.78);

  border:
    1px solid
    rgba(203, 213, 225, 0.65);

  opacity: 0.9;
}

/* =========================================================
   BOUTONS RAPIDES
   ========================================================= */

#webprofs-ai-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;

  padding:
    12px 14px
    10px 14px;

  background:
    rgba(255, 255, 255, 0.96);

  border-top:
    1px solid
    rgba(226, 232, 240, 0.9);
}

#webprofs-ai-quick button {
  border:
    1px solid
    rgba(96, 165, 250, 0.35);

  background:
    linear-gradient(
      180deg,
      #ffffff 0%,
      #f8fbff 100%
    );

  color: #1e3a8a !important;

  border-radius: 999px;

  padding: 8px 12px;

  cursor: pointer;

  font-size: 12px;
  font-weight: 600;

  letter-spacing: 0.1px;

  box-shadow:
    0 3px 10px
    rgba(15, 23, 42, 0.04);

  transition:
    all 0.2s ease;
}

#webprofs-ai-quick button:hover {
  transform: translateY(-1px);

  background:
    linear-gradient(
      180deg,
      #eff6ff 0%,
      #dbeafe 100%
    );

  border-color:
    rgba(37, 99, 235, 0.45);

  color: #1e40af !important;
}

#webprofs-ai-quick button:active {
  transform: scale(0.97);
}

/* =========================================================
   FORMULAIRE
   ========================================================= */

#webprofs-ai-form {
  display: flex;

  align-items: flex-end;

  gap: 10px;

  padding: 14px;

  background:
    rgba(255, 255, 255, 0.97);

  border-top:
    1px solid
    rgba(226, 232, 240, 0.9);
}

/* champ */
#webprofs-ai-input {
  flex: 1;

  min-height: 52px;
  max-height: 120px;

  resize: none;

  border:
    1px solid
    rgba(148, 163, 184, 0.45);

  border-radius: 16px;

  padding: 13px 14px;

  font: inherit;
  font-size: 15px;

  color: #0f172a;

  background: #f8fafc;

  outline: none;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

#webprofs-ai-input::placeholder {
  color: #64748b;
}

#webprofs-ai-input:focus {
  border-color: #3b82f6;

  background: #ffffff;

  box-shadow:
    0 0 0 4px
    rgba(59, 130, 246, 0.12);
}

/* bouton envoyer */
#webprofs-ai-form button {
  height: 52px;

  min-width: 96px;

  border: none;

  border-radius: 16px;

  padding: 0 18px;

  background:
    linear-gradient(
      135deg,
      #0f172a 0%,
      #1d4ed8 100%
    );

  color: #ffffff;

  font-weight: 700;
  font-size: 15px;

  cursor: pointer;

  box-shadow:
    0 8px 18px
    rgba(29, 78, 216, 0.22);

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

#webprofs-ai-form button:hover {
  transform: translateY(-1px);

  box-shadow:
    0 12px 24px
    rgba(29, 78, 216, 0.26);
}

#webprofs-ai-form button:active {
  transform: scale(0.98);
}

/* =========================================================
   PIED
   ========================================================= */

#webprofs-ai-footer {
  padding:
    0 14px
    calc(
      12px
      + env(safe-area-inset-bottom)
    );

  background:
    rgba(255, 255, 255, 0.97);

  text-align: center;

  font-size: 11px;

  color: #64748b;
}

/* =========================================================
   TABLETTES
   ========================================================= */

@media (max-width: 900px) {

  #webprofs-ai-root {
    right: 16px;
    bottom: 16px;
  }

  #webprofs-ai-panel {
    width:
      min(
        420px,
        calc(100vw - 24px)
      );

    height:
      min(
        620px,
        calc(100dvh - 100px)
      );

    max-height:
      calc(100dvh - 100px);
  }

  #webprofs-ai-toggle {
    width: 46px;
    height: 46px;
  }

  .webprofs-ai-toggle-icon {
    font-size: 13px;
  }

  .webprofs-ai-toggle-star {
    font-size: 8px;
  }
}

/* =========================================================
   SMARTPHONES
   ========================================================= */

@media (max-width: 600px) {

  #webprofs-ai-root {
    right: 10px;

    bottom:
      calc(
        10px
        + env(safe-area-inset-bottom)
      );
  }

  /* encore plus petit sur mobile */
  #webprofs-ai-toggle {
    width: 44px;
    height: 44px;
  }

  .webprofs-ai-toggle-icon {
    font-size: 12px;
  }

  .webprofs-ai-toggle-star {
    top: -4px;
    font-size: 7px;
  }

  #webprofs-ai-panel {
    position: fixed;

    left: 10px;
    right: 10px;

    bottom:
      calc(
        66px
        + env(safe-area-inset-bottom)
      );

    width: auto;

    height:
      calc(
        100dvh
        - 88px
        - env(safe-area-inset-bottom)
      );

    max-height: none;

    border-radius: 18px;
  }

  #webprofs-ai-header {
    padding:
      14px 54px
      12px 16px;
  }

  #webprofs-ai-header strong {
    font-size: 16px;
  }

  .webprofs-ai-subtitle {
    font-size: 11px;
  }

  #webprofs-ai-close {
    width: 34px;
    height: 34px;

    top: 10px;
    right: 10px;
  }

  #webprofs-ai-messages {
    padding: 12px;
  }

  .webprofs-ai-message {
    max-width: 90%;

    font-size: 14px;

    padding: 10px 12px;

    margin: 8px 0;
  }

  #webprofs-ai-quick {
    gap: 6px;

    padding:
      8px 10px;
  }

  #webprofs-ai-quick button {
    font-size: 11px;

    padding:
      7px 10px;
  }

  #webprofs-ai-form {
    padding: 10px;

    gap: 8px;
  }

  #webprofs-ai-input {
    min-height: 48px;

    font-size: 16px;

    padding:
      11px 12px;
  }

  #webprofs-ai-form button {
    min-width: 76px;

    height: 48px;

    padding:
      0 12px;

    font-size: 14px;
  }

  #webprofs-ai-footer {
    font-size: 10px;

    padding:
      0 10px
      calc(
        8px
        + env(safe-area-inset-bottom)
      );
  }
}

/* =========================================================
   TRÈS PETITS ÉCRANS
   ========================================================= */

@media (max-width: 380px) {

  #webprofs-ai-root {
    right: 6px;
  }

  #webprofs-ai-toggle {
    width: 42px;
    height: 42px;
  }

  .webprofs-ai-toggle-icon {
    font-size: 11px;
  }

  #webprofs-ai-panel {
    left: 6px;
    right: 6px;

    bottom:
      calc(
        62px
        + env(safe-area-inset-bottom)
      );

    height:
      calc(
        100dvh
        - 78px
        - env(safe-area-inset-bottom)
      );
  }

  #webprofs-ai-form {
    flex-direction: column;

    align-items: stretch;
  }

  #webprofs-ai-form button {
    width: 100%;
    min-width: 0;
  }

  #webprofs-ai-quick {
    overflow-x: auto;

    flex-wrap: nowrap;
  }

  #webprofs-ai-quick button {
    flex:
      0 0 auto;
  }
}

/* =========================================================
   MOBILE PAYSAGE
   ========================================================= */

@media (max-width: 900px)
       and (orientation: landscape) {

  #webprofs-ai-panel {
    height:
      calc(100dvh - 24px);

    top: 12px;

    bottom: auto;

    max-height: none;
  }

  #webprofs-ai-messages {
    padding: 10px;
  }

  #webprofs-ai-quick {
    padding:
      6px 10px;
  }

  #webprofs-ai-form {
    padding:
      8px 10px;
  }

  #webprofs-ai-footer {
    padding-bottom: 6px;
  }
}