/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Header */
header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

header .subtitle {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* Main Navigation */
.main-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.nav-btn {
    padding: 0.65rem 1.2rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-btn:hover {
    border-color: white;
    background: rgba(255, 255, 255, 0.2);
}

.nav-btn.active {
    background: white;
    color: #2c3e50;
    border-color: white;
}

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

.content-wrapper {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Filters */
.filters {
    margin-bottom: 2rem;
}

.filter-label {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #555;
}

.filter-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.65rem 1.2rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 500;
}

.filter-btn:hover {
    border-color: #2c3e50;
    background: #f9f9f9;
}

.filter-btn.active {
    background: #2c3e50;
    color: white;
    border-color: #2c3e50;
}

/* Table Wrapper for Horizontal Scroll */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 2rem;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

/* Table Styles */
.gainers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.gainers-table thead {
    background-color: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.gainers-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
}

.gainers-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.gainers-table tbody tr {
    transition: background-color 0.2s ease;
}

.gainers-table tbody tr:hover {
    background-color: #fafafa;
}

/* Row Status Coloring */
.gainers-table tr.status-confirmed:hover {
    background-color: #f0f8f5;
}

.gainers-table tr.status-unconfirmed:hover {
    background-color: #fef9f0;
}

/* Column-Specific Styles */
.gainers-table .rank {
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
    width: 70px;
}

.gainers-table .card-name {
    font-weight: 500;
    max-width: 250px;
}

.gainers-table .set-name {
    font-size: 0.9rem;
    color: #666;
    max-width: 200px;
}

.gainers-table .price {
    text-align: right;
    font-weight: 500;
    color: #2c3e50;
}

.gainers-table .percent {
    text-align: right;
    font-weight: 600;
    color: #27ae60;
}

.gainers-table .percent.return-positive {
    color: #27ae60;
}

.gainers-table .percent.return-negative {
    color: #c0392b;
}

.gainers-table .percent.return-neutral {
    color: #666;
}

.gainers-table td.pending {
    text-align: right;
    color: #999;
    font-style: italic;
}

/* Backtest Summary Cards */
.backtest-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.backtest-summary-card {
    flex: 1;
    min-width: 180px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 1rem 1.25rem;
}

.backtest-summary-card h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.backtest-summary-card p {
    font-size: 0.9rem;
    color: #555;
    margin: 0.15rem 0;
}

.gainers-table .status {
    text-align: center;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge.confirmed {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.badge.unconfirmed {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Summary and Footer */
.summary {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
    font-size: 0.9rem;
    color: #666;
}

.no-data {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
    font-size: 1.1rem;
}

.error-box {
    background-color: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
    margin-bottom: 1.5rem;
}

footer {
    text-align: center;
    padding: 2rem 1rem;
    color: #999;
    font-size: 0.9rem;
    border-top: 1px solid #e0e0e0;
    margin-top: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .container {
        padding: 1rem 0.5rem;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .gainers-table th,
    .gainers-table td {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .gainers-table .card-name {
        max-width: 150px;
    }
    
    .gainers-table .set-name {
        max-width: 120px;
    }
    
    .filter-buttons {
        gap: 0.5rem;
    }
    
    .filter-btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.25rem;
    }
    
    .gainers-table th,
    .gainers-table td {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .badge {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }
}

/* Site title link + legal footer text */
.site-title {
    color: inherit;
    text-decoration: none;
}

footer .legal {
    font-size: 0.8rem;
    opacity: 0.75;
    max-width: 760px;
    margin: 8px auto 0;
    line-height: 1.5;
}

/* Phones: keep a small card image; drop rank + printing columns so price
   and % still fit. Printing moves under the set name instead. */
.mobile-printing { display: none; }
.label-short { display: none; }
@media (max-width: 600px) {
    .label-full { display: none; }
    .label-short { display: inline; }
    .gainers-table td.set-name { font-size: 0.72rem; line-height: 1.3; }
    .gainers-table td.percent, .gainers-table td.price { white-space: nowrap; }
    .gainers-table th:nth-child(1), .gainers-table td:nth-child(1),
    .gainers-table th:nth-child(5), .gainers-table td:nth-child(5) {
        display: none;
    }
    .gainers-table td.card-image img {
        width: 36px !important;
        max-width: 36px;
        display: block;
    }
    .gainers-table th:nth-child(2) { font-size: 0; }  /* hide "Image" label, keep the column */
    .mobile-printing {
        display: block;
        font-size: 0.75rem;
        opacity: 0.7;
        margin-top: 2px;
    }
    .gainers-table th, .gainers-table td {
        padding: 8px 3px;
        font-size: 0.8rem;
    }
    .content-wrapper { padding: 0.5rem; }
}

/* Numeric column headers line up with their right-aligned values */
.gainers-table th.num { text-align: right; }

/* Losses read red, not green */
.gainers-table .percent.loss { color: #c0392b; }

/* TCGplayer buy links (affiliate when configured) */
.buy-link {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    color: #2c7be5;
    text-decoration: none;
    white-space: nowrap;
}
.buy-link:hover { text-decoration: underline; }
.buy-button {
    display: inline-block;
    margin: 8px 0 4px;
    padding: 10px 18px;
    background: #2c7be5;
    color: #fff;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
}
.buy-button:hover { background: #1a68d1; }
@media (max-width: 600px) {
    .buy-link { font-size: 0.72rem; white-space: normal; }
}
