/* ── Bouton flottant ─────────────────────────────────────────────────── */

.fixed-action-btn {
    position: fixed;
}

#chat-toggle {
    position: relative;
    background: linear-gradient(135deg, #3d7e9d, #2b5c73) !important;
    box-shadow: 0 8px 24px -6px rgba(43, 92, 115, .55);
    transition: transform .18s ease, box-shadow .18s ease;
}

#chat-toggle:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 12px 28px -6px rgba(43, 92, 115, .6);
}

#chat-toggle > i {
    transition: transform .25s ease;
}

#chat-toggle.is-open > i {
    transform: rotate(180deg);
}

.chat-fab-pulse {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(61, 126, 157, .55);
    animation: chatPulse 2.2s ease-out infinite;
    pointer-events: none;
    z-index: 996;
}

@keyframes chatPulse {
    0% {
        transform: scale(1);
        opacity: .55;
    }

    100% {
        transform: scale(1.9);
        opacity: 0;
    }
}

/* ── Panneau de chat ─────────────────────────────────────────────────── */

#chat-container {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 60vw;
    min-width: 350px;
    max-width: 70vw;
    height: 80dvh;
    z-index: 100;
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 60px -16px rgba(16, 32, 48, .35), 0 4px 16px rgba(16, 32, 48, .1);
    transform-origin: bottom right;
}

#chat-container.is-open {
    display: flex;
    animation: chatPanelIn .22s cubic-bezier(.2, .8, .3, 1.1);
}

@keyframes chatPanelIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(.94);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media only screen and (max-width : 600px) {
    #chat-container {
        width: 92vw;
        max-width: 92vw;
        right: 4vw;
        bottom: 88px;
        height: 78dvh;
    }
}

/* ── En-tête ─────────────────────────────────────────────────────────── */

#chat-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    color: #fff;
}

#chat-header-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-header-avatar i {
    font-size: 20px;
}

#chat-header-text {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#chat-header-title {
    font-size: 1rem;
    font-weight: 700;
}

#chat-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: rgba(255, 255, 255, .8);
}

.chat-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6fe08a;
    box-shadow: 0 0 0 2px rgba(111, 224, 138, .35);
}

#chat-close,
#chat-header-examples {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    transition: background .12s, opacity .12s;
}

#chat-close:hover,
#chat-header-examples:hover {
    background: rgba(255, 255, 255, .16);
}

#chat-close i,
#chat-header-examples i {
    font-size: 19px;
}

/* ── Signalement d'une réponse ───────────────────────────────────────── */

#chat-feedback-panel {
    flex-shrink: 0;
    padding: 12px 14px;
    background: #fff8ec;
    border-top: 1px solid #f0e0bd;
    animation: chatMsgIn .15s ease;
}

#chat-feedback-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    font-weight: 700;
    color: #8a6116;
    margin-bottom: 8px;
}

#chat-feedback-title i {
    font-size: 17px;
}

#chat-feedback-comment {
    width: 100%;
    box-sizing: border-box;
    resize: none;
    border: 1px solid #e9d6a8;
    border-radius: 10px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: .82rem;
    background: #fff;
    box-shadow: none !important;
    margin: 0 0 8px !important;
}

#chat-feedback-comment:focus {
    outline: none;
    border-color: #cf9d2f;
}

#chat-feedback-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#chat-feedback-actions button {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    padding: 7px 14px;
    cursor: pointer;
    border: none;
}

#chat-feedback-cancel {
    background: transparent;
    color: #8a6116;
}

#chat-feedback-cancel:hover {
    background: rgba(138, 97, 22, .1);
}

#chat-feedback-send {
    background: #cf9d2f;
    color: #fff;
}

#chat-feedback-send:hover {
    background: #b98a24;
}

#chat-feedback-send:disabled {
    opacity: .6;
    cursor: default;
}

/* ── Historique / messages ───────────────────────────────────────────── */

#chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafb;
    scrollbar-width: thin;
    scrollbar-color: #c7d3da transparent;
}

#chat-history::-webkit-scrollbar {
    width: 7px;
}

#chat-history::-webkit-scrollbar-thumb {
    background: #c7d3da;
    border-radius: 10px;
}

#chat-history::-webkit-scrollbar-thumb:hover {
    background: #9fb1bc;
}

#chat-welcome {
    text-align: center;
    padding: 18px 8px 26px;
}

#chat-welcome-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px -6px rgba(43, 92, 115, .45);
}

#chat-welcome-icon i {
    color: #fff;
    font-size: 24px;
}

#chat-welcome p {
    font-size: .85rem;
    color: #455a64;
    line-height: 1.5;
    margin: 0 0 16px;
}

#chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.chat-chip {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #2b5c73;
    background: #eef4f7;
    border: 1px solid #d7e0e6;
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .12s;
}

