/* =========================================
 * Spritz Chatbot — Styles
 * ========================================= */

:root {
    --sc-color:        #e8601e;
    --sc-color-dark:   #c44f16;
    --sc-bg:           #ffffff;
    --sc-bg-user:      var(--sc-color);
    --sc-bg-bot:       #f0f2f5;
    --sc-text:         #1a1a2e;
    --sc-text-light:   #6b7280;
    --sc-header-bg:    #1a2744;
    --sc-radius:       16px;
    --sc-shadow:       0 8px 32px rgba(0,0,0,.18);
    --sc-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --sc-z:            9999;
}

/* === Conteneur principal === */
.spritz-chatbot {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--sc-z);
    font-family: var(--sc-font);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.spritz-chatbot.bottom-left {
    right: auto;
    left: 24px;
    align-items: flex-start;
}

/* --- Position bottom-center --- */
.spritz-chatbot.bottom-center {
    right: auto;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    width: min(640px, calc(100vw - 32px));
    align-items: stretch;
    gap: 12px;
    flex-direction: column-reverse; /* pill en bas, fenêtre au-dessus */
}

/* === FAB === */
.spritz-chatbot__fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--sc-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    transition: background .2s, transform .2s;
    flex-shrink: 0;
}

.spritz-chatbot__fab:hover {
    background: var(--sc-color-dark);
    transform: scale(1.08);
}

.spritz-chatbot__fab:focus-visible {
    outline: 3px solid var(--sc-color);
    outline-offset: 3px;
}

.spritz-chatbot__fab-icon {
    width: 24px;
    height: 24px;
    transition: opacity .2s, transform .2s;
    position: absolute;
}

.spritz-chatbot__fab-icon--close {
    opacity: 0;
    transform: rotate(-90deg);
}

.spritz-chatbot__fab-icon--chat {
    opacity: 1;
    transform: rotate(0deg);
}

.spritz-chatbot.is-open .spritz-chatbot__fab-icon--close {
    opacity: 1;
    transform: rotate(0deg);
}

.spritz-chatbot.is-open .spritz-chatbot__fab-icon--chat {
    opacity: 0;
    transform: rotate(90deg);
}

/* === Pill bar (bottom-center) === */
.spritz-chatbot__pill {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: #fff;
    border: 2px solid var(--sc-color);
    border-radius: 50px;
    padding: 10px 10px 10px 24px;
    box-shadow: var(--sc-shadow);
    cursor: pointer;
    text-align: left;
    transition: box-shadow .2s;
}

.spritz-chatbot__pill:hover {
    box-shadow: 0 12px 36px rgba(0,0,0,.22);
}

.spritz-chatbot__pill:focus-visible {
    outline: 3px solid var(--sc-color);
    outline-offset: 2px;
}

