/* ============================================
   CHATBOT WIDGET - SAM (Amplitude Informatique)
   Design moderne avec identité visuelle
   ============================================ */

/* Variables pour le thème */
:root {
    --chatbot-primary: #2563EB;
    --chatbot-primary-hover: #1D4ED8;
    --chatbot-bg: #FFFFFF;
    --chatbot-surface: #F8F9FA;
    --chatbot-border: #E5E7EB;
    --chatbot-text: #1F2937;
    --chatbot-text-secondary: #6B7280;
    --chatbot-user-msg: #2563EB;
    --chatbot-bot-msg: #F3F4F6;
    --chatbot-shadow: rgba(0, 0, 0, 0.1);
    --chatbot-shadow-lg: rgba(0, 0, 0, 0.15);
}

/* Bouton déclencheur du chatbot */
.chatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(139, 92, 246, 0.5);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

/* Effet de brillance/pulse IA */
.chatbot-trigger::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, #8B5CF6, #EC4899);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: -1;
    filter: blur(15px);
}

.chatbot-trigger:hover::before {
    opacity: 0.5;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.3;
    }
}

.chatbot-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 32px rgba(139, 92, 246, 0.7);
}

/* Icône IA - Logo personnalisé */
.chatbot-trigger img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.4));
    transition: transform 0.3s ease;
}

/* Animation de l'icône au hover */
.chatbot-trigger:hover img {
    transform: scale(1.1);
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.6));
}

@keyframes sparkleRotate {
    0%, 100% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(15deg) scale(1.1);
    }
}

/* État actif (chatbot ouvert) */
.chatbot-trigger.active {
    background: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
}

.chatbot-trigger.active img {
    transform: rotate(90deg);
}

@keyframes sparkleActive {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.8);
    }
    100% {
        transform: scale(1);
    }
}

/* Conteneur principal du chatbot */
.chatbot-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 450px;
    max-width: calc(100vw - 48px);
    height: 650px;
    max-height: calc(100vh - 150px);
    background: var(--chatbot-bg);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--chatbot-shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    animation: slideIn 0.3s ease-out;
}

