/**
 * Chatbot Widget - Vitesse Performance
 * Styles du widget de chat
 */

/* Variables */
:root {
    --vp-primary: #0089CF;
    --vp-primary-dark: #006ba3;
    --vp-dark: #0a2540;
    --vp-light: #f5f5f5;
    --vp-white: #ffffff;
    --vp-gray: #666666;
    --vp-border: #e0e0e0;
    --vp-shadow: rgba(0, 0, 0, 0.15);
    --vp-radius: 12px;
}

/* Bouton flottant pour ouvrir le chat */
#vp-chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--vp-white);
    border: 4px solid var(--vp-primary);
    cursor: pointer;
    box-shadow: 0 4px 20px var(--vp-shadow);
    z-index: 9998;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

#vp-chatbot-toggle:hover {
    transform: scale(1.08);
}

#vp-chatbot-toggle .avatar-img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    border-radius: 50%;
}

#vp-chatbot-toggle .close-icon {
    display: none;
    width: 40px;
    height: 40px;
    fill: var(--vp-primary);
}

#vp-chatbot-toggle.open {
    background: var(--vp-primary);
    border: 4px solid var(--vp-primary);
    box-shadow: 0 4px 20px var(--vp-shadow);
}

#vp-chatbot-toggle.open .avatar-img {
    display: none;
}

#vp-chatbot-toggle.open .close-icon {
    display: block;
    fill: var(--vp-white);
}

/* Bulle d'accroche */
#vp-chatbot-bubble {
    position: fixed;
    bottom: 130px;
    right: 20px;
    background: var(--vp-white);
    color: var(--vp-dark);
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--vp-shadow);
    font-size: 15px;
    font-weight: 500;
    z-index: 9997;
    max-width: 220px;
    cursor: pointer;
    animation: bubblePop 0.4s ease-out;
    border: 2px solid var(--vp-primary);
}

#vp-chatbot-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 40px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid var(--vp-white);
}

#vp-chatbot-bubble::before {
    content: '';
    position: absolute;
    bottom: -14px;
    right: 38px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid var(--vp-primary);
}

#vp-chatbot-bubble:hover {
    background: var(--vp-light);
}

#vp-chatbot-bubble .close-bubble {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: var(--vp-gray);
    color: white;
    border-radius: 50%;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
}

#vp-chatbot-bubble .close-bubble:hover {
    background: var(--vp-dark);
}

@keyframes bubblePop {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Badge notification */
#vp-chatbot-toggle .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    display: none;
}

/* Container principal du chat */
#vp-chatbot-container {
    position: fixed;
    bottom: 130px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 580px;
    max-height: calc(100vh - 160px);
    background: var(--vp-white);
    border-radius: var(--vp-radius);
    box-shadow: 0 5px 40px var(--vp-shadow);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

#vp-chatbot-container.open {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header du chat */
#vp-chatbot-header {
    background: linear-gradient(135deg, var(--vp-primary), var(--vp-primary-dark));
    color: var(--vp-white);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

#vp-chatbot-header .avatar {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    max-width: 80px;
    max-height: 80px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

#vp-chatbot-header .avatar img {
    width: 72px;
    height: 72px;
    min-width: 72px;
    max-width: 72px;
    object-fit: contain;
    border-radius: 50%;
}

#vp-chatbot-header .info {
    flex: 1;
}

#vp-chatbot-header .title {
    font-weight: 600;
    font-size: 20px;
    margin: 0;
}

#vp-chatbot-header .status {
    font-size: 14px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

#vp-chatbot-header .status::before {
    content: '';
    width: 10px;
    height: 10px;
    background: #2ecc71;
    border-radius: 50%;
}

/* Bouton effacer conversation */
#vp-chatbot-clear {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    margin-left: auto;
}

#vp-chatbot-clear:hover {
    background: rgba(255, 255, 255, 0.2);
}

#vp-chatbot-clear svg {
    width: 22px;
    height: 22px;
    fill: var(--vp-white);
    opacity: 0.8;
}

#vp-chatbot-clear:hover svg {
    opacity: 1;
}

/* Zone des messages */
#vp-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--vp-white);
}

/* Bulles de message */
.vp-message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 15px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.vp-message.assistant {
    background: var(--vp-white);
    color: var(--vp-dark);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.vp-message.assistant a {
    color: var(--vp-primary);
    text-decoration: underline;
}

.vp-message.assistant a:hover {
    color: var(--vp-primary-dark);
}

/* Indicateur de frappe */
.vp-typing {
    display: flex;
    gap: 4px;
    padding: 16px;
    align-self: flex-start;
}

.vp-typing span {
    width: 8px;
    height: 8px;
    background: var(--vp-gray);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Message d'erreur */
.vp-message.error {
    background: #fee;
    color: #c00;
    border: 1px solid #fcc;
}

/* Zone de saisie */
#vp-chatbot-input-area {
    padding: 18px;
    background: var(--vp-white);
    border-top: 1px solid var(--vp-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* Mention RGPD discrète */
#vp-chatbot-disclaimer {
    background: var(--vp-light);
    color: #999;
    font-size: 10px;
    text-align: center;
    padding: 6px 10px;
    border-top: 1px solid var(--vp-border);
}

#vp-chatbot-input {
    flex: 1;
    border: 1px solid var(--vp-border);
    border-radius: 22px;
    padding: 12px 18px;
    font-size: 15px;
    outline: none;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
}

#vp-chatbot-input:focus {
    border-color: var(--vp-primary);
}

#vp-chatbot-input::placeholder {
    color: #999;
}

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

#vp-chatbot-send:hover:not(:disabled) {
    background: var(--vp-primary-dark);
    transform: scale(1.05);
}

#vp-chatbot-send:disabled {
    background: var(--vp-border);
    cursor: not-allowed;
}

#vp-chatbot-send svg {
    width: 22px;
    height: 22px;
    fill: var(--vp-white);
}

/* Suggestions rapides (optionnel) */
.vp-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 20px 18px;
    background: var(--vp-white);
}

.vp-quick-reply {
    background: var(--vp-white);
    border: 1px solid var(--vp-primary);
    color: var(--vp-primary);
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.vp-quick-reply:hover {
    background: var(--vp-primary);
    color: var(--vp-white);
}

/* Responsive mobile */
@media (max-width: 480px) {
    #vp-chatbot-container {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    #vp-chatbot-toggle {
        bottom: 15px;
        right: 15px;
        width: 80px;
        height: 80px;
    }

    #vp-chatbot-toggle .avatar-img {
        width: 70px;
        height: 70px;
    }

    #vp-chatbot-container.open+#vp-chatbot-toggle {
        display: none;
    }

    #vp-chatbot-bubble {
        bottom: 105px;
        right: 15px;
        max-width: 200px;
        font-size: 14px;
        padding: 12px 16px;
    }

    #vp-chatbot-container.open~#vp-chatbot-bubble {
        display: none;
    }
}

/* Scrollbar personnalisée */
#vp-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#vp-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#vp-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--vp-border);
    border-radius: 3px;
}

#vp-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--vp-gray);
}