/* ===== ASPTT Chatbot Widget — Modern UI ===== */

/* ---- Bouton flottant ---- */
#asptt-chat-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 62px;
    height: 62px;
    border-radius: 18px;
    background: #ffffff;
    color: #0057a8;
    border: none;
    cursor: grab;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28), 0 1px 4px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    touch-action: none;
}

#asptt-chat-toggle:hover {
    transform: scale(1.07);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
}

#asptt-chat-toggle.asptt-dragging {
    cursor: grabbing;
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    transition: none;
}

.asptt-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.asptt-toggle-icon svg {
    width: 36px;
    height: 36px;
}

/* ---- Fenêtre de chat ---- */
#asptt-chat-window {
    position: fixed;
    width: 370px;
    max-width: calc(100vw - 24px);
    height: 540px;
    max-height: calc(100vh - 110px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    transition: opacity 0.25s, transform 0.25s;
}

#asptt-chat-window.asptt-hidden {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
}

/* ---- Header ---- */
#asptt-chat-header {
    background: linear-gradient(135deg, #0057a8 0%, #0080c8 60%, #0099cc 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* Motif décoratif subtil dans le header */
#asptt-chat-header::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    pointer-events: none;
}

#asptt-chat-header::after {
    content: '';
    position: absolute;
    bottom: -40px;
    right: 30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    pointer-events: none;
}

.asptt-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.asptt-header-avatar {
    width: 46px;
    height: 46px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.35);
    font-size: 26px;
    line-height: 1;
    backdrop-filter: blur(4px);
}

.asptt-header-name {
    display: block;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.asptt-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    opacity: 0.85;
    line-height: 1.2;
    margin-top: 2px;
}

.asptt-header-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4dff91;
    box-shadow: 0 0 6px #4dff91;
    flex-shrink: 0;
}

#asptt-chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: background 0.15s;
    position: relative;
    flex-shrink: 0;
}

#asptt-chat-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ---- Zone de messages ---- */
#asptt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f5f7fa;
    scroll-behavior: smooth;
}

#asptt-chat-messages::-webkit-scrollbar { width: 4px; }
#asptt-chat-messages::-webkit-scrollbar-track { background: transparent; }
#asptt-chat-messages::-webkit-scrollbar-thumb { background: #c8d0da; border-radius: 4px; }

.asptt-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 13.5px;
    animation: aspttMsgIn 0.2s ease;
}

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

.asptt-msg-bot {
    background: #ffffff;
    color: #1c2433;
    border-bottom-left-radius: 5px;
    align-self: flex-start;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.asptt-msg-user {
    background: linear-gradient(135deg, #0057a8, #0080c8);
    color: #ffffff;
    border-bottom-right-radius: 5px;
    align-self: flex-end;
    box-shadow: 0 2px 8px rgba(0, 87, 168, 0.3);
}

/* ---- Indicateur de frappe ---- */
.asptt-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
}

.asptt-typing span {
    width: 8px;
    height: 8px;
    background: #b0bac8;
    border-radius: 50%;
    animation: aspttBounce 1.3s infinite ease-in-out;
}

.asptt-typing span:nth-child(2) { animation-delay: 0.18s; }
.asptt-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes aspttBounce {
    0%, 70%, 100% { transform: translateY(0); }
    35%            { transform: translateY(-7px); }
}

/* ---- Zone de saisie ---- */
#asptt-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #eaedf2;
    flex-shrink: 0;
}

#asptt-chat-input {
    flex: 1;
    border: 1.5px solid #e0e5ee;
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 13.5px;
    outline: none;
    resize: none;
    max-height: 90px;
    overflow-y: auto;
    font-family: inherit;
    background: #f5f7fa;
    color: #1c2433;
    transition: border-color 0.15s, background 0.15s;
    line-height: 1.45;
}

#asptt-chat-input::placeholder { color: #9aa3b0; }

#asptt-chat-input:focus {
    border-color: #0057a8;
    background: #ffffff;
}

#asptt-chat-send {
    height: 40px;
    padding: 0 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, #0057a8, #0080c8);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(0, 87, 168, 0.4);
}

#asptt-chat-send:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 14px rgba(0, 87, 168, 0.5);
}

#asptt-chat-send:disabled {
    background: #c8d0da;
    box-shadow: none;
    cursor: default;
    transform: none;
}

#asptt-chat-send svg { width: 16px; height: 16px; }

/* ---- Message d'erreur ---- */
.asptt-msg-error { color: #c0392b; font-style: italic; }

/* ---- Responsive mobile ---- */
@media (max-width: 420px) {
    #asptt-chat-window {
        width: calc(100vw - 16px) !important;
        border-radius: 16px;
    }
}