.chatbot-container.active {
    display: flex;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* En-tête du chatbot */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, #1E40AF 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Avatar SAM - sans fond rond */
.chatbot-avatar {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chatbot-header-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.chatbot-header-text p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
    color: white;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-close svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Disclaimer IA */
.chatbot-disclaimer {
    background: #FEF3C7;
    border-bottom: 1px solid #FDE68A;
    padding: 10px 20px;
    font-size: 12px;
    color: #92400E;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot-disclaimer-icon {
    flex-shrink: 0;
    font-size: 16px;
}

.chatbot-disclaimer-text {
    line-height: 1.4;
}

.chatbot-disclaimer-text strong {
    font-weight: 600;
}

/* Zone de messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--chatbot-surface);
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

/* Message individuel */
.chatbot-message {
    display: flex;
    gap: 10px;
    animation: messageIn 0.3s ease-out;
}

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

.chatbot-message.user {
    flex-direction: row-reverse;
}

/* Avatar SAM dans les messages - sans fond rond */
.chatbot-message-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-message.user .chatbot-message-avatar {
    background: var(--chatbot-primary);
    color: white;
    border-radius: 50%;
    font-size: 18px;
}

.chatbot-message.bot .chatbot-message-avatar {
    background: transparent;
}

.chatbot-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chatbot-message-content {
    max-width: 75%;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--chatbot-text);
    box-shadow: 0 1px 2px var(--chatbot-shadow);
}

.chatbot-message.user .chatbot-message-content {
    background: var(--chatbot-user-msg);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message.bot .chatbot-message-content {
    background: white;
    border-bottom-left-radius: 4px;
}

/* Indicateur de frappe */
.chatbot-typing {
    display: flex;
    gap: 10px;
    animation: messageIn 0.3s ease-out;
}

.chatbot-typing .chatbot-message-avatar {
    width: 40px;
    height: 40px;
}

.chatbot-typing-indicator {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    box-shadow: 0 1px 2px var(--chatbot-shadow);
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--chatbot-text-secondary);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Zone de saisie */
.chatbot-input-area {
    border-top: 1px solid var(--chatbot-border);
    padding: 16px 20px;
    background: var(--chatbot-bg);
    flex-shrink: 0;
}

.chatbot-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

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

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

.chatbot-send-btn {
    width: 40px;
    height: 40px;
    background: var(--chatbot-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chatbot-send-btn:hover:not(:disabled) {
    background: var(--chatbot-primary-hover);
    transform: scale(1.05);
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
    transform: rotate(60deg);  /* Icône envoi orientée vers le haut-droite (45° anti-horaire) */
}

/* Message d'accueil */
.chatbot-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--chatbot-text-secondary);
}

.chatbot-welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chatbot-welcome h4 {
    margin: 0 0 8px 0;
    color: var(--chatbot-text);
    font-size: 20px;
    font-weight: 600;
}

.chatbot-welcome p {
    margin: 0 0 20px 0;
    font-size: 14px;
    line-height: 1.6;
}

.chatbot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.chatbot-suggestion-btn {
    background: white;
    border: 1px solid var(--chatbot-border);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.chatbot-suggestion-btn:hover {
    border-color: var(--chatbot-primary);
    background: var(--chatbot-surface);
    transform: translateX(4px);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .chatbot-container {
        width: 380px;
        height: 600px;
    }

    .chatbot-header {
        padding: 16px;
    }

    .chatbot-avatar {
        width: 40px;
        height: 40px;
    }

    .chatbot-header-text h3 {
        font-size: 16px;
    }

    .chatbot-header-text p {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        animation: slideInMobile 0.3s ease-out;
    }

    @keyframes slideInMobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .chatbot-trigger {
        width: 60px;
        height: 60px;
        bottom: 16px;
        right: 16px;
    }

    .chatbot-trigger img {
        width: 34px;
        height: 34px;
    }

    .chatbot-trigger::before {
        inset: -3px;
    }

    /* Header mobile */
    .chatbot-header {
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .chatbot-header-info {
        gap: 10px;
    }

    .chatbot-avatar {
        width: 36px;
        height: 36px;
    }

    .chatbot-header-text h3 {
        font-size: 15px;
    }

    .chatbot-header-text p {
        font-size: 11px;
    }

    .chatbot-close {
        width: 36px;
        height: 36px;
    }

    .chatbot-close svg {
        width: 20px;
        height: 20px;
    }

    /* Disclaimer mobile */
    .chatbot-disclaimer {
        padding: 8px 12px;
        font-size: 11px;
    }

    .chatbot-disclaimer-icon {
        font-size: 14px;
    }

    /* Messages mobile */
    .chatbot-messages {
        padding: 12px;
        gap: 12px;
    }

    .chatbot-message-avatar {
        width: 32px;
        height: 32px;
    }

    .chatbot-message.user .chatbot-message-avatar {
        font-size: 14px;
    }

    .chatbot-message-content {
        max-width: 85%;
        padding: 10px 12px;
        font-size: 14px;
        line-height: 1.5;
    }

    /* Typing indicator mobile */
    .chatbot-typing .chatbot-message-avatar {
        width: 32px;
        height: 32px;
    }

    .chatbot-typing-indicator {
        padding: 10px 12px;
    }

    .chatbot-typing-dot {
        width: 6px;
        height: 6px;
    }

    /* Input mobile */
    .chatbot-input-area {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .chatbot-input-container {
        gap: 8px;
    }

    .chatbot-input {
        padding: 10px 12px;
        font-size: 16px; /* Évite le zoom auto sur iOS */
        border-radius: 20px;
    }

    .chatbot-send-btn {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }

    .chatbot-send-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Welcome mobile */
    .chatbot-welcome {
        padding: 24px 16px;
    }

    .chatbot-welcome-icon {
        width: 60px;
        height: 60px;
        margin-bottom: 12px;
    }

    .chatbot-welcome h4 {
        font-size: 18px;
    }

    .chatbot-welcome p {
        font-size: 13px;
        margin-bottom: 16px;
    }

    /* Suggestions mobile - amélioration majeure */
    .chatbot-suggestions {
        gap: 6px;
        margin-top: 16px;
    }

    .chatbot-suggestion-btn {
        padding: 12px 14px;
        font-size: 13px;
        border-radius: 12px;
        line-height: 1.4;
    }

    .chatbot-suggestion-btn:hover {
        transform: none;
    }

    .chatbot-suggestion-btn:active {
        background: var(--chatbot-surface);
        transform: scale(0.98);
    }
}

@media (max-width: 360px) {
    .chatbot-trigger {
        width: 56px;
        height: 56px;
        bottom: 12px;
        right: 12px;
    }

    .chatbot-trigger img {
        width: 30px;
        height: 30px;
    }

    .chatbot-header {
        padding: 10px 12px;
    }

    .chatbot-avatar {
        width: 32px;
        height: 32px;
    }

    .chatbot-header-text h3 {
        font-size: 14px;
    }

    .chatbot-header-text p {
        font-size: 10px;
    }

    .chatbot-message-content {
        max-width: 88%;
        padding: 8px 10px;
        font-size: 13px;
    }

    .chatbot-welcome h4 {
        font-size: 16px;
    }

    .chatbot-welcome p {
        font-size: 12px;
    }

    .chatbot-suggestion-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
}
