/* ============================================================
   GedKey — Widget Chatbot IA
   ============================================================ */

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
    --cb-primary:     #011c61;
    --cb-accent:      #09aff4;
    --cb-danger:      #fb0205;
    --cb-white:       #ffffff;
    --cb-bg:          #f4f8ff;
    --cb-border:      rgba(9, 175, 244, 0.18);
    --cb-text:        #1a1a2e;
    --cb-muted:       #6b7280;
    --cb-shadow:      0 12px 48px rgba(1, 28, 97, 0.22);
    --cb-radius:      18px;
    --cb-radius-sm:   10px;
    --cb-transition:  0.25s cubic-bezier(.4, 0, .2, 1);
    --cb-panel-w:     380px;
    --cb-panel-h:     540px;
}

/* ── Bouton flottant ─────────────────────────────────────────────────────── */
#chatbot-toggle {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--cb-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(1, 28, 97, 0.38);
    transition: transform var(--cb-transition), box-shadow var(--cb-transition), background var(--cb-transition);
    outline: none;
}

#chatbot-toggle:hover {
    background: #09aff4;
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(9, 175, 244, 0.45);
}

#chatbot-toggle i {
    font-size: 1.6rem;
    color: var(--cb-white);
    transition: transform var(--cb-transition);
    line-height: 1;
}

#chatbot-toggle.open i {
    transform: rotate(90deg);
}

/* Badge "nouveau" */
#chatbot-toggle::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: var(--cb-danger);
    border-radius: 50%;
    border: 2px solid var(--cb-white);
    transition: opacity var(--cb-transition);
}

#chatbot-toggle.seen::after {
    opacity: 0;
}

/* ── Panneau principal ───────────────────────────────────────────────────── */
#chatbot-panel {
    position: fixed;
    bottom: 104px;
    right: 28px;
    z-index: 9999;
    width: var(--cb-panel-w);
    height: var(--cb-panel-h);
    background: var(--cb-white);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    border: 1px solid var(--cb-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(16px) scale(0.97);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--cb-transition), opacity var(--cb-transition);
    transform-origin: bottom right;
}

#chatbot-panel.visible {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#chatbot-header {
    background: var(--cb-primary);
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

#chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(9, 175, 244, 0.25);
    border: 2px solid rgba(9, 175, 244, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chatbot-avatar i {
    font-size: 1.1rem;
    color: var(--cb-accent);
}

#chatbot-header-text .title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--cb-white);
    line-height: 1.2;
}

#chatbot-header-text .status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

#chatbot-header-text .status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
}

#chatbot-close {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.4rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 6px;
    transition: color var(--cb-transition), background var(--cb-transition);
}

#chatbot-close:hover {
    color: var(--cb-white);
    background: rgba(255, 255, 255, 0.1);
}

/* ── Zone de messages ────────────────────────────────────────────────────── */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar { width: 4px; }
#chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#chatbot-messages::-webkit-scrollbar-thumb { background: rgba(9, 175, 244, 0.25); border-radius: 99px; }

/* Bulle générique */
.cb-bubble {
    max-width: 82%;
    padding: 0.65rem 0.9rem;
    border-radius: var(--cb-radius);
    font-size: 0.88rem;
    line-height: 1.55;
    word-break: break-word;
    animation: cbFadeUp 0.22s ease both;
}

@keyframes cbFadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Bulle assistante (gauche) */
.cb-bubble.assistant {
    background: var(--cb-bg);
    color: var(--cb-text);
    border: 1px solid var(--cb-border);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

/* Bulle utilisateur (droite) */
.cb-bubble.user {
    background: var(--cb-primary);
    color: var(--cb-white);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Contenu Markdown léger */
.cb-bubble strong { font-weight: 700; }

.cb-bubble ul {
    margin: 0.4rem 0 0.2rem;
    padding-left: 1.1rem;
}

.cb-bubble ul li {
    margin-bottom: 0.2rem;
}

/* Loader 3 points */
.cb-bubble.loading {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0.75rem 1rem;
    min-width: 60px;
}

.cb-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cb-accent);
    animation: cbDot 1.2s infinite ease-in-out;
}

.cb-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cbDot {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%           { transform: scale(1.1); opacity: 1; }
}

/* ── Quick replies ───────────────────────────────────────────────────────── */
#chatbot-suggestions {
    padding: 0 1rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    flex-shrink: 0;
}

.cb-suggestion {
    font-size: 0.78rem;
    padding: 0.35rem 0.75rem;
    border-radius: 99px;
    background: rgba(9, 175, 244, 0.08);
    border: 1px solid var(--cb-border);
    color: var(--cb-primary);
    cursor: pointer;
    transition: background var(--cb-transition), color var(--cb-transition);
    white-space: nowrap;
    font-weight: 500;
}

.cb-suggestion:hover {
    background: var(--cb-accent);
    border-color: var(--cb-accent);
    color: var(--cb-white);
}

/* ── Footer — zone de saisie ─────────────────────────────────────────────── */
#chatbot-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--cb-border);
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    background: var(--cb-white);
}

#chatbot-input {
    flex: 1;
    border: 1px solid var(--cb-border);
    border-radius: 99px;
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
    color: var(--cb-text);
    background: var(--cb-bg);
    outline: none;
    transition: border-color var(--cb-transition), box-shadow var(--cb-transition);
    font-family: inherit;
}

#chatbot-input:focus {
    border-color: var(--cb-accent);
    box-shadow: 0 0 0 3px rgba(9, 175, 244, 0.12);
}

#chatbot-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--cb-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--cb-transition), transform var(--cb-transition);
    outline: none;
}

#chatbot-send:hover:not(:disabled) {
    background: var(--cb-accent);
    transform: scale(1.08);
}

#chatbot-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#chatbot-send i {
    font-size: 0.95rem;
    color: var(--cb-white);
}

/* ── Bulle d'erreur ──────────────────────────────────────────────────────── */
.cb-bubble.error {
    background: #fff0f0;
    border-color: rgba(251, 2, 5, 0.2);
    color: #b91c1c;
}

/* ── Responsive mobile ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #chatbot-panel {
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }

    #chatbot-toggle {
        bottom: 20px;
        right: 20px;
    }
}
