/* Rules Library Styles */

.stats-bar {
    display: flex;
    gap: 2rem;
    padding: 1.5rem 0;
    justify-content: center;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Crimson Pro', serif;
    color: var(--primary, #1E40AF);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary, #6B7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Search Section */
.search-section {
    padding: 2rem 0;
    background: var(--surface, #F9FAFB);
    border-radius: 12px;
    margin-bottom: 2rem;
}

.search-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.search-input-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary, #6B7280);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 3rem;
    font-size: 1rem;
    border: 2px solid var(--border, #E5E7EB);
    border-radius: 8px;
    background: white;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary, #1E40AF);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.clear-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary, #6B7280);
    border-radius: 4px;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: var(--surface, #F3F4F6);
    color: var(--text, #111827);
}

.filters-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary, #6B7280);
}

.filter-select {
    padding: 0.75rem;
    font-size: 0.95rem;
    border: 2px solid var(--border, #E5E7EB);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary, #1E40AF);
}

/* Results Section */
.results-section {
    max-width: 1200px;
    margin: 0 auto;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-count {
    font-size: 1rem;
    color: var(--text-secondary, #6B7280);
    font-weight: 500;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--surface, #F3F4F6);
    padding: 0.25rem;
    border-radius: 8px;
}

.view-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary, #6B7280);
    transition: all 0.2s;
}

.view-btn.active,
.view-btn:hover {
    background: white;
    color: var(--primary, #1E40AF);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Results Grid/List */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rule-card {
    background: white;
    border: 1px solid var(--border, #E5E7EB);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.rule-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    border-color: var(--primary, #1E40AF);
}

.rule-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.rule-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-jurisdiction {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-type {
    background: #FEF3C7;
    color: #92400E;
}

.badge-source {
    background: #E0E7FF;
    color: #4338CA;
}

.rule-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text, #111827);
    line-height: 1.4;
}

.rule-card-content {
    font-size: 0.95rem;
    color: var(--text-secondary, #6B7280);
    line-height: 1.6;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rule-card-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.tag {
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    background: var(--surface, #F3F4F6);
    color: var(--text-secondary, #6B7280);
    border-radius: 8px;
}

.rule-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border, #E5E7EB);
}

.view-details-btn {
    font-size: 0.875rem;
    color: var(--primary, #1E40AF);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.view-details-btn:hover {
    color: #1E3A8A;
}

/* Loading & Empty States */
.loading-indicator {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--surface, #E5E7EB);
    border-top-color: var(--primary, #1E40AF);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary, #6B7280);
}

.no-results svg {
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text, #111827);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem 0;
}

.page-info {
    font-size: 0.95rem;
    color: var(--text-secondary, #6B7280);
    font-weight: 500;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border, #E5E7EB);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.5rem;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    color: var(--text-secondary, #6B7280);
}

.close-btn:hover {
    background: var(--surface, #F3F4F6);
    color: var(--text, #111827);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text, #111827);
}

.modal-section p,
.modal-section pre {
    line-height: 1.6;
    color: var(--text-secondary, #6B7280);
}

.examples-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.examples-list li {
    padding: 0.75rem;
    background: var(--surface, #F9FAFB);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-family: 'Crimson Pro', serif;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr;
    }

    .filters-row {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .stats-bar {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}
