/* --- Bouton flottant --- */
#chat-bubble {
    position: fixed;
    bottom: 60px;
    right: 28px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 6px 24px rgba(102,126,234,0.5);
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s;
    user-select: none;
}
#chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 32px rgba(102,126,234,0.65);
}
#chat-bubble.open { background: linear-gradient(135deg, #764ba2 0%, #667eea 100%); }

#chat-icon-open  { display: block; }
#chat-icon-close { display: none; }
#chat-bubble.open #chat-icon-open  { display: none; }
#chat-bubble.open #chat-icon-close { display: block; }

/* Badge notification */
#chat-notif {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4757;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0a0a0a;
    animation: pulse-notif 2s infinite;
}
@keyframes pulse-notif {
    0%,100% { box-shadow: 0 0 0 0 rgba(255,71,87,0.6); }
    50%      { box-shadow: 0 0 0 6px rgba(255,71,87,0); }
}

/* --- Fenêtre --- */
#chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 340px;
    max-height: 520px;
    background: #111118;
    border: 1px solid rgba(102,126,234,0.25);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(102,126,234,0.1);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    /* Caché par défaut */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.34,1.56,.64,1);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
#chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
#chat-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(102,126,234,0.2);
    flex-shrink: 0;
}
#chat-header-left { display: flex; align-items: center; gap: 12px; }
#chat-avatar {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
#chat-title   { color: #fff; font-weight: 700; font-size: 15px; }
#chat-status  { color: #888; font-size: 12px; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
#chat-dot {
    width: 7px; height: 7px;
    background: #2ed573;
    border-radius: 50%;
    display: inline-block;
    animation: blink 2s infinite;
}
@keyframes blink {
    0%,100% { opacity: 1; } 50% { opacity: 0.3; }
}

/* Zone messages */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(102,126,234,0.3) transparent;
}
.chat-msg { display: flex; flex-direction: column; max-width: 85%; }
.chat-msg-bot  { align-self: flex-start; }
.chat-msg-user { align-self: flex-end; }
.chat-bubble-msg {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}
.chat-msg-bot  .chat-bubble-msg {
    background: rgba(102,126,234,0.15);
    border: 1px solid rgba(102,126,234,0.2);
    border-bottom-left-radius: 4px;
    color: #e0e0e0;
}
.chat-msg-user .chat-bubble-msg {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-bottom-right-radius: 4px;
    color: #fff;
}
.chat-time { font-size: 11px; color: #555; margin-top: 4px; }
.chat-msg-user .chat-time { text-align: right; }

/* Indicateur "en train d'écrire" */
#chat-typing { display: none; align-self: flex-start; }
#chat-typing .chat-bubble-msg {
    background: rgba(102,126,234,0.1);
    border: 1px solid rgba(102,126,234,0.15);
    color: #888;
    font-size: 13px;
    font-style: italic;
}

/* Formulaire */
#chat-form-area {
    padding: 12px 14px 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    background: #0e0e16;
}
#chat-fields { display: flex; flex-direction: column; gap: 8px; }
#chat-fields input,
#chat-fields textarea {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 13px;
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    resize: none;
    width: 100%;
    box-sizing: border-box;
}
#chat-fields input:focus,
#chat-fields textarea:focus {
    border-color: #667eea;
    background: rgba(102,126,234,0.08);
}
#chat-fields input::placeholder,
#chat-fields textarea::placeholder { color: #555; }

#chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    width: 100%;
}
#chat-send-btn:hover  { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(102,126,234,0.4); }
#chat-send-btn:active { transform: scale(0.98); }
#chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

#chat-error {
    color: #ff6b6b;
    font-size: 12px;
    margin-top: 6px;
    min-height: 16px;
}

#chat-bubble {
  bottom: 60px;
}

/* Responsive mobile */
@media (max-width: 480px) {
    #chat-window { width: calc(100vw - 24px); right: 12px; bottom: 90px; }
    #chat-bubble { right: 16px; bottom: 16px; }
}
