/* Unified RAG System Styles */

/* Ask AI Button */
.ask-ai-button.unified-rag {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.ask-ai-button.unified-rag:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.ask-ai-button.unified-rag:active {
    transform: translateY(0);
}

.ask-ai-button.unified-rag svg {
    transition: transform 0.3s ease;
}

.ask-ai-button.unified-rag:hover svg {
    transform: scale(1.1);
}

/* Button Container */
.rag-button-container {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 10px 0;
}

/* Floating Button Container */
.rag-button-container[style*="position: fixed"] {
    margin: 0;
    padding: 0;
}

/* Floating Button Styles */
.rag-button-container[style*="position: fixed"] .ask-ai-button.unified-rag {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    border-radius: 50px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 700;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rag-button-container[style*="position: fixed"] .ask-ai-button.unified-rag:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.5);
}

/* Responsive adjustments for floating button */
@media (max-width: 768px) {
    .rag-button-container[style*="position: fixed"] {
        bottom: 15px !important;
        right: 15px !important;
    }
    
    .rag-button-container[style*="position: fixed"] .ask-ai-button.unified-rag {
        padding: 14px 20px;
        font-size: 14px;
    }
}

/* Overlay and Modal */
.rag-search-overlay.unified-rag {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

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

/* AI-Generated Answer Styles */
.ai-generated-answer {
    background: linear-gradient(135deg, #f8faff 0%, #e8f2ff 100%);
    border: 2px solid #667eea;
    border-radius: 16px;
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.15);
    animation: slideInFromTop 0.5s ease-out;
}

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

.answer-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 24px;
    position: relative;
    overflow: hidden;
}

.answer-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.answer-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.ai-icon {
    font-size: 24px;
    animation: pulse 2s infinite;
}

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

.answer-title h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    flex: 1;
}

.confidence-indicator {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.confidence-indicator.high {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #dcfce7;
}

.confidence-indicator.medium {
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.4);
    color: #fef3c7;
}

.confidence-indicator.low {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fee2e2;
}

.search-type-badge {
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
}

.answer-content {
    padding: 24px;
    font-size: 16px;
    line-height: 1.7;
    color: #374151;
    background: white;
}

.answer-content p {
    margin: 0 0 16px 0;
}

.answer-content p:last-child {
    margin-bottom: 0;
}

.answer-content strong {
    color: #1f2937;
    font-weight: 600;
}

.answer-content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid #667eea;
    transition: all 0.2s ease;
    font-weight: 500;
}

.answer-content a:hover {
    color: #764ba2;
    border-bottom-color: #764ba2;
    background: rgba(102, 126, 234, 0.05);
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 4px;
}

.answer-content a:visited {
    color: #8b5cf6;
    border-bottom-color: #8b5cf6;
}

.answer-content .wcag-reference {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.answer-content .html-element {
    background: #f3f4f6;
    color: #374151;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    border: 1px solid #e5e7eb;
}

.answer-footer {
    background: #f8fafc;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
}

.answer-sources {
    margin-bottom: 12px;
    font-size: 14px;
    color: #64748b;
}

.answer-sources strong {
    color: #374151;
    font-weight: 600;
}

.source-tag {
    display: inline-block;
    background: #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px 4px 2px 0;
    border: 1px solid #cbd5e1;
}

.answer-disclaimer {
    color: #64748b;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.results-section-header {
    margin: 32px 0 20px 0;
    padding: 16px 0;
    border-top: 2px solid #e2e8f0;
}

.results-section-header h3 {
    margin: 0 0 8px 0;
    color: #1f2937;
    font-size: 18px;
    font-weight: 600;
}

.results-section-header p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

/* Responsive Design for AI Answer */
@media (max-width: 768px) {
    .ai-generated-answer {
        margin: 0 -8px 20px -8px;
        border-radius: 12px;
    }
    
    .answer-header {
        padding: 16px 20px;
    }
    
    .answer-title h2 {
        font-size: 18px;
    }
    
    .confidence-indicator {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .answer-content {
        padding: 20px;
        font-size: 15px;
    }
    
    .answer-footer {
        padding: 12px 20px;
    }
}

@media (max-width: 480px) {
    .answer-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .confidence-indicator {
        align-self: flex-end;
    }
    
    .ai-icon {
        font-size: 20px;
    }
}

.rag-search-modal.unified-rag {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    position: relative;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Header */
.rag-search-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}

.rag-search-header h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rag-search-header p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

.rag-close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    color: #9ca3af;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.rag-close-button:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Search Controls */
.rag-search-controls {
    padding: 20px 24px;
}

.search-input-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.rag-search-input {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.rag-search-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rag-search-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rag-search-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Search Filters */
.search-filters {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-group label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.data-source-filters {
    display: flex;
    gap: 16px;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal !important;
    cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

.filter-select {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 14px;
}

/* Status */
.rag-search-status {
    padding: 12px 24px;
    font-size: 14px;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

.rag-search-status.error {
    color: #dc2626;
    background: #fef2f2;
}

/* Results Container */
.rag-search-results {
    padding: 0 24px 24px;
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    background: white;
    transition: all 0.2s ease;
}

.search-result-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.result-type {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-type.wcag-issue {
    background: #dbeafe;
    color: #1e40af;
}

.result-type.screen-reader {
    background: #d1fae5;
    color: #065f46;
}

.result-type.generic {
    background: #f3f4f6;
    color: #374151;
}

.relevance-score {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
}

.result-title {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.4;
}

.result-description {
    margin: 0 0 16px 0;
    color: #4b5563;
    line-height: 1.6;
}

.result-details {
    margin-bottom: 16px;
}

.result-details p {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.5;
}

.result-details strong {
    color: #374151;
    font-weight: 600;
}

.tag {
    display: inline-block;
    background: #f3f4f6;
    color: #374151;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 6px;
    margin-bottom: 4px;
}

.result-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.reference-link,
.view-in-table-btn,
.view-support-btn {
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.reference-link {
    background: #667eea;
    color: white;
}

.reference-link:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.view-in-table-btn,
.view-support-btn {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.view-in-table-btn:hover,
.view-support-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.matched-keywords {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
    font-style: italic;
}

.no-results {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 40px 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .rag-search-modal.unified-rag {
        width: 95%;
        margin: 20px;
        max-height: 85vh;
    }
    
    .search-input-container {
        flex-direction: column;
    }
    
    .search-filters {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .data-source-filters {
        flex-direction: column;
        gap: 8px;
    }
    
    .result-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ask-ai-button.unified-rag {
        padding: 10px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .rag-search-header {
        padding: 20px 16px 12px;
    }
    
    .rag-search-controls {
        padding: 16px;
    }
    
    .rag-search-results {
        padding: 0 16px 16px;
    }
    
    .search-result-item {
        padding: 16px;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .rag-search-modal.unified-rag {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .rag-search-header {
        border-bottom-color: #374151;
    }
    
    .rag-search-header h2 {
        color: #f9fafb;
    }
    
    .rag-close-button {
        color: #9ca3af;
    }
    
    .rag-close-button:hover {
        background: #374151;
        color: #f3f4f6;
    }
    
    .rag-search-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .rag-search-input:focus {
        background: #4b5563;
        border-color: #667eea;
    }
    
    .search-filters {
        background: #374151;
        border-color: #4b5563;
    }
    
    .search-result-item {
        background: #374151;
        border-color: #4b5563;
    }
    
    .search-result-item:hover {
        border-color: #667eea;
    }
    
    .result-title {
        color: #f9fafb;
    }
    
    .result-description {
        color: #d1d5db;
    }
    
    .filter-select {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
}