.chat-chip:hover {
    background: #3d7e9d;
    border-color: #3d7e9d;
    color: #fff;
    transform: translateY(-1px);
}

.chat-chip--highlight {
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 6px rgba(43, 92, 115, .35);
}

.chat-chip--highlight:hover {
    background: linear-gradient(135deg, #468cae, #316a85);
    border-color: transparent;
    color: #fff;
    transform: translateY(-1px);
}

.chat-chip--more {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #3d7e9d;
    background: transparent;
    border: 1px dashed #3d7e9d;
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.chat-chip--more i {
    font-size: 15px;
}

.chat-chip--more:hover {
    background: #eef4f7;
}

.chat-error-report-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #b5490f;
    background: #fdf1ea;
    border: 1px solid #f2d3bf;
    border-radius: 999px;
    padding: 7px 13px;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}

.chat-error-report-btn i {
    font-size: 15px;
}

.chat-error-report-btn:hover {
    background: #f9e2d2;
    border-color: #e9b78e;
}

/* ── Panneau "Ce que je sais faire" ──────────────────────────────────── */

#chat-examples-panel {
    position: absolute;
    inset: 0;
    z-index: 20;
    flex-direction: column;
    background: #fff;
}

#chat-examples-panel:not(.hidden) {
    display: flex;
}

#chat-examples-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    color: #fff;
}

#chat-examples-header > span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
}

#chat-examples-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background .12s;
}

#chat-examples-close:hover {
    background: rgba(255, 255, 255, .16);
}

#chat-examples-close i {
    font-size: 20px;
}

#chat-examples-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafb;
    scrollbar-width: thin;
    scrollbar-color: #c7d3da transparent;
}

#chat-examples-body::-webkit-scrollbar {
    width: 7px;
}

#chat-examples-body::-webkit-scrollbar-thumb {
    background: #c7d3da;
    border-radius: 10px;
}

.chat-example-group {
    margin-bottom: 18px;
}

.chat-example-group-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #6b7c88;
    margin-bottom: 8px;
}

.chat-example-group-title i {
    font-size: 16px;
    color: #3d7e9d;
}

.chat-example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-msg {
    margin-bottom: 14px;
    animation: chatMsgIn .2s ease;
}

@keyframes chatMsgIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.chat-msg--bot {
    position: relative;
    padding-left: 34px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.chat-msg-report-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-top: 2px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #90a0aa;
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s, background .12s, color .12s;
}

.chat-msg--bot:hover .chat-msg-report-btn {
    opacity: 1;
}

.chat-msg-report-btn:focus-visible {
    opacity: 1;
    outline: 2px solid #3d7e9d;
    outline-offset: 1px;
}

.chat-msg-report-btn:hover {
    background: #fdf1ea;
    color: #b5490f;
}

.chat-msg-report-btn i {
    font-size: 15px;
}

.chat-msg--bot::before {
    content: "assistant";
    font-family: "Material Icons";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    color: #fff;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    text-align: left;
    font-size: .88rem;
    line-height: 1.45;
    overflow: hidden;
    word-wrap: break-word;
}

.chat-msg--user .chat-bubble {
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.chat-msg--bot .chat-bubble {
    max-width: 100%;
    background: #fff;
    color: #26323b;
    border: 1px solid #e3e8ed;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 2px rgba(16, 32, 48, .04);
}

.chat-bubble--iframe {
    width: 100%;
    padding: 0;
}

.chat-bubble ul,
.chat-bubble ol {
    padding-left: 18px;
    margin: 6px 0;
}

.chat-timestamp {
    display: block;
    margin-top: 4px;
    font-size: 10px;
}

.chat-msg--user .chat-timestamp {
    color: rgba(255, 255, 255, .75);
    text-align: right;
}

.chat-msg--bot .chat-timestamp {
    color: #90a0aa;
}

/* ── Indicateur "en train d'écrire" ──────────────────────────────────── */

.chat-bubble--typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 13px 16px;
}

.chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9fb1bc;
    animation: chatTypingBounce 1.1s infinite ease-in-out;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: .15s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: .3s;
}

@keyframes chatTypingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: .5;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.chat-typing-label {
    font-size: 11px;
    color: #90a0aa;
    margin-left: 4px;
}

/* ── Zone de saisie ──────────────────────────────────────────────────── */

#chat-input-area {
    flex-shrink: 0;
    padding: 12px 14px 10px;
    background: #fff;
    border-top: 1px solid #eceff1;
}

#chat-input-field {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f4f7f9;
    border: 1px solid #e3e8ed;
    border-radius: 18px;
    padding: 6px 6px 6px 14px;
    transition: border-color .15s, box-shadow .15s;
}

#chat-input-field:focus-within {
    border-color: #3d7e9d;
    box-shadow: 0 0 0 3px rgba(61, 126, 157, .15);
    background: #fff;
}