.spritz-chatbot__pill-text {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--sc-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spritz-chatbot__pill-avatar {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--sc-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.spritz-chatbot__pill-avatar svg {
    width: 26px;
    height: 26px;
    fill: #fff;
}

.spritz-chatbot__pill-avatar .spritz-chatbot__avatar-img,
.sc-pill-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.sc-pill-default-icon {
    width: 26px;
    height: 26px;
    fill: #fff;
}

/* Fenêtre bottom-center : plus large, centrée, s'ouvre vers le haut */
.spritz-chatbot.bottom-center .spritz-chatbot__window {
    width: 100%;
    max-width: 640px;
    max-height: 75vh;
    border-radius: var(--sc-radius);
    transform-origin: bottom center;
    margin-bottom: 12px;
}

/* === Fenêtre === */
.spritz-chatbot__window {
    width: 380px;
    max-width: calc(100vw - 48px);
    max-height: 560px;
    display: none; /* retiré du flux — géré par JS via .is-visible */
    flex-direction: column;
    border-radius: var(--sc-radius);
    overflow: hidden;
    box-shadow: var(--sc-shadow);
    background: var(--sc-bg);
    transform-origin: bottom right;
    transform: scale(0.92) translateY(8px);
    opacity: 0;
    transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .25s;
}

/* Étape 1 : inséré dans le flux, encore invisible */
.spritz-chatbot__window.is-visible {
    display: flex;
}

.spritz-chatbot.bottom-left .spritz-chatbot__window {
    transform-origin: bottom left;
}

/* Étape 2 : animé vers l'état ouvert */
.spritz-chatbot.is-open .spritz-chatbot__window {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* === Header === */
.spritz-chatbot__header {
    background: var(--sc-header-bg);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.spritz-chatbot__header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sc-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.spritz-chatbot__header-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

.spritz-chatbot__header-avatar .spritz-chatbot__avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.spritz-chatbot__header-name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

.spritz-chatbot__header-status {
    font-size: 12px;
    color: rgba(255,255,255,.65);
    display: flex;
    align-items: center;
    gap: 5px;
}

.spritz-chatbot__status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.spritz-chatbot__header-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s;
}

.spritz-chatbot__header-close:hover {
    color: #fff;
}

.spritz-chatbot__header-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* === Zone messages === */
.spritz-chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* === Bulles === */
.spritz-chatbot__message {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 88%;
}

.spritz-chatbot__message--bot {
    align-self: flex-start;
}

.spritz-chatbot__message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.spritz-chatbot__bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.spritz-chatbot__message--bot .spritz-chatbot__bubble {
    background: var(--sc-bg-bot);
    color: var(--sc-text);
    border-bottom-left-radius: 4px;
}

.spritz-chatbot__message--user .spritz-chatbot__bubble {
    background: var(--sc-bg-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Liens dans les bulles bot */
.spritz-chatbot__message--bot .spritz-chatbot__bubble a {
    display: inline-block;
    margin-top: 6px;
    padding: 5px 12px;
    background: var(--sc-color);
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .2s;
}

.spritz-chatbot__message--bot .spritz-chatbot__bubble a:hover {
    opacity: .85;
    color: #fff;
}

/* === Typing indicator === */
.spritz-chatbot__typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 10px 14px;
    background: var(--sc-bg-bot);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.spritz-chatbot__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sc-text-light);
    animation: sc-bounce 1.2s infinite;
}

.spritz-chatbot__typing span:nth-child(2) { animation-delay: .2s; }
.spritz-chatbot__typing span:nth-child(3) { animation-delay: .4s; }

@keyframes sc-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* === CTA bloc === */
.spritz-chatbot__cta {
    background: #f8f9fb;
    border-radius: 12px;
    padding: 14px;
    font-size: 13px;
    color: var(--sc-text);
    border: 1px solid #e5e7eb;
}

.spritz-chatbot__cta p {
    margin: 0 0 10px;
    line-height: 1.5;
}

.spritz-chatbot__cta-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.spritz-chatbot__cta-btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .2s;
    color: #fff !important;
}

.spritz-chatbot__cta-btn:hover { opacity: .85; color: #fff !important; }

.spritz-chatbot__cta-btn--blog {
    background: var(--sc-header-bg);
    color: #fff !important;
}

.spritz-chatbot__cta-btn--rdv {
    background: var(--sc-color);
    color: #fff;
}

/* === Zone saisie === */
.spritz-chatbot__input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: var(--sc-bg);
    flex-shrink: 0;
}

.spritz-chatbot__input {
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 9px 12px;
    font-family: var(--sc-font);
    font-size: 14px;
    line-height: 1.4;
    color: var(--sc-text);
    max-height: 120px;
    transition: border-color .2s;
    outline: none;
    margin-bottom: 0;
    box-shadow: none;
}

.spritz-chatbot__input:focus, .spritz-chatbot__input:active, .spritz-chatbot__input:focus-visible {
    border-color: var(--sc-color);
    box-shadow: none !important;
    outline: none;
}

.spritz-chatbot__input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

.spritz-chatbot__send {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--sc-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

.spritz-chatbot__send:hover:not(:disabled) {
    background: var(--sc-color-dark);
}

.spritz-chatbot__send:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.spritz-chatbot__send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* === Footer === */
.spritz-chatbot__footer {
    text-align: center;
    font-size: 11px;
    color: var(--sc-text-light);
    padding: 6px;
    background: var(--sc-bg);
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

/* === Responsive === */
@media (max-width: 480px) {
    .spritz-chatbot {
        bottom: 16px;
        right: 16px;
    }

    .spritz-chatbot.bottom-left {
        left: 16px;
    }

    .spritz-chatbot__window {
        width: calc(100vw - 32px);
        max-height: 70vh;
    }
}
