/**
 * WordPress AI Documentation Search - Frontend Styles
 */

/* Additional frontend styles that can't be inlined */

.wp-ai-docs-search-overlay * {
    box-sizing: border-box;
}

/* Enhanced scrollbar styling for search results */
.wp-ai-docs-search-results::-webkit-scrollbar {
    width: 6px;
}

.wp-ai-docs-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.wp-ai-docs-search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.wp-ai-docs-search-results::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Focus styles for accessibility */
.wp-ai-docs-search-modal *:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.wp-ai-docs-search-modal button:focus {
    outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wp-ai-docs-search-modal {
        border: 2px solid #000;
    }
    
    .search-input-container {
        border-width: 3px;
    }
    
    .search-result-item {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wp-ai-docs-search-overlay,
    .wp-ai-docs-search-modal,
    .loading-spinner {
        animation: none !important;
        transition: none !important;
    }
    
    #wp-ai-docs-trigger-btn {
        transition: none !important;
    }
}

/* Print styles */
@media print {
    .wp-ai-docs-search-trigger,
    .wp-ai-docs-search-overlay {
        display: none !important;
    }
}

/* Custom properties for theming */
:root {
    --wp-ai-docs-primary-color: #007cba;
    --wp-ai-docs-primary-dark: #005a87;
    --wp-ai-docs-background: #ffffff;
    --wp-ai-docs-text: #2c3e50;
    --wp-ai-docs-border: #e1e5e9;
    --wp-ai-docs-shadow: rgba(0, 0, 0, 0.1);
}

/* Error field styling */
.wp-ai-docs-search-form input.error,
.wp-ai-docs-search-form select.error,
.wp-ai-docs-search-form textarea.error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1) !important;
}

/* Loading states for individual components */
.wp-ai-docs-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Tooltip styles for trigger button */
.wp-ai-docs-search-trigger::after {
    content: attr(title);
    position: absolute;
    bottom: 70px;
    right: 50%;
    transform: translateX(50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

.wp-ai-docs-search-trigger:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Animations for result items */
.search-result-item {
    animation: wp-ai-docs-slideUp 0.3s ease-out;
}

.search-result-item:nth-child(2) {
    animation-delay: 0.1s;
}

.search-result-item:nth-child(3) {
    animation-delay: 0.2s;
}

.search-result-item:nth-child(4) {
    animation-delay: 0.3s;
}

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

/* Enhanced AI response styling */
.ai-response {
    position: relative;
}

.ai-response::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, #007cba, #00a0d6);
    border-radius: 10px;
    z-index: -1;
    opacity: 0.1;
}

.ai-response-content code {
    background: rgba(0, 124, 186, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
}

.ai-response-content pre {
    background: rgba(0, 124, 186, 0.05);
    border: 1px solid rgba(0, 124, 186, 0.2);
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
    margin: 10px 0;
}

.ai-response-content blockquote {
    border-left: 3px solid #007cba;
    margin: 10px 0;
    padding: 10px 15px;
    background: rgba(0, 124, 186, 0.05);
    font-style: italic;
}

/* Search suggestions (if implemented) */
.wp-ai-docs-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e1e5e9;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
}

.wp-ai-docs-suggestion {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.wp-ai-docs-suggestion:hover,
.wp-ai-docs-suggestion.active {
    background: #f8f9fa;
}

.wp-ai-docs-suggestion:last-child {
    border-bottom: none;
}

/* Status indicators */
.wp-ai-docs-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
}

.wp-ai-docs-status.success {
    color: #28a745;
}

.wp-ai-docs-status.error {
    color: #dc3545;
}

.wp-ai-docs-status.warning {
    color: #ffc107;
}

.wp-ai-docs-status-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: currentColor;
}

/* Enhanced search result styling */
.search-result-item {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.search-result-item:hover {
    border-color: #007cba;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.15);
    transform: translateY(-1px);
}

.search-result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.search-result-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    text-decoration: none;
    margin: 0;
    flex: 1;
    line-height: 1.3;
}

.search-result-title:hover {
    color: #007cba;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
}

