/* ----- Header du thème masqué sur tablette et mobile ----- */
@media (max-width: 991px) {
  #medi-app-header,
  #medi-app-header .medi-app-main-header,
  #medi-app-header > * {
    display: none !important;
  }
}

/* ----- Footer AskMed (page d'accueil) ----- */

/* Masquer le footer du thème (AppMedi) : remplacé par notre footer AskMed */
body.home #app-medi-footer,
body.home #app-medi-footer .medi-app-background_overlay {
  display: none !important;
}

#askmed-footer {
  background: #fff;
  border-top: 1px solid #eef0f3;
  padding: 30px 24px 26px;
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#askmed-footer .askmed-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

#askmed-footer .askmed-footer-badges {
  display: flex;
  align-items: center;
  gap: clamp(28px, 6vw, 80px);
  flex-wrap: wrap;
}

#askmed-footer .askmed-badge {
  height: 52px;
  width: auto;
  display: block;
}

/* Badge DigiCert officiel (logo + SECURED) */
#askmed-footer .askmed-badge-digicert {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 3px;
  width: auto;
}

#askmed-footer .askmed-badge-digicert img {
  height: 20px;
  width: auto;
  display: block;
}

#askmed-footer .askmed-badge-digicert small {
  font-size: 8.5px;
  letter-spacing: 1.6px;
  color: #5f6b76;
  font-family: Arial, sans-serif;
  line-height: 1;
}

#askmed-footer .askmed-footer-copy {
  margin-top: 26px;
}

#askmed-footer .askmed-footer-copy p {
  margin: 0 0 4px;
  font-size: 14px;
  color: #3d4750;
}

#askmed-footer .askmed-footer-links {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

#askmed-footer .askmed-footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #3d4750;
  font-size: 14px;
  text-decoration: none;
  transition: color 0.15s ease;
}

#askmed-footer .askmed-footer-links a:hover {
  color: #e12454;
}

#askmed-footer .askmed-privacy-toggle {
  display: inline-block;
  vertical-align: middle;
}

/* Tablette + mobile : tout centré, badges réduits */
@media (max-width: 991px) {
  #askmed-footer {
    padding: 26px 18px 22px;
    text-align: center;
  }

  #askmed-footer .askmed-footer-badges {
    justify-content: center;
    gap: 18px 26px;
  }

  #askmed-footer .askmed-badge {
    height: 38px;
  }

  #askmed-footer .askmed-badge-digicert {
    height: 38px;
  }

  #askmed-footer .askmed-badge-digicert img {
    height: 15px;
  }

  #askmed-footer .askmed-badge-digicert small {
    font-size: 7px;
  }

  #askmed-footer .askmed-footer-copy {
    margin-top: 22px;
  }

  #askmed-footer .askmed-footer-links {
    justify-content: center;
    gap: 14px 20px;
  }
}

/* ----- Logo + Contact Us flottants (page d'accueil, desktop) ----- */
#askmed-home-brand {
  position: absolute;
  top: 64px;
  left: 52px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#askmed-home-brand .askmed-home-logo {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  text-decoration: none;
}

#askmed-home-brand .askmed-home-logo img {
  width: 185px;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(16, 24, 40, 0.25));
}

#askmed-home-brand .askmed-home-contact {
  display: inline-flex;
  align-items: center;
  padding: 11px 22px;
  background: #fff;
  border-radius: 999px;
  color: var(--askmed-primary-dark, #c71f4b);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.18);
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

#askmed-home-brand .askmed-home-contact:hover {
  background: #fdf0f4;
  color: #e12454;
  transform: translateY(-1px);
}

@media (max-width: 991px) {
  #askmed-home-brand {
    display: none;
  }
}

/* ----- Barre blanche en haut (mobile/tablette) ----- */
#askmed-mobile-topbar {
  position: relative;
  width: 100%;
  display: none;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  padding: 9px 16px;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.08);
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#askmed-mobile-topbar .askmed-mobile-logo {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  text-decoration: none;
}

