/**
 * WordPress-specific styles for Sourcebase Search Widget
 * These styles complement the base widget styles
 * Designed to match default WordPress search styling
 */

/* WordPress-specific container styles */
.sourcebase-search-widget {
    margin: 20px 0;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Inherit theme fonts and colors */
.sourcebase-search-widget,
.sourcebase-search-container {
    color: inherit;
}

.sourcebase-search-container {
    width: 100%;
    max-width: 100%;
}

/* Search input group styling - WordPress default search form style */
.sourcebase-search-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sourcebase-search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
    line-height: 1.8;
    background-color: #fff;
    color: #333;
    transition: border-color 0.15s ease-in-out;
    font-family: inherit;
    box-sizing: border-box;
    vertical-align: middle;
}

/* Match WordPress search form padding for better compatibility */
.sourcebase-search-input::placeholder {
    color: #999;
    opacity: 1; /* Firefox fix */
}

.sourcebase-search-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.sourcebase-search-input:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.sourcebase-search-button {
    padding: 10px 20px;
    background-color: #2271b1;
    color: #fff;
    border: 1px solid #2271b1;
    border-radius: 3px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.8;
}

.sourcebase-search-button:hover:not(:disabled) {
    background-color: #135e96;
    border-color: #135e96;
}

.sourcebase-search-button:active:not(:disabled) {
    background-color: #0a4b78;
    border-color: #0a4b78;
}

.sourcebase-search-button:disabled {
    background-color: #a7aaad;
    border-color: #a7aaad;
    cursor: not-allowed;
    opacity: 0.6;
}

.sourcebase-search-button:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Accessibility improvements */
.sourcebase-search-button:focus {
    outline: none;
}

.sourcebase-search-button:focus-visible {
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.3);
}

/* Results container */
.sourcebase-search-results {
    margin-top: 16px;
}

/* Search results styling to match WordPress content */
.sourcebase-search-results h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
}

.sourcebase-search-results p {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.6;
}

/* WordPress widget-specific styles */
.widget .sourcebase-search-widget {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
}

.widget .sourcebase-search-input-group {
    flex-direction: column;
    gap: 8px;
}

.widget .sourcebase-search-input,
.widget .sourcebase-search-button {
    width: 100%;
}

/* Widget title styling to match WordPress */
.widget .sourcebase-search-widget h2,
.widget_title + .sourcebase-search-widget,
.widget_title + .sourcebase-search-input-group {
    margin-top: 16px;
}

/* Responsive design */
@media (max-width: 768px) {
    .sourcebase-search-input-group {
        flex-direction: column;
    }

    .sourcebase-search-input,
    .sourcebase-search-button {
        width: 100%;
    }
}

/* WordPress-like search result markup (minimal styling, inherit theme) */
.sb-wp-search-result {
    padding: 16px 0 16px 16px;
    border-bottom: 1px solid #ddd;
}

.sb-wp-search-result__title {
    font-size: 18px;
    font-weight: 600;
}

