/* Nexize Chatbot WordPress Plugin - CSS */

/* Variables CSS */
:root {
    --nexize-primary-color: #0000ff;
    --nexize-primary-hover: #4169E1;
    --nexize-success-color: #2ed573;
    --nexize-success-hover: #20bf55;
    --nexize-error-color: #ff4757;
    --nexize-bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --nexize-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    --nexize-shadow-hover: 0 20px 60px rgba(0, 0, 0, 0.3);
    --nexize-border-radius: 25px;
    --nexize-font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Container principal */
#nexize-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: var(--nexize-font-family);
}

/* Positions du chatbot */
.chatbot-bottom_right {
    bottom: 30px;
    right: 30px;
}

.chatbot-bottom_left {
    bottom: 30px;
    left: 30px;
}

.chatbot-top_right {
    top: 30px;
    right: 30px;
}

.chatbot-top_left {
    top: 30px;
    left: 30px;
}

/* Toggle Button */
.nexize-chatbot-toggle {
    width: 60px;
    height: 60px;
    background: var(--nexize-primary-color);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: var(--nexize-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    position: relative;
    overflow: hidden;
}

.nexize-chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--nexize-shadow-hover);
}

.nexize-chatbot-toggle.active {
    background: var(--nexize-primary-color);
    animation: none;
}

@keyframes pulse {
    0% {
        box-shadow: var(--nexize-shadow), 0 0 0 0 rgba(0, 0, 255, 0.5);
    }
    70% {
        box-shadow: var(--nexize-shadow), 0 0 0 20px rgba(0, 0, 255, 0);
    }
    100% {
        box-shadow: var(--nexize-shadow), 0 0 0 0 rgba(0, 0, 255, 0);
    }
}

/* Icône du toggle */
.toggle-icon-img {
    width: 35px;
    height: 35px;
    transition: all 0.3s ease;
    filter: brightness(0) invert(1); /* Force l'icône en blanc */
}

.toggle-icon-close {
    width: 30px;
    height: 30px;
    fill: white;
    transition: all 0.3s ease;
    position: absolute;
}

/* Fenêtre du chatbot */
.nexize-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: var(--nexize-border-radius);
    box-shadow: var(--nexize-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.4s ease-out;
}

/* Positions spécifiques de la fenêtre */
.chatbot-bottom_left .nexize-chatbot-window {
    bottom: 80px;
    right: auto;
    left: 0;
}

.chatbot-top_right .nexize-chatbot-window {
    top: 80px;
    bottom: auto;
    right: 0;
}

.chatbot-top_left .nexize-chatbot-window {
    top: 80px;
    bottom: auto;
    right: auto;
    left: 0;
}

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

@keyframes glow {
    0%, 100% {
        box-shadow: var(--nexize-shadow);
    }
    50% {
        box-shadow: 0 15px 50px rgba(0, 0, 255, 0.4), 0 0 30px rgba(0, 0, 255, 0.3);
    }
}

/* Header du chatbot */
.nexize-chatbot-header {
    background: linear-gradient(135deg, var(--nexize-primary-color), var(--nexize-primary-hover));
    color: white;
    padding: 20px;
    text-align: center;
}

.nexize-chatbot-header h3 {
    font-size: 18px;
    margin: 0 0 5px 0;
    font-weight: 600;
}

.nexize-chatbot-header p {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
    font-weight: 400;
}

/* Zone de messages */
.nexize-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f9fa;
    scroll-behavior: smooth;
    /* Optimisations performance scroll */
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
    transform: translateZ(0);
    /* Accélération matérielle pour fluidité */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    /* Momentum scrolling iOS */
    -webkit-momentum-scrolling: touch;
    /* Optimiser le rendu */
    contain: layout style paint;
}

/* Scrollbar personnalisée plus fluide */
.nexize-chat-messages::-webkit-scrollbar {
    width: 6px;
    background: transparent;
}

.nexize-chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.nexize-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.nexize-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* Optimisations pour les messages */
.nexize-message {
    margin-bottom: 15px;
    /* Optimisation rendu */
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Animation optimisée */
    animation: fadeInUp 0.3s ease-out;
    /* Isolation des layers pour performance */
    isolation: isolate;
}

/* Animation plus fluide */
@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translate3d(0, 15px, 0);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Messages bubbles optimisées */
.nexize-message-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 20px;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 14px;
    /* Optimisations performance */
    will-change: auto;
    contain: layout style;
    /* Anti-aliasing pour texte plus net */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Messages */
