/* AI Analysis Styles - Modern & Glassmorphism */

.ai-section {
    margin-top: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(167, 139, 250, 0.02));
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

/* Setup Screen */
.ai-setup {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.ai-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    box-shadow: 0 15px 40px rgba(139, 92, 246, 0.4);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.ai-setup h3 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.75rem;
}

.ai-setup > p {
    color: #64748b;
    font-size: 1.125rem;
    margin-bottom: 2.5rem;
}

/* Features Grid */
.ai-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin: 2.5rem 0;
}

.ai-feature {
    padding: 1.75rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(249, 250, 251, 0.9));
    backdrop-filter: blur(10px);
    border: 2px solid rgba(139, 92, 246, 0.15);
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.08);
}

.ai-feature:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 12px 32px rgba(139, 92, 246, 0.2);
}

.ai-feature i {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    display: block;
}

.ai-feature h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.ai-feature p {
    font-size: 0.9375rem;
    color: #64748b;
    margin: 0;
    line-height: 1.6;
}

/* Setup Steps */
.ai-setup-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: right;
    max-width: 600px;
    margin: 2.5rem auto;
}

.ai-step {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    padding: 1.75rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(249, 250, 251, 0.9));
    backdrop-filter: blur(10px);
    border: 2px solid rgba(139, 92, 246, 0.15);
    border-radius: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.08);
}

.ai-step:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateX(-5px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.15);
}

.step-number {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
}

.step-content {
    flex: 1;
}

.step-content h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.step-content p {
    color: #64748b;
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.step-content a {
    color: #8b5cf6;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.step-content a:hover {
    color: #7c3aed;
    text-decoration: underline;
}

.ai-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.ai-input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
    background: white;
}

.ai-help {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: rgba(139, 92, 246, 0.05);
    border: 2px solid rgba(139, 92, 246, 0.15);
    border-radius: 12px;
    margin-top: 2rem;
    color: #64748b;
    font-size: 0.9375rem;
}

.ai-help i {
    color: #8b5cf6;
    font-size: 1.5rem;
}

.ai-pricing-note {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(251, 191, 36, 0.05));
    border: 2px solid rgba(245, 158, 11, 0.2);
    border-radius: 12px;
    margin-top: 1rem;
}

.ai-pricing-note i {
    color: #f59e0b;
    font-size: 1.5rem;
    margin-top: 0.125rem;
}

.ai-pricing-note p {
    color: #78350f;
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.6;
}

/* Connected State */
.ai-connected {
    max-width: 900px;
    margin: 0 auto;
}

.ai-status {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.75rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(22, 163, 74, 0.08));
    border: 2px solid rgba(34, 197, 94, 0.3);
    border-radius: 50px;
    color: #16a34a;
    font-weight: 700;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.15);
}

.ai-status i {
    font-size: 1.5rem;
}

.ai-info-box {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.75rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(167, 139, 250, 0.05));
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    margin-bottom: 2rem;
}

.ai-info-box i {
    font-size: 2.5rem;
    color: #8b5cf6;
    margin-top: 0.25rem;
}

.ai-info-box h4 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.ai-info-box p {
    color: #64748b;
    font-size: 0.9375rem;
    margin: 0;
    line-height: 1.6;
}

/* Quick Analysis */
.ai-quick-analysis {
    padding: 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(249, 250, 251, 0.9));
    backdrop-filter: blur(10px);
    border: 2px solid rgba(139, 92, 246, 0.15);
    border-radius: 16px;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.08);
}

.ai-quick-analysis h4 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ai-quick-analysis p {
    color: #64748b;
    margin-bottom: 1.5rem;
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
    font-weight: 700;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.25);
}

.btn-large:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(139, 92, 246, 0.35);
}

/* Custom Prompt */
.ai-custom-prompt {
    padding: 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(249, 250, 251, 0.9));
    backdrop-filter: blur(10px);
    border: 2px solid rgba(139, 92, 246, 0.15);
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.08);
}

.ai-custom-prompt h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-prompt-input {
    width: 100%;
    padding: 1rem;
    background: white;
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Vazirmatn', sans-serif;
    margin-bottom: 1rem;
    resize: vertical;
    transition: all 0.3s ease;
}

.ai-prompt-input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

/* Analysis Result */
.ai-analysis-card {
    padding: 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(249, 250, 251, 0.95));
    backdrop-filter: blur(20px);
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.15);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(139, 92, 246, 0.1);
}

.ai-analysis-header h4 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-analysis-header i {
    color: #8b5cf6;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid rgba(139, 92, 246, 0.2);
    background: white;
    color: #8b5cf6;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #8b5cf6;
    color: white;
    transform: scale(1.05);
}

.ai-analysis-content {
    color: #334155;
    font-size: 1rem;
    line-height: 1.8;
    text-align: right;
}

.ai-analysis-content strong {
    color: #1e293b;
    font-weight: 700;
}

.ai-usage-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 10px;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: #64748b;
}

.ai-usage-info i {
    color: #8b5cf6;
}

/* Error Card */
.ai-error-card {
    padding: 2rem;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(220, 38, 38, 0.05));
    border: 2px solid rgba(239, 68, 68, 0.2);
    border-radius: 16px;
    text-align: center;
    margin-bottom: 2rem;
}

