/**
 * LitigesPro AI Assistant Styles - ChatGPT Inspired Design
 * Updated with modern, clean ChatGPT-like interface
 */

/* Container */
.litigespro-ai-container {
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Chat Widget */
.litigespro-ai-chat-widget {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Header - ChatGPT Style */
.litigespro-ai-header {
    background: #ffffff;
    color: #374151;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e5e5;
}

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

.litigespro-ai-avatar {
    width: 32px;
    height: 32px;
    background: #cf0921;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.litigespro-ai-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.litigespro-ai-status {
    margin: 2px 0 0;
    font-size: 12px;
    color: #6b7280;
    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: #f7f7f8;
    border: 1px solid #e5e5e5;
    color: #374151;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.litigespro-ai-action-btn:hover {
    background: #f0f0f0;
    border-color: #d1d5db;
}

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

/* Messages Container - ChatGPT Style */
.litigespro-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: #f7f7f8;
    min-height: 0;
}

.litigespro-ai-welcome {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.litigespro-ai-welcome h3 {
    margin: 0 0 0.75rem;
    font-size: 20px;
    font-weight: 600;
    color: #374151;
}

.litigespro-ai-welcome p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

/* 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 - ChatGPT Style */
.litigespro-ai-message {
    display: flex;
    padding: 1.5rem 1rem;
    animation: fadeInUp 0.3s ease;
}

.litigespro-ai-message:nth-child(even) {
    background: #ffffff;
}

.litigespro-ai-message:nth-child(odd) {
    background: #f7f7f8;
}

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

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 1rem;
    margin-top: 0.25rem;
}

.user-message .message-avatar {
    background: #19c37d;
    color: white;
}

.ai-message .message-avatar {
    background: #cf0921;
    color: white;
}

.message-content {
    flex: 1;
    max-width: calc(100% - 46px);
}

.message-text {
    color: #374151;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    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 - ChatGPT Style */
.litigespro-ai-input-container {
    padding: 1rem 1.5rem 1.5rem;
    background: white;
    border-top: 1px solid #e5e5e5;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    max-width: 768px;
    margin: 0 auto;
}

.input-wrapper:focus-within {
    border-color: #10a37f;
    box-shadow: 0 2px 6px rgba(16, 163, 127, 0.15);
}

#ai-message-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    max-height: 200px;
    outline: none;
    color: #374151;
}

.litigespro-ai-send-btn {
    background: #cf0921;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.litigespro-ai-send-btn:hover {
    background: #b8081e;
}

.litigespro-ai-send-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.litigespro-ai-disclaimer {
    margin: 0.75rem 0 0;
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
    line-height: 1.4;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
}

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

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

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

.litigespro-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive Design - ChatGPT Style */
@media (max-width: 768px) {
    .litigespro-ai-chat-widget {
        height: calc(100vh - 2rem) !important;
        border-radius: 0;
        border: none;
    }
    
    .litigespro-ai-message {
        padding: 1rem 0.75rem;
    }
    
    .message-avatar {
        width: 24px;
        height: 24px;
        margin-right: 0.75rem;
    }
    
    .litigespro-ai-welcome {
        padding: 2rem 1rem;
    }
    
    .litigespro-ai-input-container {
        padding: 0.75rem 1rem 1rem;
    }
    
    .input-wrapper {
        border-radius: 8px;
        padding: 0.5rem 0.75rem;
    }
    
    #ai-message-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .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 - ChatGPT Style */
.litigespro-ai-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.litigespro-ai-history-sidebar {
    width: 260px;
    background: #f7f7f8;
    border-right: 1px solid #e5e5e5;
    display: none;
    flex-direction: column;
    transition: all 0.2s 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 #e5e5e5;
    background: white;
}

.history-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

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

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

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

.history-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: all 0.15s ease;
    background: white;
}

.history-search input:focus {
    border-color: #10a37f;
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

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

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

.history-item {
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.history-item:hover {
    border-color: #10a37f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.history-item.active {
    border-color: #10a37f;
    background: #f0fdf4;
}

.history-item-preview {
    font-size: 14px;
    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: 12px;
    color: #6b7280;
}

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

.history-item-count {
    background: #f3f4f6;
    color: #6b7280;
    padding: 0.125rem 0.375rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 11px;
}

.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 - ChatGPT Style */
.message-text a {
    color: #10a37f;
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.15s ease;
}

.message-text a:hover {
    color: #0d8f6b;
    text-decoration: none;
}

/* 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: #b8081e;
}

/* Additional ChatGPT-inspired improvements */
.message-text strong {
    font-weight: 600;
}

.message-text code {
    background: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 13px;
}

.message-text pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.message-text ul, .message-text ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.message-text li {
    margin: 0.25rem 0;
}

/* Improved focus states */
.litigespro-ai-action-btn:focus,
.close-history-btn:focus,
.litigespro-ai-send-btn:focus {
    outline: 2px solid #10a37f;
    outline-offset: 2px;
}

/* Loading states */
.litigespro-ai-send-btn.loading {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.litigespro-ai-send-btn.loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
