/**
 * Widget diagnostic INFORMATH — chat bas-droite
 */

.diag-contact-bridge {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.diag-chat {
  --diag-blue: #121F59;
  --diag-blue-70: rgba(18, 31, 89, 0.7);
  --diag-blue-15: rgba(18, 31, 89, 0.15);
  --diag-blue-10: rgba(18, 31, 89, 0.1);
  --diag-white: #fff;
  --diag-radius: 16px;
  --diag-shadow: 0 12px 40px rgba(18, 31, 89, 0.18);
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 99990;
  width: min(360px, calc(100vw - 1.5rem));
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--diag-blue);
}

.diag-chat * {
  box-sizing: border-box;
}

.diag-chat__panel {
  background: var(--diag-white);
  border: 1px solid var(--diag-blue-15);
  border-radius: var(--diag-radius);
  box-shadow: var(--diag-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: min(580px, calc(100vh - 2rem));
  max-height: min(580px, calc(100vh - 2rem));
  transform-origin: bottom right;
  transition: height 0.28s ease, max-height 0.28s ease, box-shadow 0.2s ease;
}

.diag-chat.is-collapsed .diag-chat__panel {
  height: 72px;
  max-height: 72px;
}

.diag-chat__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.2rem;
  background: var(--diag-blue);
  color: var(--diag-white);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  min-height: 64px;
}

.diag-chat__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.diag-chat__header-text {
  flex: 1;
  min-width: 0;
  padding: 0.1rem 0;
}

.diag-chat__title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
}

.diag-chat__subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  line-height: 1.35;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diag-chat__toggle {
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  line-height: 1;
}

.diag-chat__toggle:hover {
  background: rgba(255, 255, 255, 0.22);
}

.diag-chat__body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.diag-chat.is-collapsed .diag-chat__body {
  display: none;
}

.diag-chat__messages {
  padding: 1rem 1.15rem;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #f7f8fc;
  -webkit-overflow-scrolling: touch;
}

.diag-msg {
  max-width: 92%;
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  animation: diagMsgIn 0.25s ease both;
}

.diag-msg--bot {
  align-self: flex-start;
  background: var(--diag-white);
  border: 1px solid var(--diag-blue-15);
  border-bottom-left-radius: 4px;
  color: var(--diag-blue);
}

.diag-msg--user {
  align-self: flex-end;
  background: var(--diag-blue);
  color: var(--diag-white);
  border-bottom-right-radius: 4px;
}

.diag-msg--hint {
  align-self: flex-start;
  background: var(--diag-blue-10);
  border: 1px dashed var(--diag-blue-15);
  color: var(--diag-blue-70);
  font-size: 0.84rem;
}

.diag-chat__actions {
  padding: 0.85rem 1.15rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: var(--diag-white);
  border-top: 1px solid var(--diag-blue-15);
  flex-shrink: 0;
}

.diag-chat__choice {
  appearance: none;
  border: 1.5px solid var(--diag-blue-15);
  background: var(--diag-white);
  color: var(--diag-blue);
  border-radius: 999px;
  padding: 0.6rem 0.9rem;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
  line-height: 1.3;
}

.diag-chat__choice:hover,
.diag-chat__choice:focus {
  background: var(--diag-blue-10);
  border-color: var(--diag-blue);
  outline: none;
}

.diag-chat__choice:active {
  transform: scale(0.98);
}

.diag-chat__form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.9rem 1.15rem 1.1rem;
  background: var(--diag-white);
  border-top: 1px solid var(--diag-blue-15);
  flex-shrink: 0;
}

.diag-chat__form[hidden] {
  display: none !important;
}

.diag-chat__field {
  margin: 0 !important;
  width: 100% !important;
  max-width: none !important;
  padding: 0 !important;
}

.diag-chat__field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--diag-blue-70);
  margin-bottom: 0.2rem;
}

.diag-chat__field input {
  width: 100%;
  border: 1px solid var(--diag-blue-15);
  background: var(--diag-blue-10);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--diag-blue);
}

.diag-chat__field input:focus {
  outline: 2px solid rgba(18, 31, 89, 0.25);
  border-color: var(--diag-blue);
  background: var(--diag-white);
}

.diag-chat__submit {
  appearance: none;
  border: 0;
  background: var(--diag-blue);
  color: var(--diag-white);
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.25rem;
}

.diag-chat__submit:hover {
  background: #0d1745;
}

.diag-chat__submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.diag-chat__status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--diag-blue-70);
  text-align: center;
}

.diag-chat__status.is-error {
  color: #b42318;
}

.diag-chat__status.is-success {
  color: #067647;
}

.diag-chat__restart {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--diag-blue);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
  padding: 0.25rem;
}

@keyframes diagMsgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .diag-chat {
    right: 0.65rem;
    bottom: 0.65rem;
    width: calc(100vw - 1.3rem);
  }

  .diag-chat__panel {
    height: min(75vh, 620px);
    max-height: min(75vh, 620px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .diag-msg,
  .diag-chat__panel {
    animation: none;
    transition: none;
  }
}