#askmed-mobile-topbar .askmed-mobile-logo img {
  height: 32px;
  width: auto;
  display: block;
}

#askmed-mobile-topbar .askmed-mobile-contact {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  background: #e12454;
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 991px) {
  #askmed-mobile-topbar {
    display: flex;
  }
}

#askmed-chat {
  --askmed-primary: #e12454;
  --askmed-primary-dark: #c71f4b;
  --askmed-navy: #162b3d;
  --askmed-green: #35c759;

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99999;
  width: 460px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100dvh - 48px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 34px rgba(15, 35, 55, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  box-sizing: border-box;
}

#askmed-chat *,
#askmed-chat *::before,
#askmed-chat *::after { box-sizing: border-box; }

/* ----- En-tête ----- */
#askmed-chat .askmed-header {
  position: relative;
  background: var(--askmed-navy);
  padding: 22px 20px;
  flex-shrink: 0;
}

#askmed-chat .askmed-header h1 {
  margin: 0 0 18px;
  color: #f6c2d3;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

#askmed-chat .askmed-doctors-row {
  display: flex;
  align-items: center;
}

#askmed-chat .askmed-avatars {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

#askmed-chat .askmed-avatars img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
  display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

#askmed-chat .askmed-avatars img + img,
#askmed-chat .askmed-avatars img + .askmed-avatar-wrap { margin-left: -10px; }

#askmed-chat .askmed-avatar-wrap {
  position: relative;
  margin-left: -10px;
  display: inline-block;
  line-height: 0;
}

#askmed-chat .askmed-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  background: var(--askmed-green);
  border-radius: 50%;
  border: 2px solid #fff;
}

#askmed-chat .askmed-info { margin-left: 14px; text-align: left; }

#askmed-chat .askmed-info h2 {
  margin: 0;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

#askmed-chat .askmed-info p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.35;
}

/* ----- Bulle flottante (mobile) : avatar + texte de bienvenue ----- */
#askmed-fab-wrap {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 999999;
  align-items: flex-end;
  gap: 10px;
}

#askmed-fab-wrap.askmed-visible {
  display: flex;
  animation: askmed-pop 0.25s ease;
}

#askmed-fab {
  position: relative;
  width: 60px;
  height: 60px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 8px 22px rgba(225, 36, 84, 0.42);
}

#askmed-fab img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
  display: block;
}

#askmed-fab .askmed-dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 12px;
  height: 12px;
  background: #35c759;
  border: 2px solid #fff;
  border-radius: 50%;
}

#askmed-fab-text {
  max-width: 220px;
  padding: 10px 14px;
  border: none;
  border-radius: 12px;
  border-bottom-right-radius: 4px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 35, 55, 0.18);
  color: #374151;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

@keyframes askmed-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ----- Zone de chat (défilante) ----- */
#askmed-chat .askmed-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #fff;
}

#askmed-chat .askmed-message {
  display: flex;
  align-items: flex-start;
}

#askmed-chat .askmed-assistant {
  position: relative;
  width: 35px;
  height: 35px;
  flex-shrink: 0;
  line-height: 0;
}

#askmed-chat .askmed-assistant img {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

#askmed-chat .askmed-assistant .askmed-dot {
  width: 9px;
  height: 9px;
  right: -1px;
  bottom: -1px;
}

#askmed-chat .askmed-message-content { margin-left: 12px; }

#askmed-chat .askmed-sender {
  color: #9aa3ad;
  font-size: 12px;
  margin-bottom: 5px;
}

#askmed-chat .askmed-bubble {
  background: #f5f2f4;
  padding: 12px;
  border-radius: 8px;
  border-top-left-radius: 2px;
  color: #374151;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ----- Messages dynamiques (agent AI) ----- */
#askmed-chat .askmed-message + .askmed-message {
  margin-top: 16px;
}

#askmed-chat .askmed-message-user {
  justify-content: flex-end;
}

#askmed-chat .askmed-message-user .askmed-message-content {
  margin-left: 0;
  margin-right: 0;
  max-width: 85%;
}

