/* WC2026 Predictor — Styles
   Theme: Red / White / Blue (USA/Mexico/Canada inspired) */

:root {
    --red: #BF0A30;
    --blue: #002868;
    --dark-blue: #001a3e;
    --light-blue: #4a90d9;
    --white: #ffffff;
    --off-white: #f4f5f7;
    --gray: #6b7280;
    --light-gray: #e5e7eb;
    --dark: #1f2937;
    --green: #16a34a;
    --yellow: #ca8a04;
    --orange: #ea580c;
    --pts-exact: #dcfce7;
    --pts-correct: #fef9c3;
    --pts-wrong: #fecaca;
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

body {
    font-family: var(--font);
    background: var(--off-white);
    color: var(--dark);
    line-height: 1.5;
    min-height: 100vh;
}

/* ===== AUTH PAGE ===== */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--blue) 0%, var(--dark-blue) 60%, var(--red) 100%);
}

.auth-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    margin: 1rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-header h1 {
    font-size: 1.75rem;
    color: var(--blue);
}

.auth-header p {
    color: var(--gray);
    font-size: 0.95rem;
}

.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--light-gray);
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.auth-tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

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

.auth-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--dark);
}

.auth-form input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--light-gray);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,40,104,0.1);
}

.auth-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--blue);
    color: var(--white);
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

.btn-primary:hover { background: var(--dark-blue); }

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    background: var(--white);
    color: var(--blue);
    border: 1.5px solid var(--blue);
}

.btn-sm:hover { background: var(--blue); color: var(--white); }

.btn-danger {
    background: var(--red);
    color: var(--white);
}

.btn-danger:hover { background: #9a0826; }

.btn-success {
    background: var(--green);
    color: var(--white);
}

.btn-success:hover { background: #138a3e; }

/* ===== APP HEADER ===== */
.app-header {
    background: linear-gradient(135deg, var(--blue), var(--dark-blue));
    color: var(--white);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 { font-size: 1.25rem; }

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

#user-display-name {
    font-weight: 600;
    font-size: 0.9rem;
}

#logout-btn {
    color: var(--white);
    border-color: rgba(255,255,255,0.5);
}

#logout-btn:hover {
    background: rgba(255,255,255,0.15);
    color: var(--white);
}

/* ===== TAB NAV ===== */
.tab-nav {
    display: flex;
    background: var(--white);
    border-bottom: 2px solid var(--light-gray);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover { color: var(--dark); }

.tab-btn.active {
    color: var(--blue);
    border-bottom-color: var(--red);
}

.tab-admin {
    color: var(--orange) !important;
}

.tab-admin.active {
    color: var(--orange) !important;
    border-bottom-color: var(--orange);
}

/* ===== CONTENT AREA ===== */
.app-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    min-height: calc(100vh - 160px);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== GROUP CARDS ===== */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

.group-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.group-card-header {
    background: var(--blue);
    color: var(--white);
    padding: 0.6rem 1rem;
    font-weight: 700;
    font-size: 1rem;
}

.group-card-body { padding: 0.75rem; }

/* Standings table */
.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.standings-table th {
    text-align: left;
    padding: 0.3rem 0.4rem;
    font-weight: 700;
    color: var(--gray);
    border-bottom: 1.5px solid var(--light-gray);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.standings-table th:not(:first-child) { text-align: center; }

.standings-table td {
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid var(--light-gray);
}

.standings-table td:not(:first-child) { text-align: center; }

.standings-table tr.qualify { background: #dcfce7; }
.standings-table tr.third-place { background: #fef9c3; }

.team-name {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.team-flag { font-size: 1.1rem; }

/* Match list inside group card */
.group-matches { font-size: 0.8rem; }

.group-match-row {
    display: flex;
    align-items: center;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--light-gray);
    gap: 0.5rem;
}

.group-match-row:last-child { border-bottom: none; }

.match-teams {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-actual, .match-predicted, .match-points {
    text-align: center;
    font-weight: 600;
    min-width: 42px;
}

.match-actual { color: var(--blue); }
.match-predicted { color: var(--gray); }

.match-label-row {
    display: flex;
    gap: 0.5rem;
    font-size: 0.7rem;
    color: var(--gray);
    text-transform: uppercase;
    padding-bottom: 0.2rem;
    border-bottom: 1.5px solid var(--light-gray);
    margin-bottom: 0.25rem;
}

.match-label-row span { text-align: center; min-width: 42px; }
.match-label-row span:first-child { flex: 1; text-align: left; }

/* Points badge */
.pts-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}

.pts-5 { background: var(--pts-exact); color: var(--green); }
.pts-2 { background: var(--pts-correct); color: var(--yellow); }
.pts-0 { background: var(--pts-wrong); color: var(--red); }
.pts-na { background: var(--light-gray); color: var(--gray); }

/* ===== PREDICTIONS ===== */
.predictions-container { max-width: 800px; margin: 0 auto; }

.predictions-sort-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.predictions-stage-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--blue);
    padding: 0.75rem 0 0.5rem;
    border-bottom: 2px solid var(--blue);
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

.predictions-stage-header:first-child { margin-top: 0; }

.prediction-group-header {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dark);
    padding: 0.5rem 0 0.25rem;
}

.prediction-date-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray);
    padding: 0.4rem 0 0.2rem;
    border-bottom: 1px solid var(--light-gray);
    margin-top: 0.5rem;
}

