/* References Page - Premium Styling */

:root {
    --primary-color: #3f9940;
    --secondary-color: #1e447f;
    --primary-dark: #2c6d2d;
    --ref-card-bg: #ffffff;
    --ref-card-hover: #f8fafc;
    --ref-border: #e2e8f0;
    --ref-shadow: rgba(0, 0, 0, 0.05);
    --ref-shadow-hover: rgba(0, 0, 0, 0.1);

    /* Category Colors */
    --cat-residential: #10b981;
    --cat-commercial: #3b82f6;
    --cat-industrial: #f59e0b;
    --cat-education: #8b5cf6;
    --cat-agriculture: #84cc16;
    --cat-municipal: #06b6d4;
    --cat-other: #64748b;
}

.references-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Search and Filter Section */
.references-controls {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 3rem;
    box-shadow: 0 4px 6px var(--ref-shadow);
}

.search-box {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--ref-border);
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(63, 153, 64, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 1.2rem;
}

/* Category Filters */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.filter-btn {
    padding: 0.625rem 1.25rem;
    border: 2px solid var(--ref-border);
    background: white;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-btn span {
    color: inherit;
    /* Ensure text inherits color from button */
}

.filter-btn:hover {
    border-color: var(--primary-color);
    background: rgba(63, 153, 64, 0.05);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.filter-btn.cat-residential.active {
    background: var(--cat-residential);
    border-color: var(--cat-residential);
}

.filter-btn.cat-commercial.active {
    background: var(--cat-commercial);
    border-color: var(--cat-commercial);
}

.filter-btn.cat-industrial.active {
    background: var(--cat-industrial);
    border-color: var(--cat-industrial);
}

.filter-btn.cat-education.active {
    background: var(--cat-education);
    border-color: var(--cat-education);
}

.filter-btn.cat-agriculture.active {
    background: var(--cat-agriculture);
    border-color: var(--cat-agriculture);
}

.filter-btn.cat-municipal.active {
    background: var(--cat-municipal);
    border-color: var(--cat-municipal);
}

.filter-btn.cat-other.active {
    background: var(--cat-other);
    border-color: var(--cat-other);
}

/* Results Count */
.results-info {
    margin-bottom: 2rem;
    color: #64748b;
    font-size: 1rem;
}

.results-count {
    font-weight: 600;
    color: var(--primary-color);
}

/* References Grid */
.references-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

/* Reference Card */
.reference-card {
    background: var(--ref-card-bg);
    border: 1px solid var(--ref-border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.reference-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.reference-card:hover {
    background: var(--ref-card-hover);
    box-shadow: 0 8px 16px var(--ref-shadow-hover);
    transform: translateY(-2px);
}

.reference-card:hover::before {
    transform: scaleY(1);
}

/* Category Badge */
.category-badge {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
    align-self: flex-start;
}

.category-badge.residential {
    background: rgba(16, 185, 129, 0.1);
    color: var(--cat-residential);
}

.category-badge.commercial {
    background: rgba(59, 130, 246, 0.1);
    color: var(--cat-commercial);
}

.category-badge.industrial {
    background: rgba(245, 158, 11, 0.1);
    color: var(--cat-industrial);
}

.category-badge.education {
    background: rgba(139, 92, 246, 0.1);
    color: var(--cat-education);
}

.category-badge.agriculture {
    background: rgba(132, 204, 22, 0.1);
    color: var(--cat-agriculture);
}

.category-badge.municipal {
    background: rgba(6, 182, 212, 0.1);
    color: var(--cat-municipal);
}

.category-badge.other {
    background: rgba(100, 116, 139, 0.1);
    color: var(--cat-other);
}

/* Reference Title */
.reference-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Reference Location */
.reference-location {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.location-icon {
    font-size: 1rem;
}

/* PDF Download Button */
.pdf-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white !important;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    margin-top: auto;
    width: 100%;
    box-shadow: 0 10px 30px rgba(30, 68, 127, 0.15);
}

.pdf-download-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(30, 68, 127, 0.22);
    filter: brightness(1.05);
    color: white !important;
}

.pdf-download-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(30, 68, 127, 0.2);
}

.pdf-download-btn:focus-visible {
    outline: 2px solid rgba(63, 153, 64, 0.4);
    outline-offset: 3px;
}

.pdf-download-btn span {
    color: white !important;
}

.pdf-icon {
    font-size: 1.1rem;
    color: white !important;
}

/* No Results Message */
.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: #64748b;
    grid-column: 1 / -1;
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.no-results-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.no-results-text {
    font-size: 1rem;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--primary-color);
    grid-column: 1 / -1;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(63, 153, 64, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

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

.pagination-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ref-border);
    background: white;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #64748b;
    font-weight: 500;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
}

.pagination-ellipsis {
    color: #94a3b8;
    padding: 0 0.25rem;
}

/* Modal */
.pdf-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pdf-modal.active {
    display: flex;
    opacity: 1;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.pdf-modal-content {
    background: white;
    width: 90%;
    max-width: 1000px;
    height: 90vh;
    border-radius: 1rem;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--ref-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0.25rem;
    line-height: 1;
}

.close-modal:hover {
    color: #dc2626;
}

.modal-body {
    flex: 1;
    background: #f8fafc;
    position: relative;
}

.pdf-frame {
    width: 100%;
    height: 100%;
    border: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .references-grid {
        grid-template-columns: 1fr;
        /* Full width on mobile */
        gap: 1.5rem;
    }

    .category-filters {
        gap: 0.5rem;
    }

    .filter-btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
        flex: 1 1 auto;
        /* Grow to fill space */
        justify-content: center;
    }

    .references-controls {
        padding: 1.5rem;
    }

    .pdf-modal.active {
        padding: 0;
    }

    .pdf-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .reference-card {
        padding: 1.25rem;
    }

    .reference-title {
        font-size: 1rem;
    }
}
