/* ===========================
   Policy Library Page Styles
   =========================== */

/* Library Header */
.library-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: calc(72px + 4rem) 0 4rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.library-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    pointer-events: none;
}

.library-title {
    font-size: 3rem;
    font-weight: 800;
    color: white;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.library-subtitle {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
    z-index: 1;
}

/* Main Library Section */
.library-main {
    padding: 3rem 0;
    min-height: calc(100vh - 400px);
}

.library-header-section {
    margin-bottom: 2rem;
}

/* Search Container */
.search-container {
    max-width: 700px;
    margin: 0 auto 2rem;
    position: relative;
}

.search-box-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    color: #94a3b8;
    pointer-events: none;
    z-index: 2;
}

.search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 3.5rem;
    font-size: 1rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    color: #1e293b;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-input::placeholder {
    color: #94a3b8;
}

.search-clear {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    padding: 0.5rem;
    color: #94a3b8;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 2;
}

.search-input:not(:placeholder-shown) ~ .search-clear {
    opacity: 1;
}

.search-clear:hover {
    color: #64748b;
}

/* Search Suggestions */
.search-suggestions {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 100;
}

.search-suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f1f5f9;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: #f8fafc;
}

.suggestion-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.suggestion-meta {
    font-size: 0.875rem;
    color: #64748b;
}

/* Filter Tabs */
.filter-tabs {
    margin-bottom: 2rem;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: white;
    border: 1.5px solid #e2e8f0;
    border-radius: 100px;
    color: #64748b;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
    line-height: 1.3;
}

.filter-chip:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.filter-chip.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.filter-chip.active .chip-dot {
    background: rgba(255, 255, 255, 0.6);
}

.chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chip--climate .chip-dot   { background: #166534; }
.chip--economy .chip-dot   { background: #92400e; }
.chip--health .chip-dot    { background: #991b1b; }
.chip--education .chip-dot { background: #1e40af; }
.chip--technology .chip-dot { background: #3730a3; }
.chip--security .chip-dot  { background: #6b21a8; }
.chip--government .chip-dot { background: #854d0e; }
.chip--history .chip-dot   { background: #78350f; }

.results-count {
    text-align: center;
    color: #64748b;
    font-size: 0.95rem;
}

.results-count strong {
    color: #1e293b;
    font-weight: 700;
}

/* Library Layout */
/* Note: sidebar is currently commented out, so using single column */
.library-layout {
    display: block;
}

/* Sidebar */
.library-sidebar {
    position: sticky;
    top: 100px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section:last-of-type {
    margin-bottom: 1.5rem;
}

.sidebar-section h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sort-select {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: #1e293b;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.sort-select:focus {
    outline: none;
    border-color: #667eea;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.75rem;
    cursor: pointer;
    accent-color: #667eea;
}

.checkbox-label {
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.4;
}

.filter-checkbox:hover .checkbox-label {
    color: #1e293b;
}

.clear-filters {
    width: 100%;
    padding: 0.75rem;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.clear-filters:hover {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

/* Library Grid */
.library-content {
    min-height: 600px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Loading State */
.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1.5rem;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-state p {
    color: #64748b;
    font-size: 1.1rem;
}

/* Document Card */
.document-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.75rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.document-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px);
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.doc-topic-badge {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.doc-topic-badge.badge--climate {
    background: #dcfce7;
    color: #166534;
}

.doc-topic-badge.badge--economy {
    background: #fef3c7;
    color: #92400e;
}

.doc-topic-badge.badge--health {
    background: #fee2e2;
    color: #991b1b;
}

.doc-topic-badge.badge--education {
    background: #dbeafe;
    color: #1e40af;
}

.doc-topic-badge.badge--technology {
    background: #e0e7ff;
    color: #3730a3;
}

.doc-topic-badge.badge--security {
    background: #f3e8ff;
    color: #6b21a8;
}

.doc-topic-badge.badge--government {
    background: #fef9c3;
    color: #854d0e;
}

.doc-topic-badge.badge--history {
    background: #f5f0e6;
    color: #78350f;
}

.doc-year {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 600;
}

.doc-title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    flex-grow: 0;
}

.doc-title a {
    color: #1e293b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.doc-title a:hover {
    color: #667eea;
}

.doc-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #64748b;
}

.doc-org {
    font-weight: 600;
}

.doc-separator {
    color: #cbd5e1;
}

.doc-pages {
    color: #94a3b8;
}

.doc-excerpt {
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
    flex-grow: 1;
    /* Only truncate very long excerpts (6+ lines) */
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc-stats {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 0;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 1.25rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-icon {
    font-size: 1.125rem;
}

.stat-value {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.95rem;
}

.stat-label {
    color: #94a3b8;
    font-size: 0.8rem;
}

.doc-actions {
    display: flex;
    gap: 0.75rem;
}

.series-editions + .doc-actions {
    margin-top: 1rem;
}

/* Series Card Styles */
.series-card {
    position: relative;
}

.doc-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.series-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
}

/* Series Editions Floating Popup */
.series-editions {
    position: relative;
}

.series-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.series-toggle:hover {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.series-editions.expanded .toggle-icon {
    transform: rotate(180deg);
}

/* Previous Editions List - Floating Popup */
.editions-list {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 0.5rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.series-editions.expanded .editions-list {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.prev-edition-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.prev-edition-item + .prev-edition-item {
    margin-top: 0.25rem;
}

.prev-edition-item:hover {
    background: #f1f5f9;
    transform: translateX(4px);
}

.prev-edition-item:hover svg {
    color: #667eea;
}

.prev-edition-year {
    flex-shrink: 0;
    padding: 0.25rem 0.5rem;
    background: #e2e8f0;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
}

.prev-edition-title {
    flex: 1;
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.4;
}

.prev-edition-item svg {
    flex-shrink: 0;
    color: #94a3b8;
    transition: color 0.2s ease;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn--primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex: 1;
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn--secondary {
    background: white;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.btn--secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

.btn--sm {
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
}

.btn--icon {
    padding: 0.65rem;
    width: auto;
    flex: 0;
}

/* Load More */
.load-more-container {
    text-align: center;
    padding: 2rem 0;
}

.load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2.5rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    color: #475569;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-more-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.load-more-btn svg {
    transition: transform 0.2s ease;
}

.load-more-btn:hover svg {
    transform: translateY(2px);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-close:hover {
    background: #f8fafc;
    transform: scale(1.1);
}

.modal-body {
    padding: 2.5rem;
    overflow-y: auto;
    max-height: 85vh;
}

/* Footer */
.footer {
    background: #0f172a;
    color: #cbd5e1;
    padding: 4rem 0 2rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2.5rem;
    margin-bottom: 2.5rem;
}

.footer-section h3 {
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.footer-section h4 {
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-section p {
    color: #94a3b8;
    line-height: 1.7;
    font-size: 0.95rem;
}

.footer-section a {
    display: block;
    color: #cbd5e1;
    text-decoration: none;
    margin-bottom: 0.75rem;
    transition: color 0.2s ease;
    font-size: 0.95rem;
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    padding-top: 2rem;
    border-top: 1px solid #334155;
    text-align: center;
}

.footer-bottom p {
    color: #94a3b8;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .library-title {
        font-size: 2.25rem;
    }

    .library-subtitle {
        font-size: 1.1rem;
    }

    .search-input {
        font-size: 0.95rem;
        padding: 0.875rem 2.5rem 0.875rem 3rem;
    }

    .library-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .filter-chips {
        gap: 0.375rem;
    }

    .filter-chip {
        padding: 0.4rem 0.75rem;
        font-size: 0.8125rem;
    }

    .chip-dot {
        width: 6px;
        height: 6px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 480px) {
    .library-header {
        padding: calc(72px + 2.5rem) 0 2.5rem;
    }

    .library-title {
        font-size: 1.875rem;
    }

    .library-subtitle {
        font-size: 1rem;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-body {
        padding: 2rem 1.5rem;
    }
}
