/* Modern CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #059669;
    --error-color: #dc2626;
    --warning-color: #d97706;
    --background-color: #ffffff;
    --surface-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

/* Reset and Base Styles */
.hadith-search-container * {
    box-sizing: border-box;
}

.hadith-search-container {
    max-width: 800px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
}

/* Search Form */
.hadith-search-form {
    background: var(--background-color);
    padding: 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.hadith-search-form:hover {
    box-shadow: var(--shadow-xl);
}

/* Search Input Container */
.search-input-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.hadith-search-input {
    flex: 1;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    background: var(--surface-color);
    color: var(--text-color);
}

.hadith-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--background-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
    transform: translateY(-1px);
}

.hadith-search-input::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

/* Search Button */
.hadith-search-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.hadith-search-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.hadith-search-button:active {
    transform: translateY(0);
}

.hadith-search-button:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    transform: none;
}

.hadith-search-button svg {
    transition: transform 0.3s ease;
}

.hadith-search-button:hover svg {
    transform: scale(1.1);
}

/* Post Type Selector */
.post-type-selector {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.filter-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-color);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.post-type-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Custom Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    border: 1px solid transparent;
    background: var(--background-color);
}

.checkbox-label:hover {
    background: var(--surface-color);
    border-color: var(--border-color);
    transform: translateY(-1px);
}

.post-type-checkbox {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    position: relative;
    transition: all 0.3s ease;
    background: var(--background-color);
}

.post-type-checkbox:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.post-type-checkbox:checked + .checkmark::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.label-text {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.875rem;
}

/* Search Filters */
.search-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hadith-taxonomy-filter {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-color);
    font-size: 0.875rem;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.hadith-taxonomy-filter:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* Search Options */
.search-options {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.search-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
}

/* Modal Styles */
.hadith-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    background: var(--background-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-color);
    transform: scale(1.1);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    max-height: calc(90vh - 80px);
}

/* Loading Animation */
.hadith-search-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
}

.loading-spinner {
    position: relative;
    width: 60px;
    height: 60px;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-ring:nth-child(2) {
    animation-delay: 0.1s;
    border-top-color: var(--primary-hover);
}

.spinner-ring:nth-child(3) {
    animation-delay: 0.2s;
    border-top-color: var(--secondary-color);
}

.hadith-search-loading p {
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
}

/* Search Results */
.hadith-search-results {
    min-height: 100px;
}

.results-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.results-header p {
    margin: 0;
    font-size: 0.875rem;
}

.hadith-result-item {
    background: var(--background-color);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.hadith-result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
}

.hadith-result-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.result-title {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.4;
}

.result-title a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.result-title a:hover {
    color: var(--primary-color);
}

.result-content {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.result-date {
    font-style: italic;
    background: var(--surface-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.acf-field {
    background: var(--surface-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
}

.acf-field strong {
    color: var(--text-color);
    font-weight: 600;
}

/* No Results and Error States */
.no-results, .search-error {
    text-align: center;
    padding: 3rem 2rem;
    border-radius: var(--radius-lg);
    margin: 2rem 0;
}

.no-results {
    background: var(--surface-color);
    border: 2px dashed var(--border-color);
    color: var(--text-secondary);
}

.search-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--error-color);
}

/* Pagination */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 44px;
}

.page-link:hover {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.page-link.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.page-link.prev, .page-link.next {
    font-weight: 600;
    min-width: auto;
    padding: 0.75rem 1.25rem;
}

.page-dots {
    padding: 0.75rem 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(2rem) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .hadith-search-container {
        margin: 1rem;
    }
    
    .hadith-search-form {
        padding: 1.5rem;
    }
    
    .search-input-container {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .hadith-search-button {
        width: 100%;
        justify-content: center;
    }
    
    .post-type-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .search-filters {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 0.5rem;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 1rem 1.5rem;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .result-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .pagination-wrapper {
        gap: 0.25rem;
    }
    
    .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        min-width: 36px;
    }
}

@media (max-width: 480px) {
    .hadith-search-form {
        padding: 1rem;
    }
    
    .hadith-result-item {
        padding: 1rem;
    }
    
    .result-title {
        font-size: 1rem;
    }
    
    .modal-header {
        padding: 0.75rem 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
}

/* Compact Form Style */
.hadith-search-container[data-style="compact"] .hadith-search-form {
    background: none;
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.hadith-search-container[data-style="compact"] .post-type-checkboxes {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.hadith-search-container[data-style="compact"] .search-filters {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}