#askmed-chat .askmed-message-user .askmed-bubble {
  background: linear-gradient(135deg, #e62b5d 0%, var(--askmed-primary-dark) 100%);
  color: #fff;
  border-radius: 8px;
  border-top-right-radius: 2px;
}

#askmed-chat .askmed-message-error .askmed-bubble {
  background: #fef3f2;
  color: #b42318;
  border: 1px solid #fecdca;
}

#askmed-chat .askmed-message-assistant .askmed-message-content {
  max-width: 85%;
}

/* ----- Indicateur "typing…" ----- */
#askmed-chat .askmed-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}

#askmed-chat .askmed-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa3ad;
  animation: askmed-typing 1.2s infinite ease-in-out;
}

#askmed-chat .askmed-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
#askmed-chat .askmed-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes askmed-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Barre de saisie compacte pendant le typing */
#askmed-chat .askmed-typing .askmed-message-content {
  max-width: none;
  width: auto;
}

#askmed-chat .askmed-typing .askmed-bubble {
  padding: 3px 6px;
  display: inline-block;
  line-height: 0;
}

#askmed-chat .askmed-typing .askmed-bubble .askmed-typing-dots {
  padding: 0;
}

/* ----- Bouton désactivé ----- */
#askmed-chat .askmed-footer button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ----- Zone de saisie ----- */
#askmed-chat .askmed-footer {
  flex-shrink: 0;
  background: #eef0f3;
  padding: 20px;
}

#askmed-chat .askmed-footer input {
  width: 100%;
  padding: 12px;
  border: 1px solid #e1e5ea;
  border-radius: 5px;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: #374151;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#askmed-chat .askmed-footer input::placeholder { color: #9aa3ad; }

#askmed-chat .askmed-footer input:focus {
  border-color: var(--askmed-primary);
  box-shadow: 0 0 0 3px rgba(225, 36, 84, 0.14);
}

#askmed-chat .askmed-footer button {
  width: 100%;
  margin-top: 15px;
  padding: 13px;
  background: linear-gradient(135deg, #e62b5d 0%, var(--askmed-primary-dark) 100%);
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(225, 36, 84, 0.28);
  transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

#askmed-chat .askmed-footer button:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 16px rgba(225, 36, 84, 0.34);
  transform: translateY(-1px);
}

#askmed-chat .askmed-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
  color: #3d4750;
  font-size: 12px;
}

#askmed-chat .askmed-status .askmed-dot {
  position: static;
  width: 8px;
  height: 8px;
  border: none;
  flex-shrink: 0;
}

/* ----- Tablette ----- */
@media (min-width: 481px) and (max-width: 768px) {
  #askmed-chat {
    width: 460px;
    height: 540px;
  }
}

/* ----- Mobile : en haut de page, sous le header ----- */
@media (max-width: 480px) {
  /* La bannière d'accueil laisse sa place au chat */
  body.home .medi-app-banner-section {
    display: none !important;
  }

  #askmed-chat {
    position: static;
    inset: auto;
    width: calc(100% - 32px);
    max-width: none;
    margin: 0 auto;
    height: 500px;
    max-height: none;
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(15, 35, 55, 0.18);
  }

  #askmed-chat .askmed-header { padding: 18px 16px; }
  #askmed-chat .askmed-body { padding: 16px; overflow-y: auto; }
  #askmed-chat .askmed-footer { padding: 16px; }
}

/* ============================================================
   Plein écran mobile : déclenché au focus de la saisie
   ============================================================ */
#askmed-chat .askmed-fs-header {
  display: none;
}

#askmed-chat .askmed-send-round {
  display: none;
}

