/* ==========================================================
   OPEN PLAY SYSTEM
   Modern Light / Dark Theme — compact/ERP sizing pass
   (colors unchanged from the original light & dark palettes;
   only spacing, font sizes and radii were tightened)
========================================================== */

:root { /* TODO: Default theme */
    color-scheme: light;
    /* color-scheme: dark; */


    --display-playing: #198754;
--display-playing-dark: #126c43;

--display-completed: #6c757d;
--display-completed-dark: #495057;


    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-light: #dcfce7;

    --bg: #f4f7f6;
    --bg-secondary: #eef2f1;
    --card-bg: #ffffff;
    --card-hover: #f8faf9;

    --border: #dfe7e3;
    --border-strong: #cbd5d1;

    --text: #17231d;
    --text-secondary: #33443a;
    --muted: #64756b;

    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning: #d97706;
    --info: #2563eb;

    --success-bg: #dcfce7;
    --success-text: #166534;

    --error-bg: #fee2e2;
    --error-text: #991b1b;

    --warning-bg: #fef3c7;
    --warning-text: #92400e;

    --info-bg: #dbeafe;
    --info-text: #1e40af;

    --input-bg: #ffffff;

    --topbar-bg: linear-gradient(
        135deg,
        #16a34a 0%,
        #15803d 55%,
        #166534 100%
    );

    --admin-bg: #1e293b;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, .10);

    --radius-sm: 7px;
    --radius-md: 10px;
    --radius-lg: 13px;

    --transition: 160ms ease;
}


/* ==========================================================
   DARK MODE
========================================================== */

html[data-theme="dark"] {
    color-scheme: dark;

    --primary: #22c55e;
    --primary-dark: #16a34a;
    --primary-light: #14532d;

    --bg: #0b1110;
    --bg-secondary: #111a17;

    --card-bg: #151f1c;
    --card-hover: #1a2722;


    --display-playing: #35c47a;
--display-playing-dark: #23965b;

--display-completed: #68747a;
--display-completed-dark: #4f5a60;

    --border: #263630;
    --border-strong: #34483e;

    --text: #ecfdf5;
    --text-secondary: #cbd5d1;
    --muted: #91a39a;

    --danger: #f87171;
    --danger-dark: #ef4444;
    --warning: #f59e0b;
    --info: #60a5fa;

    --success-bg: #12351f;
    --success-text: #86efac;

    --error-bg: #3b1515;
    --error-text: #fca5a5;

    --warning-bg: #3b2b0b;
    --warning-text: #fcd34d;

    --info-bg: #122b4d;
    --info-text: #93c5fd;

    --input-bg: #101815;

    --topbar-bg: linear-gradient(
        135deg,
        #14532d 0%,
        #166534 55%,
        #064e3b 100%
    );

    --admin-bg: #101817;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .30);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .30);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .40);
}


/* ==========================================================
   GLOBAL
========================================================== */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
    transition:
        background-color .2s ease,
        color .2s ease;
}

body {
    margin: 0;
    min-height: 100vh;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    background:
        radial-gradient(
            circle at top right,
            rgba(34, 197, 94, .06),
            transparent 32%
        ),
        var(--bg);

    color: var(--text);

    transition:
        background-color .2s ease,
        color .2s ease;
}

button,
input,
select,
textarea {
    font: inherit;
}


/* ==========================================================
   TOP BAR
========================================================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;

    background: var(--topbar-bg);
    color: white;

    padding: 10px 18px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 14px;
    flex-wrap: wrap;

    box-shadow:
        0 4px 18px rgba(0, 0, 0, .12);
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -.02em;
}

.brand-subtitle {
    font-size: .7rem;
    opacity: .75;

    padding-left: 10px;
    border-left: 1px solid rgba(255,255,255,.25);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* ==========================================================
   MAIN NAVIGATION
========================================================== */

.tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tabs a {
    color: white;
    text-decoration: none;

    padding: 6px 10px;
    border-radius: 6px;

    font-size: .82rem;
    font-weight: 600;

    opacity: .82;

    transition:
        background var(--transition),
        opacity var(--transition),
        transform var(--transition);
}

.tabs a:hover {
    opacity: 1;
    background: rgba(255,255,255,.12);
}

.tabs a.active {
    opacity: 1;
    background: rgba(255,255,255,.20);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}


/* ==========================================================
   THEME TOGGLE
========================================================== */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    min-height: 32px;
    padding: 6px 10px;

    border: 1px solid rgba(255,255,255,.20);
    border-radius: 999px;

    background: rgba(255,255,255,.10);
    color: white;

    cursor: pointer;

    font-size: .78rem;
    font-weight: 700;

    backdrop-filter: blur(8px);

    transition:
        background var(--transition),
        transform var(--transition);
}

