/**
 * Styles pour l'Assistant IA - VERSION CORRIGÉE
 * Toutes les règles sont limitées à .ai-assistant-section pour ne pas affecter le reste du site
 */

/* ========== RESET LOCAL (uniquement pour la section IA) ========== */
.ai-assistant-section * {
    box-sizing: border-box;
}

.ai-assistant-container,
.ai-assistant-section {
    max-width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ========== TITRE PRINCIPAL EN BLEU (uniquement dans la section) ========== */
.ai-assistant-section .ai-section-title,
.ai-assistant-section h2.ai-section-title,
#ai-assistant-section h2 {
    color: #000091 !important;
    font-size: 2rem !important;
    font-weight: 700 !important;
    margin-bottom: 1.5rem !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
}

/* ========== HEADER GRADIENT ========== */
.ai-assistant-section .assistant-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    color: white;
    text-align: center;
}

.ai-assistant-section .assistant-title {
    color: white !important;
    font-size: 1.75rem !important;
    margin: 0 0 0.5rem 0 !important;
    font-weight: 600 !important;
}

.ai-assistant-section .assistant-subtitle {
    color: rgba(255,255,255,0.9) !important;
    font-size: 1rem !important;
    margin: 0 !important;
}

/* ========== CARDS GRID ========== */
.ai-assistant-section .ai-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.ai-assistant-section .ai-option-card {
    background: white;
    border: 2px solid #e5e5ea;
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ai-assistant-section .ai-option-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.ai-assistant-section .ai-option-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
    border-color: #667eea;
}

.ai-assistant-section .ai-option-card:hover::before {
    transform: scaleX(1);
}

.ai-assistant-section .card-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.ai-assistant-section .card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
}

.ai-assistant-section .card-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ========== ZONE DE SAISIE (uniquement dans la section IA) ========== */
.ai-assistant-section .fr-input-group,
.ai-assistant-section .chat-input-area,
.ai-assistant-section .chat-input-wrapper {
    background: #f8f8fc !important;
    border: 2px solid #e5e5e5 !important;
    border-radius: 12px !important;
    padding: 1.25rem !important;
    margin-top: 1rem !important;
    position: relative;
}

/* TEXTAREA ET INPUTS (uniquement dans la section IA) */
.ai-assistant-section #ai-chat-input,
.ai-assistant-section #ai-editor,
.ai-assistant-section textarea.fr-input,
.ai-assistant-section textarea,
.ai-assistant-section input[type="text"],
.ai-assistant-section input[type="number"],
.ai-assistant-section .fr-input {
    width: 100% !important;
    border: 2px solid #ddd !important;
    border-radius: 8px !important;
    padding: 16px 50px 16px 16px !important;
    background: white !important;
    font-size: 1rem !important;
    line-height: 1.5 !important;
    resize: vertical;
    min-height: 80px;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Focus state */
.ai-assistant-section #ai-chat-input:focus,
.ai-assistant-section #ai-editor:focus,
.ai-assistant-section textarea.fr-input:focus,
.ai-assistant-section textarea:focus {
    border-color: #000091 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(0,0,145,0.1) !important;
}

/* Placeholder style */
.ai-assistant-section #ai-chat-input::placeholder,
.ai-assistant-section #ai-editor::placeholder,
.ai-assistant-section textarea::placeholder {
    color: #999;
    opacity: 0.8;
}

/* ========== CONVERSATION AREA ========== */
.ai-assistant-section .conversation-area:empty {
    display: none !important;
}

.ai-assistant-section .conversation-area {
    display: none;
}

.ai-assistant-section .conversation-area:not(:empty) {
    display: block !important;
    background: white !important;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid #e5e5ea;
}

/* Messages sans scroll */
.ai-assistant-section #ai-chat-messages,
.ai-assistant-section .chat-messages,
.ai-assistant-section .chat-messages-area {
    max-height: none !important;
    overflow: visible !important;
    background: white !important;
    border: none !important;
}

/* ========== MESSAGES CHAT ========== */
.ai-assistant-section .ai-message,
.ai-assistant-section .chat-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    animation: ai-slideInUp 0.3s ease;
}