@media (max-width: 480px) {
  body.askmed-chat-fullscreen-open {
    overflow: hidden;
    height: 100%;
  }

  #askmed-chat.askmed-fullscreen {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    z-index: 2147483640;
  }

  #askmed-chat.askmed-fullscreen .askmed-header {
    display: none;
  }

  #askmed-chat.askmed-fullscreen .askmed-fs-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #e62b5d 0%, var(--askmed-primary-dark, #c71f4b) 100%);
  }

  #askmed-chat.askmed-fullscreen .askmed-fs-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
  }

  #askmed-chat.askmed-fullscreen .askmed-fs-back:active {
    background: rgba(255, 255, 255, 0.32);
  }

  #askmed-chat.askmed-fullscreen .askmed-fs-avatars {
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }

  #askmed-chat.askmed-fullscreen .askmed-fs-avatars img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #fff;
    object-fit: cover;
    display: block;
  }

  #askmed-chat.askmed-fullscreen .askmed-fs-avatars img + img {
    margin-left: -10px;
  }

  #askmed-chat.askmed-fullscreen .askmed-fs-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.3;
  }

  #askmed-chat.askmed-fullscreen .askmed-fs-badge svg {
    flex-shrink: 0;
  }

  #askmed-chat.askmed-fullscreen .askmed-body {
    background: #F9FAFB;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
  }

  #askmed-chat.askmed-fullscreen .askmed-footer {
    background: #fff;
    border-top: 1px solid #eef0f3;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
  }

  #askmed-chat.askmed-fullscreen .askmed-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  #askmed-chat.askmed-fullscreen .askmed-footer input {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 13px 15px;
    border: 1.5px solid #e12454;
    border-radius: 26px;
    font-size: 15px;
  }

  #askmed-chat.askmed-fullscreen .askmed-footer input:focus {
    border-color: #e12454;
    box-shadow: 0 0 0 3px rgba(225, 36, 84, 0.18);
  }

  #askmed-chat.askmed-fullscreen .askmed-send-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #e62b5d 0%, var(--askmed-primary-dark, #c71f4b) 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(225, 36, 84, 0.32);
    transition: filter 0.15s ease, transform 0.12s ease;
  }

  #askmed-chat.askmed-fullscreen .askmed-send-round:active {
    transform: scale(0.94);
  }

  #askmed-chat.askmed-fullscreen .askmed-send-block {
    display: none;
  }

  #askmed-chat.askmed-fullscreen .askmed-status {
    display: none;
  }

  #askmed-chat.askmed-fullscreen ~ #askmed-fab-wrap,
  body.askmed-chat-fullscreen-open #askmed-fab-wrap {
    display: none !important;
  }

  /* Conversation terminée : on masque la saisie + CTA, la discussion reste scrollable */
  #askmed-chat.askmed-chat-ended .askmed-footer {
    display: none !important;
  }
}

/* ----- Plein écran paiement (mobile) : overlay fixe visible immédiatement ----- */
@media (max-width: 600px) {
  body.askmed-payment-open {
    overflow: hidden;
    height: 100%;
  }

  #askmed-payment-slot {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2147483640;
    background: #fff;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  #askmed-payment-slot.askmed-slot-open {
    display: flex;
    flex-direction: column;
  }

  /* Header sticky du overlay paiement */
  .amac-pay-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px calc(14px + env(safe-area-inset-top, 0px));
    background: linear-gradient(135deg, #e62b5d 0%, #c71f4b 100%);
    color: #fff;
    flex-shrink: 0;
  }

  .amac-pay-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
  }

  .amac-pay-back:active {
    background: rgba(255, 255, 255, 0.32);
  }

  .amac-pay-title {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Le corps du paiement */
  .amac-pay-body {
    flex: 1;
    padding: 16px;
  }

  /* Le modal Stripe est plaqué dans l'overlay */
  #askmed-payment-slot #amp-payment-window {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100%;
    max-height: none;
    overflow: visible;
    background: transparent;
    z-index: auto;
  }

  #askmed-payment-slot #amp-payment-window.amp-open {
    display: block;
  }

  #askmed-payment-slot #amp-payment-window .amp-half-window {
    padding: 0;
    width: 100%;
  }

  #askmed-payment-slot #amp-payment-window .amp-card {
    max-width: none;
    margin: 0;
    box-shadow: 0 8px 24px rgba(199, 31, 75, 0.28);
    border-radius: 16px;
  }
}
