:root {
    --tha-navy: #002D72;
    --tha-red: #BA0C2F;
    --tha-gray: #8D8D8D;
    --tha-light-gray: #F5F5F5;
    --white: #FFFFFF;
    --text-dark: #333333;
    --text-light: #666666;
    --border-color: #E0E0E0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

/* FOUC Prevention - Hide page until JavaScript determines what to show */
html {
    visibility: hidden;
}

html.ready {
    visibility: visible;
}

/* Show loading spinner immediately when JavaScript starts */
html.js-loading {
    visibility: visible;
}

html.js-loading .resources-static,
html.js-loading .controls .search-filter-bar,
html.js-loading .stats-bar {
    display: none;
}

html.js-loading .loading-spinner {
    display: flex;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--white);
}

.hero-section {
    background: linear-gradient(135deg, var(--tha-navy) 0%, var(--tha-red) 100%);
    color: var(--white);
    padding: 3rem 1rem;
    text-align: center;
}

.hero-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.tha-logo {
    height: 120px;
    width: auto;
    flex-shrink: 0;
    /* Force white silhouette for external SVG/PNG logos: make image black then invert to white */
    filter: brightness(0) invert(1);
    -webkit-filter: brightness(0) invert(1);
    /* Alternative options (uncomment to try): */
/*    filter: invert(1); */
    /* Pure black silhouette: filter: brightness(0) saturate(100%); */
    /* Black and white high contrast: filter: grayscale(1) contrast(200%); */
}

.hero-text {
    text-align: center;
}

.hero-content h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.hero-content p {
    font-size: clamp(1rem, 3vw, 1.25rem);
    opacity: 0.9;
    max-width: 600px;
    margin: 0;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.controls {
    margin-bottom: 2rem;
}

.search-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.search-container {
    flex: 1;
    min-width: 250px;
}

#searchInput {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

#searchInput:focus {
    outline: none;
    border-color: var(--tha-navy);
    box-shadow: 0 0 0 3px rgba(0, 45, 114, 0.1);
}

.filter-container select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

.filter-container select:focus {
    outline: none;
    border-color: var(--tha-navy);
}

.bulk-actions {
    display: flex;
    gap: 0.5rem;
}

.bulk-download,
.manifest-download {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.bulk-download {
    background: var(--tha-navy);
    color: var(--white);
}

.bulk-download:hover {
    background: #001a4a;
    transform: translateY(-1px);
}

.manifest-download {
    background: var(--white);
    color: var(--tha-navy);
    border: 2px solid var(--tha-navy);
}

.manifest-download:hover {
    background: var(--tha-navy);
    color: var(--white);
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--tha-light-gray);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.file-type-stat {
    background: none;
    border: none;
    color: var(--tha-navy);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
}

.file-type-stat:hover {
    background: var(--tha-navy);
    color: var(--white);
}

.file-type-stat.active {
    background: var(--tha-navy);
    color: var(--white);
    font-weight: 600;
}

.clear-filter-btn {
    background: var(--tha-red);
    color: var(--white);
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
}

.clear-filter-btn:hover {
    background: #a00a29;
}

.resources-section {
    position: relative;
    min-height: 400px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--tha-navy);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    margin-top: 1rem;
    color: var(--text-light);
}

.progress-container {
    width: 100%;
    max-width: 400px;
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--tha-navy) 0%, var(--tha-red) 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 0.25rem;
}

.progress-details {
    font-size: 0.9rem;
    color: var(--text-light);
    text-align: center;
}

.resources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.site-footer {
    background: var(--tha-navy);
    color: var(--white);
    margin-top: 4rem;
    padding: 3rem 1rem 2rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    align-items: start;
}

.footer-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--white);
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.footer-section ul li a:hover {
    color: var(--white);
    text-decoration: underline;
}

.footer-section.contact-info address {
    font-style: normal;
    line-height: 1.6;
}

.footer-section.contact-info address p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.footer-section.contact-info address a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: var(--transition);
}

.footer-section.contact-info address a:hover {
    color: var(--white);
    text-decoration: underline;
}

.social-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: var(--transition);
}

.social-links a:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    transform: translateY(-2px);
}

.social-links svg {
    width: 20px;
    height: 20px;
}

.footer-bottom {
    grid-column: 1 / -1;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 2rem;
    margin-top: 2rem;
    text-align: center;
}

.footer-copyright p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.footer-copyright .built-by {
    font-size: 0.8rem;
    opacity: 0.7;
}

.footer-copyright .built-by a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: var(--transition);
}

