/* AI Recommendations CSS */

.ai-button-wrapper {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.ai-suggest-button {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.ai-suggest-button:hover:not(:disabled) {
    background-color: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.ai-suggest-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-suggest-button i {
    margin-right: 0.25rem;
}

/* Position button next to field */
.mb-3:has(.ai-recommendation-field) {
    position: relative;
}

.ai-suggestion-container {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.ai-suggestion-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    animation: slideDown 0.3s ease-out;
}

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

.ai-suggestion-header {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-weight: 600;
}

.ai-suggestion-header i {
    font-size: 1.2rem;
    color: #ffd700;
}

.ai-suggestion-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: white;
    opacity: 0.8;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-suggestion-close:hover {
    opacity: 1;
}

.ai-suggestion-body {
    background: white;
    padding: 1rem;
}

.ai-suggestion-reason,
.ai-suggestion-improvements,
.ai-suggestion-sil2,
.ai-suggestion-existing-block,
.ai-suggestion-text {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.ai-suggestion-reason:last-child,
.ai-suggestion-improvements:last-child,
.ai-suggestion-sil2:last-child,
.ai-suggestion-existing-block:last-child,
.ai-suggestion-text:last-child {
    margin-bottom: 0;
}

.ai-suggestion-existing-block strong {
    color: #6c757d;
    display: block;
    margin-bottom: 0.25rem;
}

.ai-suggestion-existing-block .ai-suggestion-text-content,
.ai-suggestion-existing-block .ai-suggestion-json {
    background: #f1f3f5;
    border-color: #dee2e6;
    color: #495057;
}

.ai-suggestion-existing-block .ai-suggestion-existing-json {
    background: #e9ecef;
    color: #495057;
}

.ai-suggestion-existing-block .ai-suggestion-empty {
    font-style: italic;
    color: #868e96;
}

.ai-suggestion-reason strong,
.ai-suggestion-improvements strong,
.ai-suggestion-sil2 strong,
.ai-suggestion-text strong {
    color: #667eea;
    display: block;
    margin-bottom: 0.25rem;
}

.ai-suggestion-improvements ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.ai-suggestion-improvements li {
    margin-bottom: 0.25rem;
    color: #555;
}

.ai-suggestion-sil2 {
    background: #f0f7ff;
    padding: 0.75rem;
    border-left: 3px solid #667eea;
    border-radius: 4px;
}

.ai-suggestion-text-content {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    margin-top: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #333;
    font-family: inherit;
    line-height: 1.6;
}

.ai-suggestion-json {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid #444;
    margin-top: 0.5rem;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
}

.ai-suggestion-json code {
    color: #f8f8f2;
    background: transparent;
    padding: 0;
    border: none;
}

.ai-suggestion-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.ai-suggestion-actions .btn {
    flex: 1;
}

.ai-suggestion-loading {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    color: #667eea;
    font-weight: 500;
    border: 2px dashed #667eea;
}

.ai-suggestion-loading i {
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

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

/* Highlight field when suggestion is available */
.ai-recommendation-field:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Prompt Editor Modal */
.ai-prompt-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.ai-prompt-editor-modal {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

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

.ai-prompt-editor-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.ai-prompt-editor-header h5 {
    margin: 0;
    color: #667eea;
    font-weight: 600;
}

.ai-prompt-editor-header h5 i {
    margin-right: 0.5rem;
}

.ai-prompt-editor-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.6;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-prompt-editor-close:hover {
    opacity: 1;
}

.ai-prompt-editor-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.ai-prompt-textarea {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-prompt-editor-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-suggestion-actions {
        flex-direction: column;
    }
    
    .ai-suggestion-actions .btn {
        width: 100%;
    }
    
    .ai-prompt-editor-modal {
        width: 95%;
        max-height: 95vh;
    }
    
    .ai-prompt-editor-footer {
        flex-direction: column;
    }
    
    .ai-prompt-editor-footer .btn {
        width: 100%;
    }
}

