/* assets/css/chatbot.css — VERSION FINALE AVEC SYSTÈME DE VERROUILLAGE */

/* ═══════════════════════════════════════════════════ */
/*  🎨 VARIABLES                                       */
/* ═══════════════════════════════════════════════════ */

:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --danger-dark: #c0392b;
    --himaya-green: #00796B;
    --himaya-green-dark: #004D40;
    --orange: #FF5722;
    --orange-dark: #E64A19;
    --light-bg: #ecf0f1;
    --dark-text: #2c3e50;
    --light-text: #7f8c8d;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ═══════════════════════════════════════════════════ */
/*  📦 CONTAINER PRINCIPAL                             */
/* ═══════════════════════════════════════════════════ */

.chatbot-container {
    width: 100%;
    max-width: 900px;
    height: 80vh;
    max-height: 700px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════ */
/*  🔝 HEADER                                         */
/* ═══════════════════════════════════════════════════ */

.chatbot-header {
    background: linear-gradient(135deg, var(--primary-color), #5dade2);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.chatbot-header .status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.ai-badge {
    font-size: 12px;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.language-toggle {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.language-toggle:hover {
    background: rgba(255,255,255,0.3);
}

.status-dot {
    width: 10px;
    height: 10px;
    background: var(--success-color);
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ═══════════════════════════════════════════════════ */
/*  🛒 BOUTON PANIER (Header)                         */
/* ═══════════════════════════════════════════════════ */

.cart-button {
    position: relative;
    background: var(--himaya-green);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: auto;
}

.cart-button:hover {
    background: var(--himaya-green-dark);
    transform: scale(1.05);
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--orange);
    color: white;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: badgeBounce 0.5s ease;
}

@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ═══════════════════════════════════════════════════ */
/*  💬 ZONE DE MESSAGES                                */
/* ═══════════════════════════════════════════════════ */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: white;
    color: var(--dark-text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    margin: 0 10px;
}

.message.user .message-avatar {
    background: var(--secondary-color);
    color: white;
    order: 2;
}

.message.bot .message-avatar {
    background: var(--primary-color);
    color: white;
    order: 1;
}

/* ═══════════════════════════════════════════════════ */
/*  🏷️ CARTES PRODUITS                                */
/* ═══════════════════════════════════════════════════ */

.products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.product-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.product-card:hover {
    border-color: var(--himaya-green);
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.product-card.selected {
    border-color: var(--success-color);
    background: #e8f5e9;
}

.product-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
}

.product-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 5px;
    color: var(--dark-text);
}

.product-price {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 16px;
}

.product-actions {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.btn-add {
    flex: 1;
    padding: 8px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.btn-add:hover {
    background: var(--primary-dark);
}

/* ═══════════════════════════════════════════════════ */
/*  💡 SUGGESTIONS (Chips)                             */
/* ═══════════════════════════════════════════════════ */

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.suggestion-chip {
    background: var(--light-bg);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    user-select: none;
}

.suggestion-chip:hover {
    background: var(--himaya-green);
    color: white;
    border-color: var(--himaya-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 121, 107, 0.3);
}

/* ✅ Suggestion sélectionnée (celle cliquée) */
.suggestion-chip.suggestion-selected {
    background: linear-gradient(135deg, var(--success-color), #2ecc71) !important;
    color: white !important;
    cursor: default !important;
    border-color: var(--success-color) !important;
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3);
}

.suggestion-chip.suggestion-selected::after {
    content: ' ✓';
    font-weight: bold;
}

/* ✅ Suggestions désactivées (les autres du même groupe) */
.suggestion-chip.suggestion-disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    filter: grayscale(80%);
    transform: scale(0.95);
}

/* ✅ Flash d'attention quand l'utilisateur essaie de taper */
@keyframes flashPulse {
    0%   { transform: scale(1);    box-shadow: 0 0 0 rgba(231, 76, 60, 0); }
    50%  { transform: scale(1.08); box-shadow: 0 0 20px rgba(231, 76, 60, 0.5); border-color: var(--danger-color); }
    100% { transform: scale(1);    box-shadow: 0 0 0 rgba(231, 76, 60, 0); }
}

.suggestion-chip.flash-highlight {
    animation: flashPulse 0.4s ease-in-out 3;
    border-color: var(--danger-color) !important;
    z-index: 5;
    position: relative;
}

/* ═══════════════════════════════════════════════════ */
/*  ⌨️ ZONE INPUT                                     */
/* ═══════════════════════════════════════════════════ */

.chatbot-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    position: relative; /* ✅ Nécessaire pour l'overlay */
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
}

.chatbot-input:focus {
    border-color: var(--primary-color);
}

.btn-send {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-send:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-voice {
    padding: 12px 16px;
    background: var(--himaya-green);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-voice:hover:not(:disabled) {
    background: var(--himaya-green-dark);
    transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════ */
/*  🔒 SYSTÈME DE VERROUILLAGE INPUT                   */
/* ═══════════════════════════════════════════════════ */

/* --- Overlay qui bloque toute la zone input --- */
.input-lock-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.93);
    z-index: 10;
    justify-content: center;
    align-items: center;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: not-allowed;
    transition: opacity 0.3s ease;
}

.input-lock-overlay.active {
    display: flex;
}

.input-lock-overlay span {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-dark));
    color: white;
    padding: 12px 28px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.35);
    animation: overlayPulse 2.5s ease-in-out infinite;
    text-align: center;
    max-width: 90%;
    letter-spacing: 0.3px;
}

@keyframes overlayPulse {
    0%, 100% { transform: scale(1);    opacity: 1;   }
    50%      { transform: scale(1.02); opacity: 0.92; }
}

/* --- Input lui-même quand il est verrouillé --- */
.chatbot-input.input-locked {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
    border: 2px dashed #ddd !important;
    color: #bbb !important;
    user-select: none;
    -webkit-user-select: none;
}

.chatbot-input.input-locked::placeholder {
    color: #999;
    font-style: italic;
}

/* --- Boutons désactivés (commun) --- */
.btn-send:disabled,
.btn-voice:disabled {
    background-color: #ccc !important;
    cursor: not-allowed !important;
    opacity: 0.6;
    transform: none !important;
}

/* ═══════════════════════════════════════════════════ */
/*  ⏳ INDICATEUR DE FRAPPE (Typing)                   */
/* ═══════════════════════════════════════════════════ */

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--himaya-green);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ═══════════════════════════════════════════════════ */
/*  📋 DEVIS : Récapitulatif dans le chat              */
/* ═══════════════════════════════════════════════════ */