@keyframes ai-slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-assistant-section .ai-message--user,
.ai-assistant-section .chat-message--user {
    flex-direction: row-reverse;
}

.ai-assistant-section .ai-message-content,
.ai-assistant-section .chat-content {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.ai-assistant-section .ai-message--user .ai-message-content,
.ai-assistant-section .chat-message--user .chat-content {
    background: #000091;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-assistant-section .ai-message--assistant .ai-message-content,
.ai-assistant-section .chat-message--ai .chat-content {
    background: #f5f5fe;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #e8e8f5;
}

.ai-assistant-section .ai-message-avatar,
.ai-assistant-section .chat-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ai-assistant-section .ai-message--user .ai-message-avatar,
.ai-assistant-section .chat-message--user .chat-icon {
    background: #e3e3f0;
}

.ai-assistant-section .ai-message--assistant .ai-message-avatar,
.ai-assistant-section .chat-message--ai .chat-icon {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

/* ========== BOUTONS (uniquement dans la section IA) ========== */
.ai-assistant-section .fr-btn,
.ai-assistant-section button.fr-btn,
.ai-assistant-section #ai-chat-submit,
.ai-assistant-section #ai-siret-submit,
.ai-assistant-section .ai-submit-btn {
    padding: 0.75rem 1.5rem !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    border: none !important;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem;
    text-decoration: none !important;
}

.ai-assistant-section .fr-btn--primary,
.ai-assistant-section #ai-chat-submit,
.ai-assistant-section #ai-siret-submit {
    background: #000091 !important;
    color: white !important;
}

.ai-assistant-section .fr-btn--primary:hover,
.ai-assistant-section #ai-chat-submit:hover,
.ai-assistant-section #ai-siret-submit:hover {
    background: #1212ff !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,145,0.3);
}

.ai-assistant-section .fr-btn--secondary {
    background: #e5e5ea !important;
    color: #333 !important;
}

.ai-assistant-section .fr-btn--secondary:hover {
    background: #d0d0d7 !important;
}

/* ========== SIRET INPUT ========== */
.ai-assistant-section #ai-siret-input {
    font-size: 1.25rem !important;
    font-weight: 500;
    text-align: center;
    letter-spacing: 0.5px;
    padding: 16px 50px 16px 16px !important;
    border: 2px solid #ddd !important;
    border-radius: 8px !important;
    background: white !important;
    box-sizing: border-box !important;
}

.ai-assistant-section .ai-siret-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e5e5;
}

/* ========== DOCUMENT UPLOAD ========== */
.ai-assistant-section .ai-document-container,
.ai-assistant-section .document-upload-zone {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e5e5;
}

.ai-assistant-section #ai-drop-zone,
.ai-assistant-section .document-upload-zone {
    border: 3px dashed #000091;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    background: linear-gradient(135deg, #f5f5fe 0%, #ffffff 100%);
    transition: all 0.3s ease;
}

.ai-assistant-section #ai-drop-zone:hover,
.ai-assistant-section .document-upload-zone:hover {
    background: linear-gradient(135deg, #e8e8ff 0%, #f5f5fe 100%);
    border-color: #1212ff;
    transform: scale(1.01);
}

.ai-assistant-section .document-upload-zone.drag-over,
.ai-assistant-section #ai-drop-zone.drag-over {
    background: #e8e8ff;
    border-color: #000091;
    transform: scale(1.02);
}

/* ========== ANIMATIONS (avec préfixe ai-) ========== */
@keyframes ai-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-assistant-section .ai-loading,
.ai-assistant-section .typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #666;
    padding: 1rem;
}

