/* JEF Circuit Rankings - Styles */

:root {
    --color-primary: #1a4d8f;
    --color-primary-light: #2a6bcf;
    --color-bg: #f8f9fa;
    --color-white: #ffffff;
    --color-text: #212529;
    --color-text-light: #6c757d;
    --color-border: #dee2e6;
    --color-row-alt: #f2f6fc;
    --color-accent: #e8a317;
}

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

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

/* Header */
header {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.header-brand {
    background: var(--color-white);
    padding: 1rem 2rem;
    border-bottom: 3px solid var(--color-accent);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    height: 52px;
    width: auto;
}

.logo-text {
    font-weight: 700;
    font-size: 1.5rem;
    background: var(--color-primary);
    color: var(--color-white);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
}

.header-titles {
    display: flex;
    flex-direction: column;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-light);
}

header nav {
    background: var(--color-primary);
    padding: 0 2rem;
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 0.25rem;
}

header nav a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.6rem 1rem;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

header nav a:hover {
    color: var(--color-white);
    border-bottom-color: var(--color-accent);
}

/* Main */
main {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

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

.filters form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filters label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.filters select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.875rem;
    background: var(--color-white);
}

/* Rankings table */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--color-white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rankings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    white-space: nowrap;
}

.rankings-table thead {
    background: var(--color-primary);
    color: var(--color-white);
}

.rankings-table thead a {
    color: var(--color-white);
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.5);
}

.rankings-table thead a:hover {
    border-bottom-color: var(--color-white);
}

.rankings-table .sub-header {
    background: var(--color-primary-light);
    font-size: 0.75rem;
}

.rankings-table th,
.rankings-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.rankings-table th {
    font-weight: 600;
}

.rankings-table tbody tr:nth-child(even) {
    background: var(--color-row-alt);
}

.rankings-table tbody tr:hover {
    background: #e3ecf7;
}

.rank, .tour-rank {
    text-align: center;
    font-weight: 600;
}

.total {
    font-weight: 700;
    color: var(--color-primary);
}

.tour-points {
    text-align: right;
    font-size: 0.8125rem;
}

.category {
    font-size: 0.8125rem;
    color: var(--color-text-light);
}

.name {
    font-weight: 500;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-light);
    font-size: 1.1rem;
    background: var(--color-white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Error page */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--color-primary);
}

.error-page a {
    color: var(--color-primary);
}

/* Tournament detail */
.tournament-header {
    margin-bottom: 1.5rem;
}

.tournament-header h2 {
    font-size: 1.5rem;
    color: var(--color-primary);
}

.tournament-meta {
    color: var(--color-text-light);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.875rem;
}

.back-link:hover {
    text-decoration: underline;
}

/* Result indicators */
.result-win { color: #198754; font-weight: 600; }
.result-draw { color: var(--color-accent); font-weight: 600; }
.result-loss { color: #dc3545; }
.color-indicator { font-size: 0.75rem; margin: 0 0.15rem; }
.round-cell { text-align: center; white-space: nowrap; }
.round-cell[title] { cursor: help; }
.opponent-rank { font-size: 0.75rem; color: var(--color-text-light); }
.name .category { margin-left: 0.35rem; }

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-text-light);
    font-size: 0.8125rem;
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

/* Admin styles */
.admin-nav {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.admin-nav a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.admin-nav a:hover {
    text-decoration: underline;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.875rem;
    width: 100%;
    max-width: 400px;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: var(--color-primary-light);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-success {
    background: #d1e7dd;
    color: #0f5132;
}

.alert-error {
    background: #f8d7da;
    color: #842029;
}

.login-form {
    max-width: 400px;
    margin: 3rem auto;
    background: var(--color-white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.login-form h2 {
    margin-bottom: 1.5rem;
    color: var(--color-primary);
}

/* Stage cards */
.stages-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stage-card {
    background: var(--color-white);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stage-card h3 {
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.stage-card h3 a {
    color: inherit;
    text-decoration: none;
}

.stage-card h3 a:hover {
    text-decoration: underline;
}

.stage-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.stage-meta dt {
    font-weight: 500;
    color: var(--color-text);
}

.stage-meta a {
    color: var(--color-primary);
}

.stage-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.stage-badge-done {
    background: #d1e7dd;
    color: #0f5132;
}

.stage-badge-upcoming {
    background: #fff3cd;
    color: #664d03;
}

.stage-badge-past {
    background: #e2e3e5;
    color: #41464b;
}

.stage-result-link {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

.stage-result-link a {
    color: var(--color-primary);
    text-decoration: none;
}

.stage-result-link a:hover {
    text-decoration: underline;
}

/* Tournament info block */
.tournament-info {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text-light);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.tournament-info a {
    color: var(--color-primary);
}

.btn-register {
    display: inline-block;
    padding: 0.35rem 1rem;
    background: var(--color-accent);
    color: var(--color-white);
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 600;
}

.btn-register:hover {
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 768px) {
    .header-brand {
        padding: 0.75rem 1rem;
    }

    header nav {
        padding: 0 1rem;
    }

    .logo {
        height: 40px;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .filters form {
        flex-direction: column;
        align-items: flex-start;
    }

    .rankings-table {
        font-size: 0.8125rem;
    }

    .rankings-table th,
    .rankings-table td {
        padding: 0.375rem 0.5rem;
    }

    .stage-meta {
        grid-template-columns: 1fr;
    }

    .tournament-info {
        flex-direction: column;
        gap: 0.25rem;
    }
}
