#oc-advice [hidden] { display: none; }

body:has(.oc-advice-bar) {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
}

/* Bandeau fixe en bas de page */
.oc-advice-bar {
    position: fixed;
    inset: auto 0 0;
    z-index: 70;
    background: #17212b;
    color: #fff;
    box-shadow: 0 -4px 20px #17212b24;
    padding-bottom: env(safe-area-inset-bottom);
}

.oc-advice-bar-inner, #oc-advice .oc-advice-inner {
    box-sizing: border-box;
    width: min(100%, 50rem);
    margin-inline: auto;
    padding-inline: clamp(1rem, 3vw, 2rem);
}

.oc-advice-bar-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(.4rem, 2vw, 1.25rem);
    min-height: 4.5rem;
    padding-block: .55rem;
}

.oc-advice-bar p {
    margin: 0;
    font-size: clamp(.86rem, 1.6vw, 1.03rem);
    font-weight: 720;
    line-height: 1.25;
}

.oc-advice-button, .oc-advice-icon, .oc-advice-suggestions button {
    border: 0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.oc-advice-button {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    flex-shrink: 0;
    min-height: 2.75rem;
    padding: .5rem .85rem;
    border-radius: .5rem;
    background: #35dcf7;
    color: #14232b;
    font-size: .88rem;
    white-space: nowrap;
}

.oc-advice-button:hover { background: #8beafb; }
.oc-advice-button:disabled { opacity: .6; cursor: wait; }
.oc-advice-bar :focus-visible, #oc-advice :focus-visible { outline: 2px solid #0091ad; outline-offset: 3px; }

.oc-advice-icon {
    flex-shrink: 0;
    padding: 0;
    width: 2.75rem;
    height: 2.75rem;
    background: transparent;
    border-radius: .5rem;
    color: inherit;
    font-size: 1.55rem;
    line-height: 1;
}

/* Panneau */
#oc-advice {
    position: fixed;
    inset: auto 0 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    height: min(80dvh, 60rem);
    max-height: none;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: #17212b;
    box-shadow: 0 -12px 60px #101f3240;
}

#oc-advice[open] { display: flex; flex-direction: column; }
#oc-advice::backdrop { background: #15243158; }

/* En-tête : grand au départ, compact dès que la conversation commence */
.oc-advice-header {
    flex-shrink: 0;
    border-bottom: 3px solid #35dcf7;
    background: #17212b; /* couleur unie, la même que le bandeau du bas */
    color: #fff;
}

#oc-advice .oc-advice-header .oc-advice-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(.75rem, 3vw, 2rem);
    padding-block: clamp(1.1rem, 3.5vw, 2rem);
}

.oc-advice-heading { flex: 1; min-width: 0; }
#oc-advice-title {
    margin: 0;
    color: #fff;
    font-size: clamp(1.9rem, 5.5vw, 3.25rem);
    font-weight: 800;
    letter-spacing: -.035em;
    line-height: 1.05;
}
.oc-advice-lede { margin: .6rem 0 0; color: #d5e6eb; font-size: clamp(.86rem, 1.8vw, 1rem); line-height: 1.4; }

.oc-advice-portrait {
    flex-shrink: 0;
    width: clamp(4.25rem, 13vw, 7.5rem);
    height: auto;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #fff;
    object-fit: cover;
}

/* Croix dans le coin haut droit de la fenêtre, même quand le contenu est centré */
.oc-advice-close {
    position: absolute;
    top: .75rem;
    right: .75rem;
    background: #ffffff19;
    color: #fff;
}
.oc-advice-close:hover { background: #ffffff30; }

/* Fenêtre étroite : le texte ne passe pas sous la croix */
@media (max-width: 60rem) {
    #oc-advice .oc-advice-header .oc-advice-inner { padding-inline-end: 4rem; }
}

/* Fil de la conversation : chaque message occupe toute la largeur */
.oc-advice-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
}

/* Avant la première question : tout en haut de la fenêtre, juste sous l'en-tête — message d'Eric,
   choix du vélo, champ de saisie — et la place restante est vide en dessous.
   Dès qu'une question part, le champ descend en bas et la conversation occupe la place. */
#oc-advice:not([data-started]) .oc-advice-body { flex: 0 1 auto; }
#oc-advice:not([data-started]) .oc-advice-form { margin-bottom: auto; }
#oc-advice:not([data-started]) .oc-advice-form .oc-advice-inner { padding-top: .4rem; }

.oc-advice-messages { display: flex; flex-direction: column; }

/* Eric : photo et nom, texte sur toute la largeur. Visiteur : pastille à droite, comme dans une messagerie. */
.oc-advice-message .oc-advice-inner {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr);
    gap: .85rem;
    padding-block: clamp(.9rem, 2.2vw, 1.3rem);
}

.oc-advice-message[data-role="user"] .oc-advice-inner {
    display: flex;
    justify-content: flex-end;
    padding-block: .4rem;
}

/* Pastille du visiteur + accusé dessous (« Envoyé », puis « Lu par Eric »), alignés à droite */
.oc-advice-sent {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: min(34rem, 85%);
}

.oc-advice-message[data-role="user"] .oc-advice-text {
    max-width: 100%;
    padding: .7rem 1.15rem;
    border-radius: 1.3rem;
    background: #dcf5fa;
    color: #0f2a33;
}