.prediction-group-tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--blue);
    background: #dbeafe;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    margin-top: 0.1rem;
}

.prediction-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--white);
    border-radius: var(--radius);
    margin-bottom: 0.4rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    gap: 0.5rem;
}

.prediction-row.locked {
    opacity: 0.6;
    background: #f9fafb;
}

.prediction-home, .prediction-away {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.prediction-home { justify-content: flex-end; text-align: right; }
.prediction-away { justify-content: flex-start; }

.prediction-score {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.prediction-score input {
    width: 38px;
    height: 34px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    border: 1.5px solid var(--light-gray);
    border-radius: 4px;
    background: var(--white);
}

.prediction-score input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(0,40,104,0.15);
}

.prediction-score input:disabled {
    background: var(--light-gray);
    color: var(--gray);
    cursor: not-allowed;
}

.prediction-score .score-dash {
    font-weight: 700;
    color: var(--gray);
}

.lock-icon {
    color: var(--gray);
    font-size: 0.85rem;
    margin-left: 0.25rem;
}

.prediction-kickoff {
    font-size: 0.7rem;
    color: var(--gray);
    width: 75px;
    text-align: center;
}

.penalty-picker {
    margin: 0.15rem 0 0.4rem;
    padding: 0.4rem 0.75rem;
    background: #fffbeb;
    border-radius: var(--radius);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.penalty-picker label { font-weight: 600; color: var(--orange); }

.penalty-picker select {
    padding: 0.25rem 0.5rem;
    border: 1.5px solid var(--orange);
    border-radius: 4px;
    font-size: 0.85rem;
}

.save-status {
    font-size: 0.8rem;
    color: var(--green);
    text-align: center;
    padding: 0.5rem;
    min-height: 2rem;
}

/* ===== KNOCKOUT BRACKET ===== */
.knockout-container { overflow-x: auto; padding: 1rem 0; }

.bracket {
    display: flex;
    gap: 2rem;
    min-width: 1100px;
    align-items: flex-start;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 180px;
}

.bracket-round-title {
    text-align: center;
    font-weight: 700;
    color: var(--blue);
    font-size: 0.85rem;
    text-transform: uppercase;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--blue);
    margin-bottom: 0.5rem;
}

.bracket-match {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    font-size: 0.8rem;
    border-left: 3px solid var(--blue);
}

.bracket-match.final-match { border-left-color: var(--red); }

.bracket-team {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--light-gray);
}

.bracket-team:last-child { border-bottom: none; }

.bracket-team.winner { font-weight: 700; background: #dcfce7; }

.bracket-team-name {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.bracket-score { font-weight: 700; }

.bracket-penalty {
    font-size: 0.65rem;
    color: var(--orange);
    text-align: center;
    padding: 0.15rem;
}

.bracket-prediction {
    font-size: 0.7rem;
    color: var(--gray);
    padding: 0.2rem 0.6rem;
    background: var(--off-white);
    text-align: center;
}

/* Connecting lines */
.bracket-round:not(:first-child) .bracket-match {
    position: relative;
}

.bracket-round:not(:first-child) .bracket-match::before {
    content: "";
    position: absolute;
    left: -2rem;
    top: 50%;
    width: 2rem;
    height: 1px;
    background: var(--light-gray);
}

/* ===== RESULTS PAGE ===== */
.results-container { max-width: 800px; margin: 0 auto; }

.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    text-align: center;
}

.summary-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--blue);
}

.summary-label {
    font-size: 0.8rem;
    color: var(--gray);
    text-transform: uppercase;
}

.results-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.35rem 0.75rem;
    border: 1.5px solid var(--light-gray);
    border-radius: 20px;
    background: var(--white);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background: var(--blue);
    color: var(--white);
    border-color: var(--blue);
}