.sb-wp-search-result__title a {
    color: var(--wp--preset--color--primary, #2271b1);
    text-decoration: none;
}

.sb-wp-search-result__title a:hover,
.sb-wp-search-result__title a:focus {
    text-decoration: underline;
}

.sb-wp-search-result__excerpt {
    color: #666;
}

/* Dark theme adjustments */
.sourcebase-search-widget[data-theme="dark"] .sb-wp-search-result {
    border-color: #374151;
}

.sourcebase-search-widget[data-theme="dark"] .sb-wp-search-result__title,
.sourcebase-search-widget[data-theme="dark"] .sb-wp-search-result__title a {
    color: #60a5fa;
}

.sourcebase-search-widget[data-theme="dark"] .sb-wp-search-result__excerpt {
    color: #d1d5db;
}

/* Theme variations */
.sourcebase-search-widget[data-theme="dark"] {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
    color: #f9fafb !important;
}

.sourcebase-search-widget[data-theme="dark"] .sourcebase-search-input {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f9fafb !important;
}

.sourcebase-search-widget[data-theme="dark"] .sourcebase-search-input::placeholder {
    color: #9ca3af !important;
}

.sourcebase-search-widget[data-theme="dark"] .sourcebase-search-input:focus {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 1px #60a5fa !important;
}

.sourcebase-search-widget[data-theme="dark"] .sourcebase-search-button {
    background-color: #0073aa !important;
    border-color: #0073aa !important;
    color: #ffffff !important;
}

.sourcebase-search-widget[data-theme="dark"] .sourcebase-search-button:hover:not(:disabled) {
    background-color: #005177 !important;
    border-color: #005177 !important;
}

.sourcebase-search-widget[data-theme="dark"] .sourcebase-search-button:active:not(:disabled) {
    background-color: #003a4d !important;
    border-color: #003a4d !important;
}

/* Ensure all text in dark theme is visible - but not the result items (they have their own styles) */
.sourcebase-search-widget[data-theme="dark"] > h3,
.sourcebase-search-widget[data-theme="dark"] > h4,
.sourcebase-search-widget[data-theme="dark"] > p {
    color: #f9fafb !important;
}

/* Dark theme index numbers */
.sourcebase-search-widget[data-theme="dark"] [style*="color: #"].sourcebase-search-widget > div > div > div:first-child {
    color: #60a5fa !important;
}

/* Dark theme hover states for result items - only target the actual result */
.sourcebase-search-widget[data-theme="dark"] .sb-wp-search-result:hover {
    background-color: #374151 !important;
}

/* Dark theme result description text */
.sourcebase-search-widget[data-theme="dark"] p[style*="color"] {
    color: #d1d5db !important;
}

/* Dark theme media icons */
.sourcebase-search-widget[data-theme="dark"] svg {
    color: #9ca3af !important;
}

.sourcebase-search-widget[data-theme="minimal"] .sourcebase-search-input {
    border: 1px solid #000;
    border-radius: 0;
    background-color: #ffffff;
    color: #000;
}

.sourcebase-search-widget[data-theme="minimal"] .sourcebase-search-input::placeholder {
    color: #666;
}

.sourcebase-search-widget[data-theme="minimal"] .sourcebase-search-input:focus {
    box-shadow: none;
    border-width: 2px;
    border-color: #000;
    outline: none;
}

.sourcebase-search-widget[data-theme="minimal"] .sourcebase-search-button {
    background-color: #000;
    border-color: #000;
    border-radius: 0;
    color: #fff;
}

.sourcebase-search-widget[data-theme="minimal"] .sourcebase-search-button:hover:not(:disabled) {
    background-color: #333;
    border-color: #333;
}

.sourcebase-search-widget[data-theme="minimal"] .sourcebase-search-button:active:not(:disabled) {
    background-color: #4a4a4a;
    border-color: #4a4a4a;
}

/* WordPress admin styles */
.sourcebase-search-widget-info {
    margin-top: 30px;
    padding: 20px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.sourcebase-search-widget-info h2 {
    margin-top: 0;
    color: #23282d;
}

.sourcebase-search-widget-info h3 {
    color: #0073aa;
    margin-bottom: 10px;
}

.sourcebase-search-widget-info code {
    background-color: #f1f1f1;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: Consolas, Monaco, monospace;
}

.sourcebase-search-widget-info pre {
    background-color: #f1f1f1;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    border: 1px solid #ddd;
}

.sourcebase-search-widget-info pre code {
    background: none;
    padding: 0;
}

/* Loading states */
.sourcebase-search-widget.loading .sourcebase-search-button {
    position: relative;
    color: transparent;
}

.sourcebase-search-widget.loading .sourcebase-search-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: sourcebase-spin 1s linear infinite;
}

@keyframes sourcebase-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error states */
.sourcebase-search-widget.error .sourcebase-search-input {
    border-color: #ef4444;
}

.sourcebase-search-widget.error .sourcebase-search-input:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Success states */
.sourcebase-search-widget.success .sourcebase-search-input {
    border-color: #10b981;
}

.sourcebase-search-widget.success .sourcebase-search-input:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}
