/* LCTC AI Chatbot Frontend Styles */

.lctc-chatbot-container {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin: 15px 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.lctc-chatbot-container:hover {
    border-color: #ccc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.lctc-ai-badge {
    color: white;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    position: relative;
}

.lctc-ai-badge::after {
    content: '▼';
    font-size: 12px;
    transition: transform 0.3s ease;
}

.lctc-chatbot-container.collapsed .lctc-ai-badge::after {
    transform: rotate(-90deg);
}

.lctc-chatbot-container.collapsed .lctc-chatbot-content {
    display: none;
}

.lctc-ai-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.lctc-chatbot-content {
    padding: 20px;
    min-height: 120px;
    position: relative;
}

.lctc-chatbot-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #666;
}

.lctc-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.lctc-chatbot-response {
    line-height: 1.6;
    color: #333;
    font-size: 15px;
}

.lctc-chatbot-response h4 {
    color: #2c3e50;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 16px;
}

.lctc-chatbot-response p {
    margin-bottom: 12px;
}

.lctc-chatbot-response ul, .lctc-chatbot-response ol {
    margin: 12px 0;
    padding-left: 24px;
}

.lctc-chatbot-response li {
    margin-bottom: 6px;
}

.lctc-chatbot-controls {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 12px;
    align-items: center;
}

.lctc-regenerate-btn, .lctc-show-original-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lctc-regenerate-btn {
    background: #2196F3;
    color: white;
}

.lctc-regenerate-btn:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

.lctc-regenerate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.lctc-show-original-btn {
    background: #6c757d;
    color: white;
}

.lctc-show-original-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.lctc-chatbot-error {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    color: #856404;
    text-align: center;
}

.lctc-chatbot-error .retry-btn {
    background: #ffc107;
    color: #212529;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    margin-top: 12px;
    cursor: pointer;
    font-weight: 500;
}

.lctc-chatbot-error .retry-btn:hover {
    background: #e0a800;
}

/* Block-specific styling */
.lctc-ai-notes {
    border-left-color: #2196F3 !important;
}

.lctc-ai-notes .lctc-ai-badge {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
}

.lctc-ai-translation {
    border-left-color: #4CAF50 !important;
}

.lctc-ai-translation .lctc-ai-badge {
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
}

.lctc-ai-related {
    border-left-color: #9C27B0 !important;
}

.lctc-ai-related .lctc-ai-badge {
    background: linear-gradient(135deg, #9C27B0 0%, #7B1FA2 100%);
}

/* Responsive design */
@media (max-width: 768px) {
    .lctc-chatbot-container {
        margin: 16px 0;
    }
    
    .lctc-ai-badge {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .lctc-chatbot-content {
        padding: 16px;
    }
    
    .lctc-chatbot-controls {
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    
    .lctc-regenerate-btn, .lctc-show-original-btn {
        font-size: 13px;
        padding: 6px 12px;
    }
}

/* Animation for content loading */
.lctc-chatbot-content.loading {
    opacity: 0.7;
}

.lctc-chatbot-content.loaded {
    animation: fadeIn 0.5s ease;
}

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

/* Success state */
.lctc-chatbot-success {
    border-left: 4px solid #28a745;
}

.lctc-chatbot-success .lctc-ai-badge::after {
    content: '✓';
    margin-left: auto;
    font-size: 18px;
}

/* Integration with existing LCTC styles */
.lctc-scripture .lctc-chatbot-container {
    max-width: 100%;
}

/* Dark mode support (if theme supports it) */
@media (prefers-color-scheme: dark) {
    .lctc-chatbot-container {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .lctc-chatbot-response {
        color: #e2e8f0;
    }
    
    .lctc-chatbot-response h4 {
        color: #f7fafc;
    }
    
    .lctc-chatbot-controls {
        background: #1a202c;
        border-top-color: #4a5568;
    }
}


/* Error and timeout states */
.lctc-chatbot-error-state {
    border-left: 4px solid #dc3545;
}

.lctc-chatbot-timeout-state {
    border-left: 4px solid #fd7e14;
}

.lctc-chatbot-fallback {
    border-left: 4px solid #6c757d;
}

.lctc-chatbot-error, .lctc-chatbot-timeout {
    padding: 20px;
    border-radius: 6px;
    text-align: center;
}

.lctc-chatbot-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.lctc-chatbot-timeout {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.lctc-error-actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.retry-btn, .fallback-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.retry-btn {
    background: #dc3545;
    color: white;
}

.retry-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.fallback-btn {
    background: #6c757d;
    color: white;
}

.fallback-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Fallback content styling */
.lctc-fallback-content {
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    color: #495057;
}

.lctc-fallback-content h4 {
    color: #343a40;
    margin-bottom: 12px;
    font-size: 16px;
}

.lctc-fallback-content p {
    margin-bottom: 10px;
    line-height: 1.5;
}

.lctc-fallback-content em {
    color: #6c757d;
    font-style: italic;
}

/* Debug information styling */
.lctc-debug-info {
    margin-top: 12px;
    font-size: 12px;
}

.lctc-debug-info summary {
    cursor: pointer;
    padding: 4px 8px;
    background: #e9ecef;
    border-radius: 4px;
    margin-bottom: 8px;
}

.lctc-debug-info summary:hover {
    background: #dee2e6;
}

.lctc-debug-info pre {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    border: 1px solid #dee2e6;
    max-height: 200px;
    overflow-y: auto;
}

/* Loading state improvements */
.lctc-chatbot-loading p {
    margin-top: 8px;
    font-size: 14px;
    color: #6c757d;
}

/* Responsive adjustments for error states */
@media (max-width: 768px) {
    .lctc-error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .retry-btn, .fallback-btn {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
    
    .lctc-fallback-content {
        padding: 16px;
    }
    
    .lctc-debug-info pre {
        font-size: 10px;
        padding: 6px;
    }
}

/* Animation for error states */
.lctc-chatbot-error-state, .lctc-chatbot-timeout-state {
    animation: errorPulse 0.5s ease;
}

@keyframes errorPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Accessibility improvements */
.retry-btn:focus, .fallback-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.lctc-debug-info summary:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Dark mode support for new elements */
@media (prefers-color-scheme: dark) {
    .lctc-chatbot-error {
        background: #2d1b1f;
        border-color: #842029;
        color: #ea868f;
    }
    
    .lctc-chatbot-timeout {
        background: #2d2a1f;
        border-color: #664d03;
        color: #ffda6a;
    }
    
    .lctc-fallback-content {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .lctc-fallback-content h4 {
        color: #f7fafc;
    }
    
    .lctc-debug-info summary {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .lctc-debug-info summary:hover {
        background: #2d3748;
    }
    
    .lctc-debug-info pre {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
}