.theme-toggle:hover {
    background: rgba(255,255,255,.18);
    transform: translateY(-1px);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-icon {
    font-size: .95rem;
    line-height: 1;
}


/* ==========================================================
   CONTAINER
========================================================== */

.container {
    width: min(1180px, calc(100% - 32px));

    margin: 18px auto;

    padding-bottom: 50px;
}


/* ==========================================================
   CARDS
========================================================== */

.card {
    background: var(--card-bg);

    border: 1px solid var(--border);

    border-radius: var(--radius-lg);

    padding: 16px;

    margin-bottom: 14px;

    box-shadow: var(--shadow-sm);

    transition:
        background-color .2s ease,
        border-color .2s ease,
        box-shadow .2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card.narrow {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

h1 {
    margin-top: 0;
    margin-bottom: 6px;

    font-size: clamp(1.15rem, 1.8vw, 1.4rem);
    letter-spacing: -.025em;
}

h2 {
    font-size: 1.02rem;
    margin-top: 0;
}

h3 {
    font-size: .92rem;
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

.small {
    font-size: .8rem;
}


/* ==========================================================
   FORMS
========================================================== */

.form-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 12px;

    margin-top: 12px;
}

.form-grid label {
    display: flex;
    flex-direction: column;

    min-width: 0;

    gap: 5px;

    color: var(--text);

    font-size: .8rem;
    font-weight: 700;
}

.form-grid label.full {
    grid-column: 1 / -1;
}

.form-grid label.checkbox {
    flex-direction: row;
    align-items: center;

    font-weight: 600;
}

.form-grid label.checkbox input {
    width: auto;
}

input[type=text],
input[type=email],
input[type=password],
input[type=date],
input[type=number],
input[type=file],
select,
textarea {
    width: 100%;
    min-width: 0;

    padding: 8px 10px;

    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);

    background: var(--input-bg);
    color: var(--text);

    font-size: .88rem;

    outline: none;

    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        background var(--transition);
}

input[type=file] {
    padding: 6px 8px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 3px rgba(34, 197, 94, .15);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
}


/* ==========================================================
   BUTTONS
========================================================== */

.btn-primary {
    background: linear-gradient(
        135deg,
        var(--primary),
        var(--primary-dark)
    );

    color: white;

    border: none;

    padding: 9px 14px;

    border-radius: var(--radius-sm);

    font-weight: 700;
    font-size: .86rem;

    cursor: pointer;

    box-shadow:
        0 3px 8px rgba(22, 163, 74, .18);

    transition:
        transform var(--transition),
        box-shadow var(--transition),
        filter var(--transition);
}

.btn-primary:hover {
    filter: brightness(1.04);

    transform: translateY(-1px);

    box-shadow:
        0 6px 14px rgba(22, 163, 74, .22);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text);

    border: 1px solid var(--border);

    padding: 7px 11px;

    border-radius: var(--radius-sm);

    cursor: pointer;

    font-weight: 700;
    font-size: .82rem;

    margin-top: 8px;

    transition:
        background var(--transition),
        border-color var(--transition),
        transform var(--transition);
}

.btn-secondary:hover {
    background: var(--card-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.btn-link {
    background: none;
    border: none;

    color: white;

    text-decoration: underline;

    cursor: pointer;

    font-size: .84rem;
}

.btn-link-inline {
    background: none;
    border: none;

    color: var(--info);

    cursor: pointer;

    text-decoration: underline;

    font-size: .8rem;
    padding: 0;
}

.btn-danger-link {
    background: none;
    border: none;

    color: var(--danger);

    cursor: pointer;

    text-decoration: underline;

    font-size: .8rem;

    padding: 0;
}

.btn-danger {
    background: var(--danger);

    color: white;

    border: none;

    padding: 7px 13px;

    border-radius: var(--radius-sm);

    font-weight: 700;

    cursor: pointer;

    transition:
        background var(--transition),
        transform var(--transition);
}

.btn-danger:hover {
    background: var(--danger-dark);
    transform: translateY(-1px);
}

.full {
    grid-column: 1 / -1;
}


/* ==========================================================
   INLINE FORMS
========================================================== */

.inline-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    gap: 6px;

    margin-top: 8px;
}


/* ==========================================================
   ALERTS
========================================================== */

.flash {
    padding: 10px 13px;

    border-radius: var(--radius-md);

    margin-bottom: 13px;

    font-size: .86rem;
    font-weight: 500;
}

.flash.success {
    background: var(--success-bg);
    color: var(--success-text);

    border: 1px solid rgba(34,197,94,.25);
}

.flash.error {
    background: var(--error-bg);
    color: var(--error-text);

    border: 1px solid rgba(239,68,68,.25);
}


/* ==========================================================
   STATS
========================================================== */

.stat-row {
    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(120px, 1fr));

    gap: 9px;

    margin: 12px 0;
}

.stat {
    text-align: center;

    background: var(--bg-secondary);

    border: 1px solid var(--border);

    border-radius: var(--radius-md);

    padding: 10px 9px;

    transition:
        background var(--transition),
        transform var(--transition);
}

.stat:hover {
    background: var(--card-hover);
    transform: translateY(-2px);
}

.stat-num {
    display: block;

    font-size: 1.3rem;
    font-weight: 800;

    color: var(--primary);
}

.stat-label {
    display: block;

    margin-top: 2px;

    font-size: .68rem;

    color: var(--muted);

    text-transform: uppercase;
    letter-spacing: .04em;
}


/* ==========================================================
   TABLES
========================================================== */

.data-table {
    width: 100%;

    border-collapse: separate;
    border-spacing: 0;

    margin-top: 10px;

    font-size: .84rem;

    overflow: hidden;
}

.data-table th,
.data-table td {
    text-align: left;

    padding: 8px 8px;

    border-bottom: 1px solid var(--border);

    vertical-align: middle;
}

.data-table th {
    color: var(--muted);

    font-weight: 700;

    font-size: .7rem;

    text-transform: uppercase;
    letter-spacing: .04em;

    background: var(--bg-secondary);
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: var(--card-hover);
}

.data-table tr.upcoming {
    background: var(--success-bg);
}


/* ==========================================================
   BADGES
========================================================== */

.badge {
    display: inline-flex;
    align-items: center;

    padding: 3px 8px;

    border-radius: 999px;

    font-size: .68rem;

    font-weight: 800;

    text-transform: capitalize;

    white-space: nowrap;
}

.badge.pending {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.badge.waitlist {
    background: #ede9fe;
    color: #6d28d9;
}

.badge.approved,
.badge.win {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge.rejected,
.badge.loss {
    background: var(--error-bg);
    color: var(--error-text);
}

.badge.upcoming {
    background: var(--info-bg);
    color: var(--info-text);
}


/* ==========================================================
   PROFILE
========================================================== */

.profile-box {
    margin-top: 12px;
}

.profile-box h2 {
    margin-bottom: 4px;
}


/* ==========================================================
   ADMIN HEADER
========================================================== */

.admin-header {
    position: sticky;
    top: 58px;
    z-index: 50;

    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 10px;

    background: var(--admin-bg);

    color: white;

    padding: 9px 13px;

    border-radius: var(--radius-md);

    margin-bottom: 12px;

    font-size: .84rem;

    flex-wrap: wrap;

    box-shadow: var(--shadow-md);
}

.admin-header form {
    display: inline;
}

.admin-header .btn-link {
    color: #93c5fd;
}

.admin-subnav {
    display: flex;
    gap: 5px;
}


/* ==========================================================
   ADMIN TABS
========================================================== */

.admin-tabs {
    display: flex;

    flex-wrap: wrap;

    gap: 4px;

    align-items: center;

    padding: 3px;

    border: 1px solid rgba(255,255,255,.08);

    border-radius: 9px;

    background: rgba(255,255,255,.04);
}

.admin-tabs .admin-tab {
    appearance: none;

    border: 1px solid transparent;

    background: transparent;

    color: #cbd5e1;

    font: inherit;

    font-weight: 700;

    font-size: .78rem;

    line-height: 1.2;

    padding: 6px 10px;

    border-radius: 6px;

    cursor: pointer;

    transition: .15s ease;
}

.admin-tabs .admin-tab:hover {
    background: rgba(255,255,255,.08);
    color: white;
}

.admin-tabs .admin-tab.active {
    background: var(--primary);
    color: white;

    border-color: var(--primary);
}

.admin-tab-section {
    display: none;
}

.admin-tab-section.admin-tab-visible {
    display: block;

    animation: tabFade .18s ease;
}

@keyframes tabFade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ==========================================================
   EVENTS
========================================================== */

.create-event-box summary {
    cursor: pointer;
    list-style: none;
}

.create-event-box summary::-webkit-details-marker {
    display: none;
}

.actions-cell {
    display: flex;

    flex-direction: column;

    gap: 5px;

    align-items: flex-start;
}


/* ==========================================================
   UTILITY BOX
========================================================== */

.utility-box {
    border: 1px solid var(--border);

    border-radius: var(--radius-md);

    padding: 12px;

    margin-top: 10px;

    background: var(--bg-secondary);
}

.utility-box h3 {
    margin: 0 0 4px;

    font-size: .88rem;

    color: var(--text);
}

.utility-box code {
    background: var(--card-bg);

    border: 1px solid var(--border);

    padding: 2px 6px;

    border-radius: 5px;

    font-size: .78rem;

    color: var(--text-secondary);
}


/* ==========================================================
   COURTS
========================================================== */

.court-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fill, minmax(220px, 1fr));

    gap: 10px;

    margin-top: 12px;

    align-items: start;
}

.court-box {
    min-width: 0;

    overflow: hidden;

    box-sizing: border-box;

    border: 1px solid var(--border);

    border-radius: var(--radius-md);

    padding: 11px;

    background: var(--card-bg);

    box-shadow: var(--shadow-sm);

    transition:
        transform var(--transition),
        box-shadow var(--transition),
        border-color var(--transition);
}

.court-box:hover {
    transform: translateY(-2px);

    box-shadow: var(--shadow-md);

    border-color: var(--border-strong);
}

.court-box * {
    box-sizing: border-box;
}

.court-box h4 {
    margin: 0 0 6px;

    color: var(--primary);
}

.player-list {
    list-style: none;

    padding: 0;

    margin: 0 0 6px;

    font-size: .84rem;
}

.player-list li {
    padding: 2px 0;
}


/* ==========================================================
   SCORE GRID
========================================================== */

.court-score-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(0, 1fr);

    gap: 6px;

    width: 100%;
}

