/* ==========================================================================
   IRG Chatbot — Front-end styles
   Couleurs : #0e2d55 (primaire) / #ffffff (blanc)
   ========================================================================== */

/* ---------- Variables ---------- */
:root {
    --irg-cb-primary: #0e2d55;
    --irg-cb-primary-light: #143a6e;
    --irg-cb-white: #ffffff;
    --irg-cb-gray-light: #f4f5f7;
    --irg-cb-gray: #e2e4e8;
    --irg-cb-text: #1a1a2e;
    --irg-cb-text-light: #5a5f72;
    --irg-cb-radius: 12px;
    --irg-cb-shadow: 0 4px 24px rgba(14, 45, 85, .18);
    --irg-cb-bubble-size: 56px;
    --irg-cb-window-w: 370px;
    --irg-cb-window-h: 520px;
    --irg-cb-z: 999990;
}

/* ---------- Reset conteneur ---------- */
.irg-chatbot,
.irg-chatbot * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.45;
}

/* ==========================================================================
   Bulle flottante
   ========================================================================== */
.irg-chatbot-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--irg-cb-z);
    width: var(--irg-cb-bubble-size);
    height: var(--irg-cb-bubble-size);
    border-radius: 50%;
    border: none;
    background: var(--irg-cb-primary);
    color: var(--irg-cb-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--irg-cb-shadow);
    transition: transform .2s ease, background .2s ease;
}

.irg-chatbot-bubble:hover {
    transform: scale(1.08);
    background: var(--irg-cb-primary-light);
}

.irg-chatbot-bubble:focus-visible {
    outline: 3px solid var(--irg-cb-primary-light);
    outline-offset: 2px;
}

/* ==========================================================================
   Bulle teaser (message d'accroche)
   ========================================================================== */
.irg-chatbot-teaser {
    position: fixed;
    bottom: calc(20px + var(--irg-cb-bubble-size) + 10px);
    right: 20px;
    z-index: var(--irg-cb-z);
    background: var(--irg-cb-white);
    color: var(--irg-cb-text);
    padding: 10px 36px 10px 16px;
    border-radius: var(--irg-cb-radius);
    box-shadow: var(--irg-cb-shadow);
    font-size: 14px;
    max-width: 260px;
    cursor: pointer;
    animation: irg-cb-slide-up .4s ease;
}

.irg-chatbot-teaser__close {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--irg-cb-text-light);
    cursor: pointer;
    line-height: 1;
}

@keyframes irg-cb-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Fenêtre de conversation
   ========================================================================== */
.irg-chatbot-window {
    position: fixed;
    bottom: calc(20px + var(--irg-cb-bubble-size) + 12px);
    right: 20px;
    z-index: calc(var(--irg-cb-z) + 1);
    width: var(--irg-cb-window-w);
    height: var(--irg-cb-window-h);
    max-height: calc(100vh - 120px);
    background: var(--irg-cb-white);
    border-radius: var(--irg-cb-radius);
    box-shadow: var(--irg-cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: irg-cb-fade-in .25s ease;
}

@keyframes irg-cb-fade-in {
    from { opacity: 0; transform: translateY(16px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----- Header ----- */
.irg-chatbot-window__header {
    background: var(--irg-cb-primary);
    color: var(--irg-cb-white);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.irg-chatbot-window__title {
    font-size: 16px;
    font-weight: 600;
}

.irg-chatbot-window__close {
    background: none;
    border: none;
    color: var(--irg-cb-white);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    opacity: .8;
    transition: opacity .15s;
}

.irg-chatbot-window__close:hover {
    opacity: 1;
}

/* ----- Zone messages ----- */
.irg-chatbot-window__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ----- Message individuel ----- */
.irg-cb-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: var(--irg-cb-radius);
    font-size: 14px;
    word-wrap: break-word;
}

.irg-cb-msg--bot {
    background: var(--irg-cb-gray-light);
    color: var(--irg-cb-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.irg-cb-msg--user {
    background: var(--irg-cb-primary);
    color: var(--irg-cb-white);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Markdown-lite dans les messages bot */
.irg-cb-msg--bot strong {
    font-weight: 600;
}

/* ----- Zone options (boutons) ----- */
.irg-chatbot-window__options {
    flex-shrink: 0;
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--irg-cb-gray);
    max-height: 45%;
    overflow-y: auto;
}

/* ----- Bouton option ----- */
.irg-cb-opt {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--irg-cb-primary);
    border-radius: 8px;
    background: var(--irg-cb-white);
    color: var(--irg-cb-primary);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s;
    text-decoration: none;
    line-height: 1.35;
}

.irg-cb-opt:hover,
.irg-cb-opt:focus-visible {
    background: var(--irg-cb-primary);
    color: var(--irg-cb-white);
}

/* Bouton lien externe : petite icône */
.irg-cb-opt--link::after {
    content: " \2197"; /* ↗ */
    font-size: 12px;
    opacity: .65;
}

/* Bouton téléphone */
.irg-cb-opt--phone::before {
    content: "\260E\00a0"; /* ☎  */
}

/* Bouton restart */
.irg-cb-opt--restart {
    border-style: dashed;
    font-weight: 400;
    font-size: 13px;
    text-align: center;
    color: var(--irg-cb-text-light);
    border-color: var(--irg-cb-gray);
}

.irg-cb-opt--restart:hover {
    background: var(--irg-cb-gray-light);
    color: var(--irg-cb-text);
    border-color: var(--irg-cb-text-light);
}

/* ----- Lien inline dans les messages FAQ ----- */
.irg-cb-msg a.irg-cb-inline-link {
    display: inline-block;
    margin-top: 8px;
    color: var(--irg-cb-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.irg-cb-msg a.irg-cb-inline-link:hover {
    color: var(--irg-cb-primary-light);
}

/* ==========================================================================
   Responsive — mobile
   ========================================================================== */
@media (max-width: 480px) {
    .irg-chatbot-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: calc(12px + var(--irg-cb-bubble-size) + 8px);
        right: 8px;
        border-radius: var(--irg-cb-radius);
    }

    .irg-chatbot-bubble {
        bottom: 12px;
        right: 12px;
    }

    .irg-chatbot-teaser {
        bottom: calc(12px + var(--irg-cb-bubble-size) + 8px);
        right: 12px;
        max-width: calc(100vw - 80px);
    }
}

/* ==========================================================================
   Animation typing (3 points)
   ========================================================================== */
.irg-cb-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.irg-cb-typing span {
    width: 7px;
    height: 7px;
    background: var(--irg-cb-text-light);
    border-radius: 50%;
    animation: irg-cb-bounce .6s infinite alternate;
}

.irg-cb-typing span:nth-child(2) { animation-delay: .15s; }
.irg-cb-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes irg-cb-bounce {
    from { opacity: .3; transform: translateY(0); }
    to   { opacity: 1;  transform: translateY(-4px); }
}
