/* ════════════════════════════════════════════════════
   Hortense — widget chat public
   Thème Titane Spectral — clair / verre / violet discret
   ════════════════════════════════════════════════════ */

/* ── Conteneur widget ─────────────────────────────── */
.hortense-widget {
    overflow: hidden;
    background: #f4f5f8;
    border: 1px solid rgba(0,0,0,.07);
    border-radius: 10px;
}

/* ── Statut ───────────────────────────────────────── */
.hortense-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    color: #9098a9;
    font-size: 12px;
    font-weight: 600;
}
.hortense-status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #c4cad6;
}

/* Online : vert foncé lisible sur fond clair */
.hortense-status.is-online .hortense-status-dot {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,.2);
}
.hortense-status.is-partial .hortense-status-dot {
    background: #d97706;
}
.hortense-status.is-online  { color: #16803a; }
.hortense-status.is-partial { color: #92400e; }
.hortense-status.is-offline { color: #9098a9; }

/* ── Messages ─────────────────────────────────────── */
.hortense-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 210px;
    min-height: 76px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 20px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(139,92,246,.22) transparent;
    /* Halo spectral très subtil — profondeur sans surcharger */
    background: radial-gradient(ellipse 70% 55% at 92% 8%, rgba(139,92,246,.05) 0%, transparent 100%);
}
.hortense-messages::-webkit-scrollbar { width: 4px; }
.hortense-messages::-webkit-scrollbar-track { background: transparent; }
.hortense-messages::-webkit-scrollbar-thumb {
    background: rgba(139,92,246,.22);
    border-radius: 4px;
}
.hortense-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(139,92,246,.38);
}

/* ── Bulles ───────────────────────────────────────── */
.hortense-message {
    max-width: 82%;
    padding: 9px 13px;
    border: 1px solid rgba(0,0,0,.07);
    border-radius: 8px;
    color: #1a1a2e;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.hortense-message p {
    margin: 3px 0 0;
    white-space: pre-wrap;
}
.hortense-message-author {
    display: block;
    color: #6d28d9;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 1px;
}

/* Bulle Hortense : blanc verre + accent gauche violet spectral */
.hortense-message-hortense {
    align-self: flex-start;
    background: rgba(255,255,255,.92);
    border-color: rgba(139,92,246,.1);
    border-left-color: rgba(109,40,217,.28);
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

/* Bulle utilisateur : relation Coyote — orange très pâle */
.hortense-message-user {
    align-self: flex-end;
    background: #fff7ed;
    border-color: rgba(249,115,22,.22);
    color: #374151;
}
.hortense-message-user .hortense-message-author { color: #c2400c; }
.hortense-message-thinking { color: #9098a9; }
.hortense-thinking-dots::after {
    content: '…';
    display: inline-block;
    width: 1.2em;
    overflow: hidden;
    vertical-align: bottom;
    animation: hortense-thinking 1.1s steps(4, end) infinite;
}

/* ── État vocal ───────────────────────────────────── */
.hortense-voice-state {
    flex-shrink: 0;
    padding: 7px 20px;
    background: rgba(109,40,217,.055);
    border-top: 1px solid rgba(109,40,217,.1);
    color: #5b21b6;
    font-size: 12px;
    font-weight: 650;
    line-height: 1.4;
}
.hortense-voice-state[hidden] { display: none; }
.hortense-voice-state[data-state="recording"] {
    background: rgba(220,38,38,.06);
    border-top-color: rgba(220,38,38,.13);
    color: #b91c1c;
}
.hortense-voice-state[data-state="error"],
.hortense-voice-state[data-state="unavailable"] {
    background: rgba(217,119,6,.06);
    border-top-color: rgba(217,119,6,.13);
    color: #92400e;
}

/* ── Compose ──────────────────────────────────────── */
.hortense-compose {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 11px 20px 14px;
    background: rgba(255,255,255,.75);
    border-top: 1px solid rgba(0,0,0,.07);
}
.hortense-input {
    align-self: end;
    width: 100%;
    min-width: 0;
    min-height: 38px;
    max-height: 84px;
    resize: none;
    overflow-y: hidden;
    padding: 8px 12px;
    background: #ffffff;
    border: 1px solid #d5d8df;
    border-radius: 6px;
    color: #17181c;
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
    transition: border-color .15s, box-shadow .15s;
}
.hortense-input::placeholder { color: #9098a9; }
.hortense-input:hover:not(:disabled) { border-color: #b4b9c6; }

/* Bouton push-to-talk — spectral discret, rouge seulement pendant l'écoute */
.hortense-mic {
    align-self: center;
    justify-self: center;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
    touch-action: none;
    background: #f5f3ff;
    border: 1px solid rgba(109,40,217,.25);
    border-radius: 7px;
    color: #6d28d9;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.hortense-mic svg {
    display: block;
    flex: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    max-width: 20px;
    max-height: 20px;
    fill: currentColor;
}
.hortense-mic:hover:not(:disabled) {
    background: #ede9fe;
    border-color: rgba(109,40,217,.45);
    box-shadow: 0 0 0 3px rgba(139,92,246,.08);
}
.hortense-mic.is-permission {
    background: #faf8ff;
    border-style: dashed;
    color: #7c3aed;
}
.hortense-mic.is-processing {
    background: #ede9fe;
    color: #6d28d9;
}
.hortense-mic.is-recording {
    background: #dc2626;
    border-color: #b91c1c;
    color: #ffffff;
    box-shadow: 0 0 0 5px rgba(220,38,38,.14);
    animation: hortense-recording-pulse 1.5s ease-in-out infinite;
}

/* Bouton Envoyer — orange Coyote solide : pont visuel Coyote ↔ Hortense */
.hortense-send {
    align-self: stretch;
    min-width: 88px;
    padding: 0 18px;
    background: #f97316;
    border: 1px solid #ea6c00;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    transition: background .12s;
}
.hortense-send:hover:not(:disabled) {
    background: #ea6c00;
}

/* ── Focus ────────────────────────────────────────── */
/* Input : focus spectral violet (identité IA) */
.hortense-input:focus-visible {
    outline: none;
    border-color: rgba(109,40,217,.5);
    box-shadow: 0 0 0 3px rgba(139,92,246,.12);
}
/* Bouton : focus Coyote orange */
.hortense-send:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(249,115,22,.15);
}
.hortense-mic:focus-visible {
    outline: 2px solid #6d28d9;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(139,92,246,.14);
}
.hortense-input:disabled,
.hortense-send:disabled,
.hortense-mic:disabled {
    cursor: not-allowed;
    opacity: .42;
}

/* ── Toggle voix auto ─────────────────────────────── */
.hortense-voice-toggle {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #6d28d9;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s, color .12s, border-color .12s;
}
.hortense-voice-toggle svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: currentColor;
}
.hortense-voice-toggle[aria-pressed="false"] {
    color: #c4cad6;
}
.hortense-voice-toggle:hover {
    background: rgba(109,40,217,.06);
    border-color: rgba(109,40,217,.12);
    color: #6d28d9;
}
.hortense-voice-toggle:focus-visible {
    outline: 2px solid #6d28d9;
    outline-offset: 2px;
}

/* ── Bouton replay dans la bulle Hortense ─────────── */
.hortense-replay-btn {
    display: block;
    margin-top: 6px;
    padding: 0;
    background: none;
    border: none;
    color: #6d28d9;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    opacity: .65;
    transition: opacity .12s;
    text-align: left;
}
.hortense-replay-btn:hover {
    opacity: 1;
}
.hortense-replay-btn:focus-visible {
    outline: 2px solid #6d28d9;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Accessibilité ────────────────────────────────── */
.hortense-sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes hortense-thinking {
    0%   { width: 0; }
    100% { width: 1.2em; }
}

@keyframes hortense-recording-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(220,38,38,.11); }
    50%      { box-shadow: 0 0 0 7px rgba(220,38,38,.18); }
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 600px) {
    .hortense-messages { max-height: 176px; }
    .hortense-message  { max-width: 92%; }
    .hortense-voice-state { padding-right: 12px; padding-left: 12px; }
    .hortense-compose  {
        grid-template-columns: 44px minmax(0, 1fr) auto;
        gap: 6px;
        padding: 10px 12px 12px;
    }
    .hortense-send {
        min-width: 72px;
        min-height: 44px;
        padding: 0 12px;
    }
}

/* Desktop : plafond viewport-relatif — brise la chaîne max-content du grid */
/* Spécificité (0,2,0) identique à .hs-card .hortense-messages dans homepage.css ;
   hortense-widget.css chargé après → ce fichier gagne sur max-height: none. */
@media (min-width: 861px) {
    .hortense-widget .hortense-messages {
        max-height: max(200px, calc(100dvh - 260px));
        overscroll-behavior: contain;
    }
    .hortense-widget .hortense-voice-state {
        flex-shrink: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hortense-messages { scroll-behavior: auto; }
    .hortense-thinking-dots::after { animation: none; width: auto; }
    .hortense-mic.is-recording { animation: none; }
}
