/* MODIFICATIONS UI JUIN 2024 */

/* Modal de recherche IA */
.ps-chatbot-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
    pointer-events: none; /* Par défaut, ne bloque pas les clics */
}

/* Classe pour contrôler l'état ouvert de la modale */
.ps-chatbot-modal-open {
    pointer-events: auto !important; /* Force les clics quand ouverte */
}

.ps-chatbot-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    pointer-events: auto; /* L'overlay capture les clics pour fermer la modal */
}

.ps-chatbot-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1200px;
    width: 1100px;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    pointer-events: auto; /* Le contenu de la modal est toujours cliquable */
}

.ps-chatbot-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid #e5e5e5;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ps-chatbot-modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.ps-chatbot-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.ps-chatbot-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ps-chatbot-modal-body {
    padding: 32px;
    max-height: 70vh;
    overflow-y: auto;
    pointer-events: auto;
}

/* Nouveau loader moderne */
.ps-chatbot-modal .ps-chatbot-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    background: none;
}

/* Loader spécifique pour la modale */
.ps-chatbot-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.ps-chatbot-loader-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 18px;
    color: #4f3bd0;
    font-weight: 500;
}

.ps-chatbot-modal .ps-chatbot-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #4f3bd0;
    border-radius: 50%;
    animation: ps-spin 1s linear infinite;
    margin-bottom: 18px;
    background: none;
    box-sizing: border-box;
    display: block;
}

@keyframes ps-spin {
    0% { transform: rotate(0deg);}
    100% { transform: rotate(360deg);}
}

.ps-chatbot-modal .ps-chatbot-loading p {
    transform: none !important;
    animation: none !important;
    writing-mode: initial !important;
    text-align: center;
    display: block;
}

/* Résultats IA */
.ps-chatbot-ai-response {
    margin-bottom: 32px;
}

.ps-chatbot-ai-message {
    background: #f8f9fa;
    /* border-left: 4px solid #667eea; */
    border-left: none;
    padding: 20px;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    margin-bottom: 24px;
}

.ps-chatbot-suggested-products h4 {
    color: #333;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e5e5;
}

.ps-chatbot-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.ps-chatbot-product-card {
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 340px;
    max-width: 320px;
    margin: 0 auto;
    box-sizing: border-box;
}

.ps-chatbot-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.ps-chatbot-product-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 12px 12px 0 0;
    background: #f3f3f3;
    display: block;
}

.ps-chatbot-product-image[onerror] {
    content: url('/modules/ps_chatbot/views/img/no-image.svg');
}

.ps-chatbot-product-info {
    flex: 1;
    min-width: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
}

.ps-chatbot-product-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ps-chatbot-product-price {
    font-size: 18px;
    font-weight: 700;
    color: #4f3bd0;
    margin-bottom: 8px;
    text-align: center;
    width: 100%;
    display: block;
}

.ps-chatbot-product-description {
    font-size: 14px;
    color: #666;
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* États d'erreur et pas de résultats */
.ps-chatbot-no-results,
.ps-chatbot-error {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.ps-chatbot-error {
    color: #dc3545;
}

.ps-chatbot-no-results p,
.ps-chatbot-error p {
    font-size: 16px;
    margin: 0;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Animation de chargement style chatbot */
.ps-chatbot-loader-typing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 18px;
    color: #4f3bd0;
    margin-top: 12px;
    font-weight: 500;
}
.ps-chatbot-loader-dots {
    display: inline-block;
}
.ps-chatbot-loader-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background: #4f3bd0;
    border-radius: 50%;
    opacity: 0.6;
    animation: ps-chatbot-typing-dots 1.2s infinite both;
}
.ps-chatbot-loader-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.ps-chatbot-loader-dots span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes ps-chatbot-typing-dots {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
}

/* Animation des points de chargement pour le loader moderne */
.ps-chatbot-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.ps-chatbot-typing-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4f3bd0;
    animation: typing-dots 1.4s infinite ease-in-out;
    box-shadow: 0 2px 4px rgba(79, 59, 208, 0.3);
}