.ai-error-card i {
    font-size: 3rem;
    color: #ef4444;
    margin-bottom: 1rem;
}

.ai-error-card p {
    color: #991b1b;
    font-size: 1rem;
    margin: 0;
}

/* Loading Spinner */
.ai-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.spinner-circle {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(139, 92, 246, 0.1);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ai-spinner p {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.ai-spinner small {
    color: #64748b;
    font-size: 0.875rem;
}

/* Key Management */
.ai-key-management {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(249, 250, 251, 0.9));
    backdrop-filter: blur(10px);
    border: 2px solid rgba(139, 92, 246, 0.15);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.08);
}

.ai-key-management h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-key-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-sm {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 10px;
}

/* Toast Notifications */
.ai-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 10000;
    font-family: 'Vazirmatn', sans-serif;
}

.ai-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.ai-toast-success {
    border-right: 4px solid #22c55e;
}

.ai-toast-success i {
    color: #22c55e;
    font-size: 1.25rem;
}

.ai-toast-error {
    border-right: 4px solid #ef4444;
}

.ai-toast-error i {
    color: #ef4444;
    font-size: 1.25rem;
}

/* Dark Mode */
html[data-theme="dark"] .ai-section {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(167, 139, 250, 0.04));
    border-color: rgba(139, 92, 246, 0.3);
}

html[data-theme="dark"] .ai-setup h3,
html[data-theme="dark"] .ai-feature h4,
html[data-theme="dark"] .ai-step h4,
html[data-theme="dark"] .ai-info-box h4,
html[data-theme="dark"] .ai-quick-analysis h4,
html[data-theme="dark"] .ai-custom-prompt h4,
html[data-theme="dark"] .ai-analysis-header h4,
html[data-theme="dark"] .ai-key-management h4 {
    color: #f1f5f9;
}

html[data-theme="dark"] .ai-feature,
html[data-theme="dark"] .ai-step,
html[data-theme="dark"] .ai-quick-analysis,
html[data-theme="dark"] .ai-custom-prompt,
html[data-theme="dark"] .ai-analysis-card,
html[data-theme="dark"] .ai-key-management {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.7));
    border-color: rgba(139, 92, 246, 0.25);
}

html[data-theme="dark"] .ai-input,
html[data-theme="dark"] .ai-prompt-input {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(139, 92, 246, 0.3);
    color: #f1f5f9;
}

html[data-theme="dark"] .ai-analysis-content {
    color: #cbd5e1;
}

html[data-theme="dark"] .ai-toast {
    background: #1e293b;
    color: #f1f5f9;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-section {
        padding: 1.5rem;
    }
    
    .ai-features {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .ai-setup-steps {
        gap: 1rem;
    }
    
    .ai-step {
        padding: 1.25rem;
    }
    
    .ai-toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
    }
    
    .ai-key-actions {
        flex-direction: column;
    }
}

/* Conversation History Styles */
.ai-history-section {
    padding: 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(249, 250, 251, 0.9));
    backdrop-filter: blur(10px);
    border: 2px solid rgba(139, 92, 246, 0.15);
    border-radius: 16px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.08);
}

.ai-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.ai-history-header h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.ai-history-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.ai-history-item {
    padding: 1.5rem;
    background: white;
    border: 2px solid rgba(139, 92, 246, 0.1);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.ai-history-item:hover {
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.1);
}

.ai-history-item .ai-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}

.ai-history-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.875rem;
}

.ai-history-date i {
    color: #8b5cf6;
}

.ai-history-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    background: white;
    color: #8b5cf6;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.btn-icon-sm:hover {
    background: #8b5cf6;
    color: white;
    transform: scale(1.05);
}

.ai-history-question {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(139, 92, 246, 0.05);
    border-radius: 10px;
}

.ai-history-question i {
    color: #8b5cf6;
    font-size: 1.125rem;
    margin-top: 0.125rem;
}

.ai-history-question strong {
    color: #1e293b;
}

.ai-history-answer {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.ai-history-answer i {
    color: #8b5cf6;
    font-size: 1.125rem;
    margin-top: 0.125rem;
}

.ai-history-answer strong {
    color: #1e293b;
}

.ai-history-answer p {
    margin: 0.5rem 0 0 0;
    color: #334155;
    line-height: 1.6;
}

/* Dark Mode for History */
html[data-theme="dark"] .ai-history-section {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.7));
    border-color: rgba(139, 92, 246, 0.25);
}

html[data-theme="dark"] .ai-history-item {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(139, 92, 246, 0.2);
}

html[data-theme="dark"] .ai-history-header h4 {
    color: #f1f5f9;
}

html[data-theme="dark"] .ai-history-question {
    background: rgba(139, 92, 246, 0.1);
}

html[data-theme="dark"] .ai-history-question strong,
html[data-theme="dark"] .ai-history-answer strong {
    color: #f1f5f9;
}

html[data-theme="dark"] .ai-history-answer p {
    color: #cbd5e1;
}

html[data-theme="dark"] .btn-icon-sm {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(139, 92, 246, 0.3);
}