.nexize-message {
    margin-bottom: 15px;
    animation: fadeInUp 0.3s ease-out;
}

.nexize-message.bot {
    text-align: left;
}

.nexize-message.user {
    text-align: right;
}

.nexize-message.bot .nexize-message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nexize-message.user .nexize-message-bubble {
    background: var(--nexize-primary-color);
    color: white;
    border-bottom-right-radius: 5px;
}

/* Styles pour le formatage Markdown */
.nexize-message-bubble strong,
.nexize-message-bubble .nexize-highlight {
    color: var(--nexize-primary-color);
    font-weight: 600;
}

.nexize-message.user .nexize-message-bubble strong {
    color: white;
    font-weight: 600;
}

.nexize-message-bubble .nexize-important {
    color: var(--nexize-primary-color);
    font-weight: 500;
    background: rgba(0, 0, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.nexize-message.user .nexize-message-bubble .nexize-important {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

/* Sections avec émojis */
.nexize-section-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    margin-top: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0, 0, 255, 0.2);
}

.nexize-section-header:first-child {
    margin-top: 0;
}

.nexize-section-emoji {
    font-size: 20px;
    margin-right: 8px;
}

.nexize-section-title {
    color: var(--nexize-primary-color);
    font-size: 16px;
    font-weight: 600;
}

/* Listes stylées */
.nexize-message-bubble .nexize-list {
    margin: 10px 0;
    padding-left: 0;
    list-style: none;
}

.nexize-message-bubble .nexize-list li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.nexize-message-bubble .nexize-list li:before {
    content: "•";
    position: absolute;
    left: 8px;
    color: var(--nexize-primary-color);
    font-weight: bold;
    font-size: 18px;
    line-height: 1;
}

/* Paragraphes et espacement */
.nexize-message-bubble p {
    margin: 0 0 10px 0;
}

.nexize-message-bubble p:last-child {
    margin-bottom: 0;
}

.nexize-message-bubble br + br {
    display: block;
    content: "";
    height: 8px;
}

/* Boutons de choix */
.nexize-choice-buttons {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Optimiser l'animation */
    transform: translateZ(0);
}

.nexize-choice-btn {
    background: white;
    border: 2px solid var(--nexize-primary-color);
    color: var(--nexize-primary-color);
    padding: 10px 15px;
    border-radius: 35px;
    cursor: pointer;
    transition: all 0.2s ease; /* Transition plus courte pour fluidité */
    font-family: var(--nexize-font-family);
    font-size: 14px;
    text-align: left;
    font-weight: 500;
    /* Optimisations performance */
    will-change: transform, background-color, color;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.nexize-choice-btn:hover {
    background: var(--nexize-primary-color);
    color: white;
    transform: translate3d(0, -2px, 0); /* translate3d plus performant */
    box-shadow: 0 4px 12px rgba(0, 0, 255, 0.3);
}

/* Zone de saisie */
.nexize-chat-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #eee;
    /* Optimisation position fixe mobile */
    will-change: auto;
    contain: layout style;
}

.nexize-input-group {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.nexize-chat-input {
    flex: 1;
    border: 2px solid #e1e8ed;
    border-radius: 25px;
    padding: 12px 20px;
    font-family: var(--nexize-font-family);
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease; /* Transition plus courte */
    max-height: 100px;
    min-height: 20px;
    /* Optimisations performance */
    will-change: border-color;
    backface-visibility: hidden;
}

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

.nexize-send-btn {
    background: var(--nexize-primary-color);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease; /* Plus court pour fluidité */
    /* Optimisations */
    will-change: transform, background-color;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.nexize-send-btn:hover {
    transform: scale3d(1.1, 1.1, 1);
    background: var(--nexize-primary-hover);
}

.nexize-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Formulaire de lead */
.nexize-lead-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin: 10px 0;
    border: 1px solid #e1e8ed;
    /* Optimiser le rendu */
    contain: layout style;
    will-change: auto;
}

.nexize-lead-form h4 {
    margin: 0 0 15px 0;
    color: var(--nexize-primary-color);
    font-size: 16px;
    font-weight: 600;
}

.nexize-form-group {
    margin-bottom: 15px;
}

.nexize-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.nexize-form-group input,
.nexize-form-group select,
.nexize-form-group textarea {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-family: var(--nexize-font-family);
    font-size: 14px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.nexize-form-group input:focus,
.nexize-form-group select:focus,
.nexize-form-group textarea:focus {
    outline: none;
    border-color: var(--nexize-primary-color);
}

.nexize-form-group.required label::after {
    content: " *";
    color: var(--nexize-error-color);
}

.nexize-submit-btn {
    background: var(--nexize-primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 35px;
    cursor: pointer;
    font-family: var(--nexize-font-family);
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    font-size: 14px;
}

.nexize-submit-btn:hover {
    background: var(--nexize-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 255, 0.3);
}

/* Bouton de réservation */
.nexize-book-meeting-btn {
    background: var(--nexize-success-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 35px;
    cursor: pointer;
    font-family: var(--nexize-font-family);
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-size: 14px;
}

.nexize-book-meeting-btn:hover {
    background: var(--nexize-success-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(46, 213, 115, 0.3);
    text-decoration: none;
    color: white;
}

/* Indicateur de frappe */
.nexize-typing-indicator {
    display: none;
    align-items: flex-start;
    margin-bottom: 15px;
    animation: fadeInUp 0.3s ease-out;
    opacity: 0;
    transition: opacity 0.3s ease;
    /* Optimiser l'animation */
    will-change: opacity, transform;
    transform: translateZ(0);
}

.nexize-typing-indicator.show {
    display: flex;
    opacity: 1;
}

.nexize-typing-bubble {
    background: white;
    padding: 15px 20px;
    border-radius: 20px;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 80%;
    display: inline-block;
    /* Optimisation rendu */
    will-change: auto;
    contain: layout style;
}

.nexize-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 20px;
}

.nexize-typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
    opacity: 0.5;
    /* Optimisation animation */
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.nexize-typing-dot:nth-child(1) { 
    animation-delay: -0.32s; 
}

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

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

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale3d(0.8, 0.8, 1);
        opacity: 0.5;
    }
    40% {
        transform: scale3d(1, 1, 1);
        opacity: 1;
    }
}

/* Messages de validation */
.nexize-validation-message {
    font-size: 12px;
    margin-top: 5px;
    color: var(--nexize-error-color);
    display: none;
}

.nexize-validation-message.success {
    color: var(--nexize-success-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Assurer que le container principal est visible */
    #nexize-chatbot-container {
        position: fixed !important;
        z-index: 999999 !important;
    }
    
    /* Toggle button mobile */
    .nexize-chatbot-toggle {
        width: 60px !important;
        height: 60px !important;
        position: fixed !important;
        z-index: 1000000 !important;
        /* Assurer une position visible */
        bottom: 20px !important;
        right: 20px !important;
    }

    .toggle-icon-img {
        width: 30px !important;
        height: 30px !important;
    }

    .toggle-icon-close {
        width: 25px !important;
        height: 25px !important;
    }
    
    /* Fenêtre chatbot mobile - plein écran */
    .nexize-chatbot-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0 !important;
        z-index: 999998 !important;
        max-width: none !important;
        max-height: none !important;
    }
    
    /* Positions spécifiques écrasées pour mobile */
    .chatbot-bottom_right .nexize-chatbot-window,
    .chatbot-bottom_left .nexize-chatbot-window,
    .chatbot-top_right .nexize-chatbot-window,
    .chatbot-top_left .nexize-chatbot-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0 !important;
    }
    
    /* Header mobile */
    .nexize-chatbot-header {
        padding: 20px 15px !important;
        position: relative;
    }
    
    /* Ajouter bouton fermer sur mobile */
    .nexize-chatbot-header::after {
        content: '✕';
        position: absolute;
        top: 15px;
        right: 15px;
        font-size: 24px;
        color: white;
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
    }
    
    /* Messages area mobile */
    .nexize-chat-messages {
        padding: 15px !important;
        /* Ajuster pour le header et l'input */
        height: calc(100vh - 180px) !important;
        overflow-y: auto !important;
        /* Scroll plus fluide sur mobile */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        /* Réduire les repaints */
        will-change: scroll-position;
        /* Optimiser pour écrans tactiles */
        touch-action: pan-y;
    }
    
    /* Input area mobile */
    .nexize-chat-input-area {
        padding: 15px !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        border-top: 2px solid #eee !important;
        z-index: 1000001 !important;
    }
    
    /* Input mobile */
    .nexize-chat-input {
        font-size: 16px !important; /* Éviter le zoom iOS */
        min-height: 44px !important; /* Taille minimum tactile */
        padding: 12px 15px !important;
    }
    
    .nexize-send-btn {
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* Messages plus compacts sur mobile */
    .nexize-message {
        margin-bottom: 12px;
        /* Optimisation mémoire mobile */
        contain: layout style;
    }
    
    .nexize-message-bubble {
        font-size: 13px !important;
        padding: 10px 14px !important;
        max-width: 85%;
        /* Optimiser rendu texte mobile */
        text-rendering: optimizeSpeed;
    }
    
    /* Sections optimisées mobile */
    .nexize-section-header {
        margin-bottom: 8px;
        margin-top: 12px;
        padding-bottom: 6px;
    }
    
    .nexize-section-emoji {
        font-size: 18px;
        margin-right: 6px;
    }
    
    .nexize-section-title {
        font-size: 14px;
    }
    
    /* Listes optimisées mobile */
    .nexize-message-bubble .nexize-list li {
        padding-left: 20px;
        margin-bottom: 6px;
    }
    
    .nexize-message-bubble .nexize-list li:before {
        left: 6px;
        font-size: 16px;
    }
    
    /* Boutons de choix mobile */
    .nexize-choice-btn {
        padding: 12px 15px !important;
        font-size: 14px !important;
        min-height: 44px !important; /* Taille minimum tactile */
        text-align: center !important;
    }
    
    /* Formulaire mobile */
    .nexize-lead-form {
        padding: 15px !important;
        margin: 10px 0 !important;
    }
    
    .nexize-form-group input,
    .nexize-form-group select,
    .nexize-form-group textarea {
        font-size: 16px !important; /* Éviter le zoom iOS */
        min-height: 44px !important;
        padding: 12px 15px !important;
    }
    
    .nexize-submit-btn,
    .nexize-book-meeting-btn {
        min-height: 44px !important;
        font-size: 16px !important;
        padding: 12px 20px !important;
    }
    
    /* Indicateur de frappe mobile */
    .nexize-typing-bubble {
        padding: 12px 16px;
        max-width: 85%;
    }
    
    .nexize-typing-dots {
        min-width: 35px;
        height: 18px;
    }
    
    .nexize-typing-dot {
        width: 6px;
        height: 6px;
    }
}

/* Spécifique iOS */
@supports (-webkit-touch-callout: none) {
    .nexize-chatbot-window {
        /* Fix pour iOS Safari */
        height: -webkit-fill-available !important;
    }
    
    .nexize-chat-input {
        /* Éviter le zoom automatique sur iOS */
        font-size: 16px !important;
    }
}

/* Très petits écrans (< 480px) */
@media (max-width: 480px) {
    .nexize-chatbot-toggle {
        width: 55px !important;
        height: 55px !important;
        bottom: 15px !important;
        right: 15px !important;
    }
    
    .toggle-icon-img {
        width: 25px !important;
        height: 25px !important;
    }
    
    .nexize-chatbot-header h3 {
        font-size: 16px !important;
    }
    
    .nexize-chatbot-header p {
        font-size: 13px !important;
    }
    
    .nexize-message-bubble {
        font-size: 13px !important;
        padding: 10px 14px !important;
    }
}

/* Landscape mobile */
@media (max-width: 812px) and (orientation: landscape) {
    .nexize-chat-messages {
        height: calc(100vh - 160px) !important;
    }
    
    .nexize-chatbot-header {
        padding: 15px !important;
    }
    
    .nexize-chatbot-header h3 {
        font-size: 16px !important;
        margin-bottom: 2px !important;
    }
    
    .nexize-chatbot-header p {
        font-size: 12px !important;
    }
}

/* États du chatbot */
.nexize-chatbot-window.show {
    display: flex;
}

.nexize-chatbot-window.hide {
    display: none;
}

/* Animations personnalisées */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.nexize-choice-btn {
    animation: bounceIn 0.5s ease-out;
}

/* Style pour les boutons désactivés */
.nexize-choice-btn:disabled,
.nexize-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading state */
.nexize-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .nexize-chat-messages {
        scroll-behavior: auto;
    }
}

/* Focus visible pour l'accessibilité */
.nexize-chatbot-toggle:focus-visible,
.nexize-choice-btn:focus-visible,
.nexize-submit-btn:focus-visible,
.nexize-send-btn:focus-visible {
    outline: 2px solid var(--nexize-primary-color);
    outline-offset: 2px;
}

/* Mode réduit animations si préféré par l'utilisateur */
@media (prefers-reduced-motion: reduce) {
    .nexize-chat-messages {
        scroll-behavior: auto;
    }
    
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Performance optimizations pour écrans haute densité */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .nexize-message-bubble {
        -webkit-font-smoothing: subpixel-antialiased;
    }
}