/* BOINC Stats - Modern Static Site Styles */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #3b82f6;
        --primary-dark: #2563eb;
        --bg: #0f172a;
        --bg-card: #1e293b;
        --text: #f1f5f9;
        --text-muted: #94a3b8;
        --border: #334155;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.logo:hover {
    text-decoration: none;
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-muted);
    font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    text-decoration: none;
}

/* Main Content */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

section {
    margin-bottom: 2.5rem;
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}

h3 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header p {
    color: var(--text-muted);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 1rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

/* Search */
.search-container {
    display: flex;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto 1rem;
}

#search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
}

#search-input:focus {
    outline: none;
    border-color: var(--primary);
}

#search-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

#search-btn:hover {
    background: var(--primary-dark);
}

.search-results {
    max-width: 600px;
    margin: 0 auto;
    text-align: left;
}

.search-result-item {
    display: block;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    transition: border-color 0.2s;
}

.search-result-item:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.search-result-name {
    font-weight: 600;
    color: var(--text);
}

.search-result-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card.highlight {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(37, 99, 235, 0.05) 100%);
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}

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

.stat-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.project-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.project-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.project-card h3 {
    color: var(--text);
    margin-bottom: 0.5rem;
}

.project-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:hover {
    background: rgba(37, 99, 235, 0.02);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.projects-table-container {
    overflow-x: auto;
}

/* Badges */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.badge-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: border-color 0.2s;
}

.badge-card:hover {
    border-color: var(--primary);
}

.badge-card img {
    max-width: 64px;
    max-height: 64px;
    margin-bottom: 0.5rem;
}

.badge-name {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.badge-project {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 0.5rem;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* User Header */
.user-header {
    margin-bottom: 2rem;
}

.cpid {
    color: var(--text-muted);
}

.cpid code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.875rem;
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

/* Footer */
footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer p {
    margin-bottom: 0.5rem;
}

footer a {
    color: var(--text-muted);
}

footer a:hover {
    color: var(--primary);
}

.footer-about {
    max-width: 700px;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

.footer-support {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.footer-support-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}

.footer-support-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.footer-support-btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.footer-support-btn.github-sponsors {
    background: #db61a2;
    color: white;
}

.footer-support-btn.github-sponsors:hover {
    background: #c9508e;
}

.footer-support-btn.buymeacoffee {
    background: #ffdd00;
    color: #000000;
}

.footer-support-btn.buymeacoffee:hover {
    background: #e5c700;
}

.footer-meta {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.footer-meta p {
    margin-bottom: 0.25rem;
}

@media (max-width: 480px) {
    .footer-support {
        flex-direction: column;
        align-items: center;
    }
    
    .footer-support-btn {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
}

/* Utility */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 1rem;
    border-radius: var(--radius);
}

.hidden {
    display: none !important;
}

/* Loading States - Skeleton Animation */
@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

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

.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1em;
    width: 60%;
    display: inline-block;
    vertical-align: middle;
}

.skeleton-text.short {
    width: 30%;
}

.skeleton-text.medium {
    width: 50%;
}

.skeleton-text.full {
    width: 100%;
}

/* Loading indicator for stat cards */
.stat-card.is-loading .stat-value {
    color: transparent;
    position: relative;
}

.stat-card.is-loading .stat-value::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 4px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

.loading-spinner.large {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* Loading overlay for sections */
.section-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
    gap: 1rem;
}

.section-loading-text {
    font-size: 0.875rem;
}

/* Table loading skeleton */
.table-skeleton {
    width: 100%;
}

.table-skeleton-row {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.table-skeleton-row:last-child {
    border-bottom: none;
}

.table-skeleton-cell {
    flex: 1;
    height: 1.25rem;
    background: var(--border);
    border-radius: 4px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.table-skeleton-cell:first-child {
    flex: 0 0 50px;
}

.table-skeleton-cell:nth-child(2) {
    flex: 2;
}

/* Card loading skeleton */
.card-skeleton {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.card-skeleton-title {
    height: 1.25rem;
    width: 70%;
    background: var(--border);
    border-radius: 4px;
    margin-bottom: 0.75rem;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.card-skeleton-text {
    height: 1rem;
    width: 50%;
    background: var(--border);
    border-radius: 4px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Loading state for data grids */
.projects-grid.is-loading,
.countries-grid.is-loading,
.badges-grid.is-loading {
    display: grid;
}

.projects-grid.is-loading .card-skeleton,
.countries-grid.is-loading .card-skeleton {
    min-height: 100px;
}

/* Charts */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.chart-container h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.chart-wrapper {
    position: relative;
    height: 300px;
}

.chart-wrapper.pie-chart {
    height: 350px;
    max-width: 500px;
    margin: 0 auto;
}

.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

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

/* Countries Grid */
.countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.country-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.country-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.country-card h3 {
    color: var(--text);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.country-flag {
    font-size: 1.5rem;
}

.country-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.country-rank {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

/* About Page */
.about-header {
    text-align: center;
    margin-bottom: 2rem;
}

.about-subtitle {
    color: var(--text-muted);
    font-size: 1.125rem;
}

.about-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.about-section h2 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.about-section p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.about-section p:last-child {
    margin-bottom: 0;
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.feature-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.feature-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* API Examples */
.api-example {
    margin-top: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.api-example h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.api-example pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

.api-example code {
    color: var(--text);
}

/* Donation Buttons */
.donation-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0;
}

.donation-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}

.donation-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.donation-btn svg {
    flex-shrink: 0;
}

.donation-btn.github-sponsors {
    background: #db61a2;
    color: white;
}

.donation-btn.github-sponsors:hover {
    background: #c9508e;
}

.donation-btn.buymeacoffee {
    background: #ffdd00;
    color: #000000;
}

.donation-btn.buymeacoffee:hover {
    background: #e5c700;
}

/* Crypto Donation */
.crypto-donation {
    margin-top: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.crypto-donation h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.crypto-address {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.crypto-label {
    font-weight: 600;
    color: var(--text);
}

.crypto-value {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    color: var(--text);
    word-break: break-all;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .search-container {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .chart-wrapper {
        height: 250px;
    }

    .about-section {
        padding: 1.25rem;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    .donation-options {
        flex-direction: column;
    }

    .donation-btn {
        justify-content: center;
    }

    .crypto-address {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-links {
        gap: 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .projects-grid,
    .countries-grid {
        grid-template-columns: 1fr;
    }

    .badges-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