.quote-summary {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-top: 15px;
}

.quote-summary h3 {
    margin-top: 0;
    color: var(--himaya-green);
}

.quote-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    margin: 10px 0;
    border-radius: 8px;
    border-left: 3px solid var(--himaya-green);
}

.quote-item-details {
    flex: 1;
}

.quote-item-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-remove {
    background: var(--orange);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.btn-remove:hover {
    background: var(--orange-dark);
    transform: scale(1.1);
}

.quote-totals {
    border-top: 2px solid #ddd;
    padding-top: 15px;
    margin-top: 15px;
}

.quote-total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 16px;
}

.quote-total-row.total {
    font-size: 20px;
    font-weight: bold;
    color: var(--himaya-green);
    border-top: 2px solid var(--himaya-green);
    padding-top: 15px;
    margin-top: 10px;
}

.quote-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ═══════════════════════════════════════════════════ */
/*  📋 DEVIS : Modal                                   */
/* ═══════════════════════════════════════════════════ */

.quote-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.quote-modal.active {
    display: flex;
}

.quote-modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.quote-modal h3 {
    margin-bottom: 20px;
    color: var(--dark-text);
}

.quote-total {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* ═══════════════════════════════════════════════════ */
/*  📝 FORMULAIRE EMAIL DEVIS                          */
/* ═══════════════════════════════════════════════════ */

.quote-form {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-top: 15px;
}

.quote-form h3 {
    margin-top: 0;
    color: var(--himaya-green);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--himaya-green);
    box-shadow: 0 0 0 3px rgba(0, 121, 107, 0.1);
}

/* ═══════════════════════════════════════════════════ */
/*  🔘 BOUTONS GÉNÉRIQUES                             */
/* ═══════════════════════════════════════════════════ */

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-primary {
    background: var(--himaya-green);
    color: white;
}

.btn-primary:hover {
    background: var(--himaya-green-dark);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--orange);
    color: white;
}

.btn-secondary:hover {
    background: var(--orange-dark);
    transform: translateY(-2px);
}

/* ═══════════════════════════════════════════════════ */
/*  📱 RESPONSIVE                                      */
/* ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .chatbot-container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
    
    .products-container {
        grid-template-columns: 1fr;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .chatbot-header h2 {
        font-size: 18px;
    }
    
    .input-wrapper {
        flex-wrap: wrap;
    }
    
    .btn-voice {
        order: 3;
        flex: 0 0 auto;
    }
    
    .quote-actions {
        flex-direction: column;
    }
    
    .product-card {
        width: 100%;
    }
    
    .input-lock-overlay span {
        font-size: 13px;
        padding: 10px 20px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
}

@media (max-width: 400px) {
    .chatbot-header {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .chatbot-header .status {
        justify-content: center;
    }
    
    .suggestion-chip {
        font-size: 12px;
        padding: 6px 10px;
    }
}