.court-score-field {
    display: block;

    min-width: 0;

    width: 100%;

    font-size: .76rem;

    font-weight: 700;
}

.court-score-field input[type="number"] {
    display: block;

    width: 100%;

    min-width: 0;
    max-width: 100%;

    margin-top: 4px;

    padding: 6px 6px;

    font-size: .85rem;
}

.court-box form {
    min-width: 0;
    max-width: 100%;
}

.court-box .btn-secondary,
.court-box .btn-link-inline {
    max-width: 100%;
    white-space: normal;
}


/* ==========================================================
   FOOTER
========================================================== */

.footer {
    text-align: center;

    color: var(--muted);

    font-size: .74rem;

    padding: 16px;

    border-top: 1px solid var(--border);
}


/* ==========================================================
   REGISTRATION FORM
========================================================== */

.registration-form {
    align-items: start;
}

.registration-form > label {
    min-width: 0;
}

.registration-form > label > input,
.registration-form > label > select,
.registration-form > label > textarea {
    width: 100%;
    min-width: 0;
}

.registration-form .registration-field {
    display: flex;

    flex-direction: column;

    gap: 5px;

    min-width: 0;
}

.registration-form .registration-event-field,
.registration-form .registration-payment-field {
    min-width: 0;
}

.registration-form .registration-payment-field input[type="file"] {
    width: 100%;
    min-width: 0;
}