#chat-input {
    flex: 1 1 auto;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    max-height: 120px;
    min-height: 22px;
    padding: 6px 0;
    margin: 0;
    font-size: .88rem;
    font-family: inherit;
    line-height: 1.4;
    box-shadow: none !important;
}

#chat-send {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s, transform .1s;
}

#chat-send:active {
    transform: scale(.92);
}

#chat-send:disabled {
    background: #c7d3da;
    cursor: default;
}

#chat-send i {
    font-size: 18px;
}

#chat-disclaimer {
    font-style: italic;
    color: #90a0aa;
    font-size: 10.5px;
    line-height: 1.4;
    margin-top: 8px;
    padding: 0 4px;
}

#chat-rate-limit {
    display: none;
    color: #90a0aa;
    font-size: 10.5px;
    line-height: 1.4;
    margin-top: 6px;
    padding: 0 4px;
}

#chat-rate-limit.is-visible {
    display: block;
}

#chat-rate-limit.is-low {
    color: #c9720f;
}

/* ── Mini-assistant de configuration (flow de démarrage) ─────────────── */

.chat-config-step {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-config-step-body p {
    margin: 0;
}

.chat-config-hint {
    font-size: 12px;
    line-height: 1.35;
    color: #78909c;
    margin-top: 4px !important;
}

.chat-config-step-badge {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6fa2ba;
    margin-bottom: 2px;
}

.chat-config-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-config-row input,
.chat-config-step-body input[type="time"] {
    flex: 1;
    min-width: 90px;
    font-family: inherit;
    font-size: .85rem;
    padding: 7px 10px;
    border: 1px solid #d7e0e6;
    border-radius: 8px;
    color: #26323b;
    background: #f7fafc;
}

.chat-config-row input:focus,
.chat-config-step-body input[type="time"]:focus {
    outline: none;
    border-color: #3d7e9d;
    background: #fff;
}

.chat-config-save {
    align-self: flex-start;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    border: none;
    border-radius: 999px;
    padding: 7px 16px;
    cursor: pointer;
}

.chat-config-save:hover {
    opacity: .9;
}

.chat-config-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-config-choice {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #2b5c73;
    background: #eef4f7;
    border: 1px solid #d7e0e6;
    border-radius: 999px;
    padding: 7px 14px;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}

.chat-config-choice:hover {
    border-color: #3d7e9d;
}

.chat-config-choice.active {
    color: #fff;
    background: linear-gradient(135deg, #3d7e9d, #2b5c73);
    border-color: transparent;
}

.chat-config-option-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-config-option-card {
    display: block;
    width: 100%;
    text-align: left;
    font-family: inherit;
    background: #f7fafc;
    border: 1px solid #d7e0e6;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color .12s, background .12s;
}

.chat-config-option-card:hover {
    border-color: #3d7e9d;
}

.chat-config-option-card.active {
    background: #eef4f7;
    border-color: #3d7e9d;
    border-width: 2px;
    padding: 9px 11px;
}

.chat-config-option-card-header {
    font-size: 12.5px;
    font-weight: 700;
    color: #2b5c73;
    margin-bottom: 3px;
}

.chat-config-option-card.active .chat-config-option-card-header::before {
    content: "✓ ";
}

.chat-config-option-card-desc {
    font-size: 11.5px;
    color: #4a5b66;
    line-height: 1.4;
}

.chat-config-option-card-formula {
    margin-top: 4px;
    font-size: 10.5px;
    font-style: italic;
    color: #90a0aa;
    line-height: 1.5;
}

.chat-config-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border: 2px dashed #d7e0e6;
    border-radius: 10px;
    color: #90a0aa;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: border-color .12s;
}

.chat-config-logo:hover {
    border-color: #3d7e9d;
}

.chat-config-logo.has-logo {
    border-style: solid;
    color: transparent;
}

.chat-config-step-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.chat-config-skip {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    color: #90a0aa;
    background: transparent;
    border: 1px solid #e3e8ed;
    border-radius: 999px;
    padding: 5px 12px;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.chat-config-skip:hover {
    background: #eef4f7;
    color: #2b5c73;
}

.chat-config-skip.is-done {
    color: #3d7e9d;
    border-color: transparent;
    cursor: default;
}

.chat-config-skip.is-done i {
    font-size: 15px;
}

.chat-config-list-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.chat-chip-sm {
    font-size: 11px;
    padding: 5px 10px;
}

.chat-chip-sm.active {
    background: #3d7e9d;
    border-color: #3d7e9d;
    color: #fff;
}

.chat-config-list-iframe {
    width: 100%;
    height: 500px;
    border: 1px solid #e3e8ed;
    border-radius: 8px;
    margin-top: 20px;
}