/* Classe pour désactiver l'animation */
.ps-chatbot-typing-dots.no-animation span {
    animation: none !important;
}

.ps-chatbot-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

/* Classe pour arrêter l'animation */
.ps-chatbot-typing-dots.animation-stopped {
    animation: none !important;
}

.ps-chatbot-typing-dots.animation-stopped span {
    animation: none !important;
}

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

/* Responsive */
@media (max-width: 768px) {
    .ps-chatbot-modal-content {
        width: 95vw;
        max-height: 95vh;
        margin: 10px;
    }
    
    .ps-chatbot-modal-header {
        padding: 20px;
    }
    
    .ps-chatbot-modal-header h3 {
        font-size: 20px;
    }
    
    .ps-chatbot-modal-body {
        padding: 20px;
    }
    
    .ps-chatbot-products-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .ps-chatbot-product-card {
        padding: 12px;
    }
    
    .ps-chatbot-product-image {
        width: 60px;
        height: 60px;
    }
    
    .ps-chatbot-product-name {
        font-size: 14px;
    }
    
    .ps-chatbot-product-price {
        font-size: 16px;
    }
}

#ps-chatbot-button {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border-radius: 50% !important;
    border: none;
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 16px rgba(80, 60, 180, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

#ps-chatbot-button:empty:after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background: url('/modules/ps_chatbot/views/img/profil_2.png') center/cover no-repeat;
    border-radius: 50%;
}

.ps-chatbot-search-bar-modern {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 32px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.07);
    padding: 6px 12px 6px 20px;
    position: relative;
    height: 56px;
    min-height: 56px;
}
.ps-chatbot-switch-container {
    display: flex;
    align-items: center;
    margin-left: 12px;
    gap: 6px;
    height: 100%;
}
.ps-chatbot-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    vertical-align: middle;
}

/* Styles pour l'historique de recherche et les suggestions */

.ps-chatbot-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
    font-family: inherit;
}

.suggestions-section {
    padding: 8px 0;
}

.suggestions-section:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

.suggestions-section h4 {
    margin: 0 0 8px 0;
    padding: 0 16px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    color: #333;
}

.suggestion-item:hover {
    background-color: #f5f5f5;
}

.suggestion-item:active {
    background-color: #e8e8e8;
}

.suggestion-icon {
    margin-right: 12px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.suggestion-text {
    flex: 1;
    font-weight: 500;
}

.suggestion-mode {
    font-size: 11px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

.suggestion-count {
    font-size: 11px;
    color: #666;
    margin-left: 8px;
}

/* Styles spécifiques pour les types de suggestions */
.history-item .suggestion-icon {
    color: #4f3bd0;
}

.popular-item .suggestion-icon {
    color: #ff6b35;
}

.suggestion-item .suggestion-icon {
    color: #28a745;
}

/* Animation d'apparition */
.ps-chatbot-suggestions {
    animation: slideDown 0.2s ease-out;
}

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

/* Responsive */
@media (max-width: 768px) {
    .ps-chatbot-suggestions {
        max-height: 250px;
        font-size: 13px;
    }
    
    .suggestion-item {
        padding: 10px 16px;
    }
    
    .suggestion-icon {
        font-size: 14px;
        margin-right: 10px;
    }
}

/* Scrollbar personnalisée */
.ps-chatbot-suggestions::-webkit-scrollbar {
    width: 6px;
}

.ps-chatbot-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ps-chatbot-suggestions::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ps-chatbot-suggestions::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* État vide */
.ps-chatbot-suggestions:empty::before {
    content: "Aucune suggestion disponible";
    display: block;
    padding: 16px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Bouton pour nettoyer l'historique */
.clear-history-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clear-history-btn:hover {
    background: #f0f0f0;
    color: #666;
}

/* Indicateur de chargement */
.suggestions-loading {
    padding: 16px;
    text-align: center;
    color: #666;
}

.suggestions-loading::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4f3bd0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
} 