/**
 * LitigesPro AI Assistant Styles
 */

/* Container */
.litigespro-ai-container {
    max-width: 100%;
    margin: 0 auto;
}

/* Chat Widget */
.litigespro-ai-chat-widget {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Header */
.litigespro-ai-header {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eaf6 100%);
    color: #374151;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.litigespro-ai-header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.litigespro-ai-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #cf0921 0%, #8b0615 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.litigespro-ai-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.litigespro-ai-status {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.litigespro-ai-actions {
    display: flex;
    gap: 0.5rem;
}

.litigespro-ai-action-btn {
    background: linear-gradient(135deg, #cf0921 0%, #8b0615 100%);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.litigespro-ai-action-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.litigespro-ai-action-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Messages Container */
.litigespro-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #f9fafb;
    min-height: 0; /* Important for proper scrolling */
}

.litigespro-ai-welcome {
    text-align: center;
    padding: 2rem 1rem;
}

.litigespro-ai-welcome h4 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    color: #1f2937;
}

.litigespro-ai-welcome p {
    margin: 0 0 1.5rem;
    color: #6b7280;
    line-height: 1.6;
}

/* Quick Questions */
.litigespro-ai-quick-questions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
    margin: 0 auto;
}

.quick-questions-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 0.5rem;
    text-align: left;
}

.quick-question-btn {
    background: white;
    border: 2px solid #e5e7eb;
    color: #374151;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    text-align: left;
    transition: all 0.2s;
}

.quick-question-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* Messages */
.litigespro-ai-message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.3s ease;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: #3b82f6;
    color: white;
}

.ai-message .message-avatar {
    background: linear-gradient(135deg, #cf0921 0%, #8b0615 100%);
    color: white;
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.user-message .message-content {
    margin-left: auto;
}

.message-text {
    background: #f9fafb;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    line-height: 1.6;
    color: #1f2937;
}

.user-message .message-text {
    background: #3b82f6;
    color: white;
}

.message-time {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.5rem;
}

/* Typing Indicator */
.typing-indicator .message-content {
    background: white;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    display: inline-block;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Error Message */
.litigespro-ai-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    animation: fadeInUp 0.3s ease;
}

/* Input Container */
.litigespro-ai-input-container {
    padding: 1.25rem;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.75rem;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: #667eea;
}

#ai-message-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    max-height: 120px;
    outline: none;
}

.litigespro-ai-send-btn {
    background: linear-gradient(135deg, #cf0921 0%, #8b0615 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.litigespro-ai-send-btn:hover {
    transform: scale(1.05);
}

.litigespro-ai-send-btn:active {
    transform: scale(0.95);
}

.litigespro-ai-disclaimer {
    margin: 0.75rem 0 0;
    font-size: 0.75rem;
    color: #9ca3af;
    text-align: center;
    line-height: 1.4;
}

/* Scrollbar */
.litigespro-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.litigespro-ai-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.litigespro-ai-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.litigespro-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive */
@media (max-width: 768px) {
    .litigespro-ai-chat-widget {
        height: calc(100vh - 2rem) !important;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .litigespro-ai-welcome {
        padding: 1.5rem 0.5rem;
    }
    
    .quick-question-btn {
        font-size: 0.8125rem;
        padding: 0.625rem 0.875rem;
    }
    
    .litigespro-ai-main-content {
        flex-direction: column;
    }
    
    .litigespro-ai-history-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 10000;
    }
}

/* History Sidebar Styles */
.litigespro-ai-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* Important for flex children */
}

.litigespro-ai-history-sidebar {
    width: 300px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: none;
    flex-direction: column;
    transition: all 0.3s ease;
}

.litigespro-ai-history-sidebar.active {
    display: flex;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: white;
}

.history-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}

.close-history-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.close-history-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.history-search {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.history-search input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.history-search input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.history-loading {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
    font-size: 0.875rem;
}

.history-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-item.active {
    border-color: #3b82f6;
    background: #eff6ff;
}

.history-item-preview {
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #6b7280;
}

.history-item-date {
    font-weight: 500;
}

.history-item-count {
    background: #e5e7eb;
    color: #374151;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-weight: 500;
}

.history-empty {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.history-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.litigespro-ai-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Important for flex children */
}

/* Input container positioning */
.litigespro-ai-input-container {
    border-top: 1px solid #e5e7eb;
    background: white;
}

/* Delete button for history items */
.history-item-delete {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
    margin-left: 0.5rem;
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Message links styling */
.message-text a {
    color: #3b82f6;
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s ease;
}

.message-text a:hover {
    color: #1d4ed8;
    text-decoration: none;
}

.user-message .message-text a {
    color: #bfdbfe;
}

.user-message .message-text a:hover {
    color: #ffffff;
}

/* Special styling for different link types */
.message-text a[href^="tel:"] {
    color: #059669;
}

.message-text a[href^="mailto:"] {
    color: #dc2626;
}

.message-text a[href^="https://justicial.fr"] {
    color: #cf0921;
    font-weight: 600;
}

.message-text a[href^="https://justicial.fr"]:hover {
    color: #8b0615;
}