.ai-assistant-section .ai-loading-spinner,
.ai-assistant-section .ai-loader {
    width: 20px;
    height: 20px;
    border: 2px solid #f0f0f5;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
}

.ai-assistant-section .typing-indicator span {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: ai-typing 1.4s infinite;
}

.ai-assistant-section .typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-assistant-section .typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ai-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ========== DRAG & DROP OVERLAY ========== */
.ai-assistant-section .drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.ai-assistant-section .drag-message {
    color: white;
    font-size: 2rem;
    font-weight: 600;
}

/* ========== RESPONSIVE MOBILE ========== */
@media (max-width: 768px) {
    .ai-assistant-container {
        padding: 1rem;
    }
    
    .ai-assistant-section .assistant-header {
        padding: 1.5rem;
    }
    
    .ai-assistant-section .assistant-title {
        font-size: 1.5rem !important;
    }
    
    .ai-assistant-section .ai-cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .ai-assistant-section .ai-message-content,
    .ai-assistant-section .chat-content {
        max-width: 85%;
    }
    
    .ai-assistant-section #ai-chat-input,
    .ai-assistant-section #ai-editor,
    .ai-assistant-section textarea.fr-input,
    .ai-assistant-section textarea {
        padding: 14px 40px 14px 14px !important;
        min-height: 60px;
    }
    
    .ai-assistant-section .chat-input-wrapper .fr-input-group {
        flex-direction: column;
    }
    
    .ai-assistant-section #ai-chat-submit,
    .ai-assistant-section #ai-siret-submit {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .ai-assistant-section textarea {
        padding: 12px 35px 12px 12px !important;
    }
    
    .ai-assistant-section .ai-message-content,
    .ai-assistant-section .chat-content {
        max-width: 90%;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
}

/* ========== ÉTATS ET FEEDBACK ========== */
.ai-assistant-section .error-message,
.ai-assistant-section .fr-alert--error {
    background: #fee;
    color: #c00;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid #c00;
}

.ai-assistant-section .success-message,
.ai-assistant-section .fr-alert--success {
    background: #efe;
    color: #070;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid #070;
}

.ai-assistant-section .info-message,
.ai-assistant-section .fr-alert--info {
    background: #e3f2fd;
    color: #0d47a1;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid #0d47a1;
}

/* ========== ANNONCE PREVIEW ========== */
.ai-assistant-section .annonce-legale-preview {
    background: #fffef0;
    border: 2px solid #000091;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
}

.ai-assistant-section .annonce-legale-preview h3 {
    color: #000091;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
}

/* ========== TARIF BADGE ========== */
.ai-assistant-section .tarif-badge {
    display: inline-block;
    background: #000091;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    margin: 0.5rem 0;
}

/* ========== ACTION BUTTONS ========== */
.ai-assistant-section .action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.ai-assistant-section .action-buttons .fr-btn {
    flex: 1;
    min-width: 200px;
}

/* ========== ACCESSIBILITÉ ========== */
.ai-assistant-section .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.ai-assistant-section :focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* ========== FIX PADDING POUR TEXTAREA (uniquement dans la section IA) ========== */
.ai-assistant-section #ai-editor {
    padding: 10px 15px 10px 10px !important;
}

.ai-assistant-section #ai-editor[contenteditable]:empty:before,
.ai-assistant-section #ai-editor:empty:not(:focus)::before,
.ai-assistant-section #ai-editor[data-empty="true"]::before {
    right: 15px !important;
    left: 16px !important;
    padding-right: 0 !important;
}

/* ========== PRINT STYLES ========== */
@media print {
    .ai-assistant-section .assistant-header,
    .ai-assistant-section .ai-cards-grid,
    .ai-assistant-section .fr-input-group,
    .ai-assistant-section .fr-btn {
        display: none !important;
    }
    
    .ai-assistant-section #ai-conversation,
    .ai-assistant-section .conversation-area {
        max-height: none;
        border: none;
    }
}