.footer-copyright .built-by a:hover {
    color: var(--white);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .hero-header {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    
    .hero-text {
        text-align: center;
    }
    
    .tha-logo {
        height: 60px;
    }
    
    .search-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .bulk-actions {
        justify-content: center;
    }
    
    .stats-bar {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .resources-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .social-links {
        justify-content: center;
    }
}

/* Static HTML fallback styles for healthcare/no-JS environments */
.resources-static {
    display: block; /* Show by default */
}

.js-disabled-notice {
    background: var(--tha-light-gray);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border-left: 4px solid var(--tha-navy);
}

.js-disabled-notice h3 {
    color: var(--tha-navy);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.js-disabled-notice p {
    color: var(--text-dark);
    margin: 0;
    font-size: 1rem;
}

.category-section {
    margin-bottom: 2.5rem;
}

.category-section h3 {
    color: var(--tha-navy);
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--tha-red);
}

.resource-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.resource-list li {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: var(--transition);
}

.resource-list li:hover {
    background: var(--tha-light-gray);
    border-color: var(--tha-navy);
    box-shadow: var(--shadow);
}

.resource-list a {
    color: var(--tha-navy);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
}

.resource-list a:hover {
    color: var(--tha-red);
    text-decoration: underline;
}

.file-meta {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: normal;
    margin-left: 0.5rem;
}

.healthcare-notice {
    background: #e8f4f8;
    border: 1px solid #bee5eb;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 2rem;
    color: var(--text-dark);
}

.healthcare-notice p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Hide static version when JavaScript loads */
body.js-enabled .resources-static {
    display: none;
}

/* Print styles for healthcare documentation */
@media print {
    .hero-section,
    .controls,
    .site-footer {
        display: none;
    }
    
    .resources-static {
        display: block !important;
    }
    
    .category-section {
        page-break-inside: avoid;
        margin-bottom: 1.5rem;
    }
    
    .category-section h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .resource-list li {
        border: none;
        background: none;
        padding: 0.25rem 0;
        margin-bottom: 0.25rem;
    }
    
    .resource-list a {
        color: #000;
        text-decoration: none;
    }
    
    .resource-list a:after {
        content: " - " attr(href);
        font-size: 0.8rem;
        color: #666;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .resource-list li,
    .progress-fill,
    .spinner {
        transition: none;
        animation: none;
    }
}

@media (prefers-contrast: high) {
    .resource-list li {
        border-width: 2px;
    }
    
    .category-section h3 {
        border-bottom-width: 3px;
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: 2rem 1rem;
    }
    
    .hero-header {
        gap: 1rem;
    }
    
    .tha-logo {
        height: 50px;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .bulk-actions {
        flex-direction: column;
    }
    
    .site-footer {
        padding: 2rem 1rem 1.5rem;
    }
    
    .footer-content {
        gap: 1.5rem;
    }
    
    .footer-bottom {
        padding-top: 1.5rem;
        margin-top: 1.5rem;
    }
    
    .social-links a {
        width: 36px;
        height: 36px;
    }
    
    .social-links svg {
        width: 18px;
        height: 18px;
    }
    
    /* Mobile adjustments for static resources */
    .js-disabled-notice {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .category-section h3 {
        font-size: 1.1rem;
    }
    
    .resource-list li {
        padding: 0.5rem;
    }
    
    .resource-list a {
        font-size: 0.95rem;
        display: block;
        margin-bottom: 0.25rem;
    }
    
    .file-meta {
        display: block;
        margin-left: 0;
        font-size: 0.8rem;
    }
}

/* Selective Download Feature Styles */

/* Selection Controls */
.bulk-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.selection-controls {
    display: flex;
    gap: 0.5rem;
}

.selection-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--white);
    color: var(--text-dark);
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.selection-btn:hover {
    background-color: var(--tha-light-gray);
    border-color: var(--tha-gray);
}

.download-actions {
    display: flex;
    gap: 0.5rem;
}

/* Selection Counter */
.selected-count {
    color: var(--tha-navy);
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    background-color: var(--tha-light-gray);
    border-radius: 12px;
    font-size: 0.9rem;
}

/* Resource Card Checkboxes */
.card-selector {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    z-index: 2;
}

.file-selector {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    opacity: 0;
    position: absolute;
}

.selector-label {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    background: var(--white);
}

.selector-label:hover {
    border-color: var(--tha-navy);
}

.file-selector:checked + .selector-label {
    background-color: var(--tha-navy);
    border-color: var(--tha-navy);
}

.file-selector:checked + .selector-label::after {
    content: '✓';
    position: absolute;
    top: -1px;
    left: 2px;
    color: var(--white);
    font-size: 14px;
    font-weight: bold;
}

.resource-card[data-selected="true"] {
    border-color: var(--tha-navy);
    box-shadow: 0 0 0 2px rgba(0, 45, 114, 0.1);
}

/* ZIP Progress Modal */
.zip-progress-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.zip-progress-content {
    background: var(--white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    min-width: 400px;
    max-width: 90vw;
}

.zip-progress-header h3 {
    color: var(--tha-navy);
    margin-bottom: 1.5rem;
    text-align: center;
}

.zip-progress-bar {
    width: 100%;
    height: 12px;
    background-color: var(--tha-light-gray);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.zip-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--tha-navy), var(--tha-red));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 6px;
}

.zip-progress-text {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    text-align: center;
}

.zip-progress-details {
    color: var(--text-light);
    font-size: 0.9rem;
    text-align: center;
}

/* Healthcare Accessibility */
@media (prefers-reduced-motion: reduce) {
    .selection-btn,
    .selector-label,
    .zip-progress-fill {
        transition: none;
    }
}

/* Mobile Responsive Updates */
@media (max-width: 768px) {
    .bulk-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .selection-controls,
    .download-actions {
        justify-content: center;
    }
    
    .zip-progress-content {
        margin: 1rem;
        padding: 1.5rem;
        min-width: unset;
    }
    
    .card-selector {
        top: 0.5rem;
        right: 0.5rem;
    }
}