.search-result-category {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-category.setup {
    background: #e3f2fd;
    color: #1976d2;
}

.search-result-category.security {
    background: #fff3e0;
    color: #f57c00;
}

.search-result-category.wordpress {
    background: #f3e5f5;
    color: #7b1fa2;
}

.search-result-category.server {
    background: #e8f5e8;
    color: #388e3c;
}

.search-result-category.domain {
    background: #fce4ec;
    color: #c2185b;
}

.search-result-category.backup {
    background: #e0f2f1;
    color: #00695c;
}

.search-result-category.troubleshooting {
    background: #ffebee;
    color: #d32f2f;
}

.search-result-category.general {
    background: #f5f5f5;
    color: #616161;
}

.search-result-relevance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #666;
    font-weight: 500;
}

.relevance-bar {
    width: 30px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.relevance-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.relevance-fill.high {
    background: linear-gradient(90deg, #4caf50, #8bc34a);
}

.relevance-fill.medium {
    background: linear-gradient(90deg, #ff9800, #ffc107);
}

.relevance-fill.low {
    background: linear-gradient(90deg, #f44336, #ff5722);
}

.search-result-excerpt {
    color: #666;
    line-height: 1.5;
    margin: 8px 0 12px;
}

.search-result-excerpt mark.search-highlight {
    background: #fff3cd;
    color: #856404;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 500;
}

.search-result-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
    font-size: 12px;
    color: #888;
}

.search-result-url {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
}

.search-result-url:hover {
    text-decoration: underline;
}

.search-result-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* AI Response enhancements */
.ai-response {
    background: linear-gradient(135deg, #f8f9ff 0%, #fff 100%);
    border: 1px solid #e3e8ff;
    border-left: 4px solid #007cba;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    position: relative;
}

.ai-response-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #2c3e50;
}

.ai-response-icon {
    width: 20px;
    height: 20px;
    background: linear-gradient(45deg, #007cba, #00a0d6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: bold;
}

.ai-response-content {
    line-height: 1.6;
    color: #444;
}

.ai-response-content h1,
.ai-response-content h2,
.ai-response-content h3 {
    color: #2c3e50;
    margin: 16px 0 8px;
}

.ai-response-content h1 {
    font-size: 20px;
}

.ai-response-content h2 {
    font-size: 18px;
}

.ai-response-content h3 {
    font-size: 16px;
}

.ai-response-content ul,
.ai-response-content ol {
    padding-left: 20px;
    margin: 12px 0;
}

.ai-response-content li {
    margin: 4px 0;
}

.ai-response-content a {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.ai-response-content a:hover {
    border-bottom-color: #007cba;
}

.ai-confidence {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #666;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* Results summary */
.search-results-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #666;
}

.results-count {
    font-weight: 600;
    color: #2c3e50;
}

.search-type-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e8f4f8;
    color: #0066cc;
    font-weight: 500;
}

.search-type-indicator.ai {
    background: linear-gradient(45deg, #e3f2fd, #f3e5f5);
    color: #7b1fa2;
}

/* No results state */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.no-results-icon {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 16px;
}

.no-results h3 {
    color: #2c3e50;
    margin-bottom: 8px;
}

.no-results p {
    margin-bottom: 16px;
    line-height: 1.5;
}

.search-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.suggestion-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #f0f0f0;
    color: #666;
    border-radius: 16px;
    font-size: 12px;
    text-decoration: none;
    transition: all 0.2s;
}

.suggestion-tag:hover {
    background: #007cba;
    color: white;
}

/* Enhanced mobile responsiveness */
@media (max-width: 480px) {
    .wp-ai-docs-search-overlay {
        padding: 5px;
    }
    
    .wp-ai-docs-search-header {
        padding: 16px 20px 12px;
    }
    
    .wp-ai-docs-search-header h3 {
        font-size: 16px;
    }
    
    .wp-ai-docs-search-body {
        padding: 20px 16px;
    }
    
    .search-input-container {
        padding: 10px 12px;
    }
    
    #wp-ai-docs-search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .search-result-header {
        padding: 10px 12px;
    }
    
    .search-result-content {
        padding: 12px;
    }
}

/* Focus trap for modal accessibility */
.wp-ai-docs-search-modal.focus-trapped {
    /* Styles for when focus trap is active */
}