.registration-form .registration-stats {
    min-width: 0;
}


/* ==========================================================
   SCROLLBARS
========================================================== */

html[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

html[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #0b1110;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #33483e;
    border-radius: 999px;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #466054;
}


/* ==========================================================
   RESPONSIVE
========================================================== */

@media (max-width: 850px) {

    .topbar {
        align-items: flex-start;
    }

    .topbar-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .admin-header {
        top: 0;
    }
}


@media (max-width: 700px) {

    .container {
        width: min(100% - 20px, 1180px);
        margin-top: 12px;
    }

    .card {
        padding: 14px;
        border-radius: var(--radius-md);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid label.full {
        grid-column: 1;
    }

    .registration-form {
        grid-template-columns: 1fr !important;
    }

    .registration-form .full {
        grid-column: 1 / -1;
    }

    .brand-subtitle {
        display: none;
    }

    .tabs {
        width: 100%;
    }

    .tabs a {
        flex: 1;
        text-align: center;
    }

    .theme-toggle {
        margin-left: auto;
    }

    .court-grid {
        grid-template-columns: 1fr;
    }

    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}


@media (max-width: 420px) {

    .topbar {
        padding: 9px 12px;
    }

    .container {
        width: calc(100% - 14px);
    }

    .card {
        padding: 12px;
    }

    .topbar-right {
        gap: 6px;
    }

    .tabs a {
        padding: 6px 7px;
        font-size: .74rem;
    }

    .theme-toggle {
        padding: 6px 8px;
    }

    .stat-row {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .court-score-grid {
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }

    .court-score-field input[type="number"] {
        padding-left: 5px;
        padding-right: 5px;
    }
}


/* ==========================================================
   REDUCED MOTION
========================================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}