.result-row {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: var(--white);
    border-radius: var(--radius);
    margin-bottom: 0.35rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    gap: 0.75rem;
    font-size: 0.85rem;
}

.result-row.pts-bg-5 { border-left: 3px solid var(--green); }
.result-row.pts-bg-2 { border-left: 3px solid var(--yellow); }
.result-row.pts-bg-0 { border-left: 3px solid var(--red); }
.result-row.pts-bg-na { border-left: 3px solid var(--light-gray); }

.result-teams { flex: 1; font-weight: 500; }
.result-actual { min-width: 50px; text-align: center; font-weight: 700; color: var(--blue); }
.result-predicted { min-width: 50px; text-align: center; color: var(--gray); }
.result-pts { min-width: 40px; text-align: center; }

.result-header {
    display: flex;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: var(--gray);
    text-transform: uppercase;
    padding: 0.25rem 0.75rem;
    font-weight: 600;
}

.result-header span:first-child { flex: 1; }
.result-header span { min-width: 50px; text-align: center; }
.result-header span:last-child { min-width: 40px; }

/* ===== LEADERBOARD ===== */
.leaderboard-container { max-width: 600px; margin: 0 auto; }

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.leaderboard-table th {
    background: var(--blue);
    color: var(--white);
    padding: 0.7rem 0.75rem;
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.leaderboard-table th:not(:first-child):not(:nth-child(2)) { text-align: center; }

.leaderboard-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--light-gray);
    font-size: 0.9rem;
}

.leaderboard-table td:not(:first-child):not(:nth-child(2)) { text-align: center; }

.leaderboard-table tr:nth-child(even) { background: var(--off-white); }

.leaderboard-table tr.current-user {
    background: #dbeafe !important;
    font-weight: 700;
}

.leaderboard-table tr:first-child td { font-weight: 700; }

.rank-1 { color: #ca8a04; }
.rank-2 { color: #6b7280; }
.rank-3 { color: #b45309; }

/* ===== ADMIN ===== */
.admin-container { max-width: 800px; margin: 0 auto; }

.admin-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.admin-section h2 {
    font-size: 1.1rem;
    color: var(--blue);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light-gray);
}

.admin-match-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--light-gray);
    gap: 0.5rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.admin-match-row:last-child { border-bottom: none; }

.admin-match-teams {
    flex: 1;
    min-width: 150px;
    font-weight: 500;
}

.admin-score-input {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.admin-score-input input {
    width: 40px;
    height: 32px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    border: 1.5px solid var(--light-gray);
    border-radius: 4px;
}

.admin-score-input input:focus {
    outline: none;
    border-color: var(--blue);
}

.admin-penalty-select {
    padding: 0.25rem;
    border: 1.5px solid var(--light-gray);
    border-radius: 4px;
    font-size: 0.8rem;
}

.admin-save-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    background: var(--green);
    color: var(--white);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.admin-save-btn:hover { background: #138a3e; }

.admin-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.admin-tbd-section {
    margin-top: 1rem;
}

.admin-tbd-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.85rem;
}

.admin-tbd-row input {
    padding: 0.3rem 0.5rem;
    border: 1.5px solid var(--light-gray);
    border-radius: 4px;
    font-size: 0.85rem;
    width: 180px;
}

/* ===== FOOTER ===== */
.app-footer {
    text-align: center;
    padding: 1rem;
    color: var(--gray);
    font-size: 0.8rem;
    border-top: 1px solid var(--light-gray);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    .app-header h1 { font-size: 1.1rem; }

    .tab-nav { padding: 0 0.25rem; }

    .tab-btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    .app-content { padding: 1rem 0.5rem; }

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

    .prediction-row {
        flex-wrap: wrap;
        padding: 0.5rem;
    }

    .prediction-home, .prediction-away {
        font-size: 0.8rem;
    }

    .bracket { min-width: 900px; }

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

    .result-row { font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .auth-container { padding: 1.5rem; margin: 0.5rem; }
    .auth-header h1 { font-size: 1.4rem; }

    .prediction-home, .prediction-away { font-size: 0.75rem; }
    .prediction-score input { width: 32px; height: 30px; font-size: 0.9rem; }
    .prediction-kickoff { width: 60px; font-size: 0.65rem; }
}

/* ===== LOADING / EMPTY STATES ===== */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--gray);
}

.loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--light-gray);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

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

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--gray);
    font-size: 0.95rem;
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-center { display: flex; justify-content: center; align-items: center; }
