/* =============================================
   ESD Cybersecurity — Chatbot Widget
   ============================================= */

/* --- Bouton flottant --- */
.esd-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(16, 185, 129, 0.4), 0 2px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.esd-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 32px rgba(16, 185, 129, 0.5), 0 4px 12px rgba(0,0,0,0.3);
}

.esd-chat-btn svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

.esd-chat-btn.open svg {
    transform: rotate(90deg);
}

/* Pulse animation on load */
.esd-chat-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.3);
    animation: esd-pulse 2s ease-out 3;
    pointer-events: none;
}

@keyframes esd-pulse {
    0%   { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Notification dot */
.esd-chat-btn .esd-notif {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #0f172a;
    animation: esd-bounce 1s ease infinite alternate;
}

@keyframes esd-bounce {
    0%   { transform: scale(1); }
    100% { transform: scale(1.15); }
}

/* --- Fenêtre de chat --- */
.esd-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9999;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #0f172a;
    border: 1px solid #1e293b;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(16, 185, 129, 0.1);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.esd-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* --- Header --- */
.esd-chat-header {
    padding: 18px 20px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    border-bottom: 1px solid #ffffff10;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.esd-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981, #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.esd-chat-avatar svg {
    width: 22px;
    height: 22px;
    color: #fff;
}

.esd-chat-header-info {
    flex: 1;
    min-width: 0;
}

.esd-chat-header-title {
    font-size: 15px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
    line-height: 1.2;
}

.esd-chat-header-status {
    font-size: 11px;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.esd-chat-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}

.esd-chat-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.esd-chat-close:hover {
    background: #1e293b;
    color: #f8fafc;
}

/* --- Messages --- */
.esd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.esd-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.esd-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.esd-chat-messages::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.esd-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: esd-msg-in 0.3s ease;
}

@keyframes esd-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.esd-msg-bot {
    align-self: flex-start;
    background: #1e293b;
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}

.esd-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.esd-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: #1e293b;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.esd-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    animation: esd-typing-dot 1.4s ease-in-out infinite;
}

.esd-typing span:nth-child(2) { animation-delay: 0.2s; }
.esd-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes esd-typing-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Quick replies --- */
.esd-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 8px;
    flex-shrink: 0;
}

.esd-quick-btn {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid #334155;
    background: transparent;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.esd-quick-btn:hover {
    border-color: #10b981;
    color: #10b981;
    background: #10b98110;
}

/* CTA tunnel (bouton mis en avant) */
.esd-quick-btn--cta {
    border-color: #10b981;
    color: #10b981;
    background: #10b98115;
    font-weight: 600;
}

.esd-quick-btn--cta:hover {
    background: #10b98130;
}

/* --- Input --- */
.esd-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #1e293b;
    background: #0f172a;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.esd-chat-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #f8fafc;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.esd-chat-input::placeholder {
    color: #475569;
}

.esd-chat-input:focus {
    border-color: #10b981;
}

.esd-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.esd-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.esd-chat-send:not(:disabled):hover {
    transform: scale(1.05);
}

.esd-chat-send svg {
    width: 18px;
    height: 18px;
}

/* --- Footer --- */
.esd-chat-footer {
    padding: 6px 16px 10px;
    text-align: center;
    font-size: 10px;
    color: #334155;
    flex-shrink: 0;
}

/* --- Bulle teaser (effet tunnel) --- */
.esd-chat-teaser {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9997;
    width: 280px;
    max-width: calc(100vw - 100px);
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    padding: 16px 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(16, 185, 129, 0.08);
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.esd-chat-teaser.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.esd-teaser-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: none;
    border: none;
    color: #475569;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    transition: color 0.2s;
}

.esd-teaser-close:hover {
    color: #94a3b8;
}

.esd-teaser-text {
    font-size: 13.5px;
    color: #e2e8f0;
    line-height: 1.5;
    margin-bottom: 12px;
    padding-right: 16px;
    cursor: pointer;
}

.esd-teaser-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
}

.esd-teaser-cta:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

/* Flèche de la bulle pointant vers le bouton */
.esd-chat-teaser::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 16px;
    height: 16px;
    background: #1e293b;
    border-right: 1px solid #334155;
    border-bottom: 1px solid #334155;
    transform: rotate(45deg);
}

/* --- Mobile --- */
@media (max-width: 480px) {
    .esd-chat-window {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .esd-chat-btn {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .esd-chat-teaser {
        bottom: 82px;
        right: 16px;
        width: 260px;
    }
}