.oc-advice-receipt {
    margin: .3rem .6rem 0 0;
    color: #6a7178;
    font-size: .82rem;
    line-height: 1.2;
}

.oc-advice-avatar {
    display: grid;
    place-items: center;
    align-self: end; /* photo en bas à gauche du message, le nom reste en haut du texte */
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    background: #d7e6ec;
    color: #31505d;
}

.oc-advice-content { min-width: 0; padding-top: .1rem; }

.oc-advice-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
    margin: 0 0 .25rem;
    font-size: 1rem;
    line-height: 1.2;
}
.oc-advice-name strong { color: #17212b; font-weight: 650; }

.oc-advice-text {
    margin: 0;
    color: #1f2d38;
    font-size: 1.12rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Vélo proposé par Eric : le nom du vélo en lien bleu souligné, même taille et même graisse que le texte, seul sur sa ligne */
.oc-advice-link {
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: .3rem 0 .45rem;
    color: #1558d6;
    font: inherit;
    text-decoration: underline;
    text-decoration-color: #1558d6;
    text-decoration-thickness: .08em;
    text-underline-offset: .2em;
    white-space: normal;
}
.oc-advice-link:hover { color: #0e3fa3; text-decoration-color: #0e3fa3; }

/* Eric « écrit » : trois points avant sa réponse */
.oc-advice-typing { display: flex; align-items: center; gap: .35rem; height: 1.75rem; margin: 0; }
.oc-advice-typing span {
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: #8fa3ad;
    animation: oc-advice-dot 1.1s infinite ease-in-out;
}
.oc-advice-typing span:nth-child(2) { animation-delay: .15s; }
.oc-advice-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes oc-advice-dot {
    0%, 60%, 100% { opacity: .35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-.25rem); }
}
@media (prefers-reduced-motion: reduce) {
    .oc-advice-typing span { animation: none; opacity: .7; }
}

/* Réponses rapides sous la question d'Eric */
.oc-advice-suggestions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .7rem;
    max-width: 38rem;
    margin-top: 1rem;
}

.oc-advice-suggestions button {
    display: grid;
    align-content: start;
    gap: .2rem;
    min-height: 4rem;
    padding: .85rem 1rem;
    border: 1px solid #d6e0e6;
    border-radius: .65rem;
    background: #f3f6f8;
    color: #17212b;
    text-align: left;
    line-height: 1.3;
}
.oc-advice-suggestions strong { font-size: 1.05rem; font-weight: 650; }
.oc-advice-suggestions span { color: #41525e; font-size: .92rem; font-weight: 500; }
.oc-advice-suggestions button:hover { border-color: #0091ad; background: #e5faff; }

.oc-advice-after { padding-block: .2rem 1rem; }
.oc-advice-status { margin: .7rem 0 0; color: #4b5c69; font-size: .85rem; }
.oc-advice-status:empty { margin: 0; }

/* Champ de saisie */
.oc-advice-form {
    flex-shrink: 0;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
}

/* Le champ ne colle pas au bord bas de l'écran : un peu d'air dessous */
.oc-advice-form .oc-advice-inner { padding-block: .7rem clamp(1.4rem, 4vh, 2.25rem); }

/* Cadre gris clair arrondi : ligne d'info centrée, puis le champ cerné d'un trait sombre */
.oc-advice-panel {
    padding: .7rem .75rem .75rem;
    border-radius: 1.6rem;
    background: #f4f5f6;
}
.oc-advice-delay {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    margin: 0 0 .65rem;
    color: #6a7178;
    font-size: .95rem;
    line-height: 1.2;
}
.oc-advice-composer {
    display: flex;
    align-items: flex-end;
    gap: .4rem;
    padding: .25rem;
    border: 2px solid #5f6870;
    border-radius: 1.75rem;
    background: #fff;
}
.oc-advice-composer:focus-within { border-color: #0086a4; box-shadow: 0 0 0 3px #35dcf733; }
.oc-advice-form textarea {
    flex: 1;
    width: 0;
    min-height: 2.75rem;
    max-height: 8rem;
    box-sizing: border-box;
    resize: none;
    padding: .65rem .85rem;
    border: 0;
    border-radius: inherit;
    background: transparent;
    font: inherit;
    font-size: 1rem;
    line-height: 1.45;
    color: #17212b;
}
.oc-advice-form textarea:focus, .oc-advice-form textarea:focus-visible { outline: none !important; box-shadow: none !important; }
.oc-advice-send { width: 2.75rem; min-height: 2.75rem; justify-content: center; padding: 0; border-radius: 50%; }

.oc-advice-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

@media (max-width: 520px) {
    .oc-advice-bar-inner { padding-inline: .75rem .4rem; }
    .oc-advice-bar .oc-advice-button { padding-inline: .62rem; }
    .oc-advice-bar .oc-advice-button span { display: none; }
    #oc-advice-title { font-size: 1.6rem; white-space: nowrap; }
    .oc-advice-message .oc-advice-inner { grid-template-columns: 2.25rem minmax(0, 1fr); gap: .7rem; }
    .oc-advice-avatar { width: 2.25rem; height: 2.25rem; }
    .oc-advice-name { font-size: .95rem; }
    .oc-advice-text { font-size: 1.05rem; }
    .oc-advice-suggestions { gap: .5rem; }
    .oc-advice-suggestions button { padding: .75rem .8rem; }
}
