/* ==========================================================================
   PadelCheckr — dark theme
   ========================================================================== */

:root {
    color-scheme: dark;

    --bg: #0f1115;
    --bg-elevated: #13161b;
    --surface: #15181e;
    --surface-2: #181b21;
    --input-bg: #0f1115;
    --border: #22262e;
    --border-strong: #2b303a;

    --text: #f2f4f7;
    --text-soft: #c3c8d1;
    --text-muted: #8a919e;
    --text-faint: #5c6370;

    --accent: #c6f432;
    --accent-strong: #9fd11c;
    --accent-ink: #0f1115;
    --accent-tint: #1d2416;
    --accent-text: #e9fbb0;

    --danger: #ff6b6b;
    --danger-tint: #2a1416;

    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --sidebar-width: 248px;
    --topbar-height: 68px;

    --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
    margin: 0;
}

button,
input {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -48px;
    z-index: 100;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 12px;
}

.logo {
    flex-shrink: 0;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 20px;
    border: 0;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.05s ease;
}

.btn--primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: var(--accent-ink);
}

.btn--primary:hover {
    filter: brightness(1.06);
}

.btn--primary:active {
    transform: translateY(1px);
}

.btn--block {
    width: 100%;
}

.btn[disabled] {
    cursor: progress;
    filter: saturate(0.6) brightness(0.85);
}

.btn.is-loading .btn__label::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 10px;
    vertical-align: -2px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
}

.icon-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

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

/* ---------- Forms ---------- */

.form {
    display: grid;
    gap: 18px;
}

.form__field {
    display: grid;
    gap: 8px;
}

.form__label {
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 500;
}

.form__input-wrap {
    position: relative;
}

.form__input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form__input-wrap .form__input {
    padding-right: 64px;
}

.form__input::placeholder {
    color: var(--text-faint);
}

.form__input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(198 244 50 / 0.15);
}

.form__input[aria-invalid="true"] {
    border-color: var(--danger);
}

.form__toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    padding: 4px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
}

.form__toggle:hover {
    color: var(--text);
}

.form__error {
    padding: 10px 12px;
    border: 1px solid rgb(255 107 107 / 0.35);
    border-radius: var(--radius-sm);
    background: var(--danger-tint);
    color: #ffb4b4;
    font-size: 13px;
}

/* ---------- Login page ---------- */

.page-login {
    display: grid;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% 30%, #1f2a1a 0%, var(--bg) 55%, #0b0c0f 100%);
    overflow-x: hidden;
}

/* Faint padel court drawn in the background */
.court-lines {
    position: fixed;
    inset: 11% 11%;
    border: 2px solid #1c2027;
    border-radius: 4px;
    pointer-events: none;
    background:
        linear-gradient(#1c2027, #1c2027) 50% 0 / 2px 100% no-repeat,
        linear-gradient(#1c2027, #1c2027) 0 50% / 100% 2px no-repeat,
        linear-gradient(#1c2027, #1c2027) 20% 0 / 2px 100% no-repeat,
        linear-gradient(#1c2027, #1c2027) 80% 0 / 2px 100% no-repeat;
}

.login {
    position: relative;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 24px;
    padding: 32px 16px;
}

.login__card {
    width: 100%;
    max-width: 380px;
    padding: 36px 32px 32px;
    border: 1px solid #262a33;
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.6);
}

.login__header {
    display: grid;
    justify-items: center;
    gap: 6px;
    margin-bottom: 28px;
    text-align: center;
}

.login__header .logo {
    margin-bottom: 10px;
}

.login__title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.login__subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

.login__footer {
    color: #4b5260;
    font-size: 12px;
}

/* ---------- App shell ---------- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: var(--sidebar-width);
    height: 100vh;
    padding: 20px 14px 14px;
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 10px 24px;
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
    text-decoration: none;
}

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
}

.sidebar__heading {
    padding: 14px 10px 8px;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.sidebar__list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 40px;
    padding: 0 12px 0 16px;
    border-radius: var(--radius);
    color: #9aa1ad;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

a.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-item.is-active {
    background: var(--accent-tint);
    color: var(--accent-text);
    font-weight: 600;
}

.nav-item.is-active .icon {
    color: var(--accent);
}

.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 2px;
    background: var(--accent);
}

.nav-item.is-disabled {
    color: var(--text-faint);
    cursor: not-allowed;
}

.badge {
    margin-left: auto;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-faint);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.sidebar__user form {
    margin: 0 0 0 auto;
}

.avatar {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2a3020;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.sidebar__user-email {
    min-width: 0;
    overflow: hidden;
    color: var(--text-soft);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 14px;
    height: var(--topbar-height);
    padding: 0 40px;
    border-bottom: 1px solid #1d2027;
    background: rgb(15 17 21 / 0.85);
    backdrop-filter: blur(8px);
}

.topbar__menu {
    display: none;
}

.topbar__title {
    font-size: 20px;
    font-weight: 700;
}

.content {
    display: grid;
    gap: 28px;
    padding: 36px 40px 48px;
}

.content:focus {
    outline: none;
}

/* ---------- Home ---------- */

.welcome__title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.welcome__text {
    margin-top: 6px;
    color: var(--text-muted);
}

.empty-state {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 6px;
    min-height: 380px;
    padding: 40px 24px;
    border: 1px dashed #2a2f38;
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    text-align: center;
}

.empty-state__ball {
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: #1a2014;
}

.empty-state__ball::after {
    content: "";
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.empty-state__title {
    color: #e6e8ec;
    font-size: 16px;
    font-weight: 600;
}

.empty-state__text {
    color: #6b7280;
    font-size: 13px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        z-index: 20;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar.is-open {
        transform: none;
        box-shadow: 20px 0 60px rgb(0 0 0 / 0.5);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgb(0 0 0 / 0.55);
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar__menu {
        display: inline-grid;
    }

    .content {
        padding: 24px 16px 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Utilities ---------- */

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Extra button variants ---------- */

.btn--ghost {
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-soft);
}

.btn--ghost:hover {
    border-color: #3a404b;
    background: var(--surface-2);
    color: var(--text);
}

.btn--danger {
    background: #e5484d;
    color: #fff;
}

.btn--danger:hover {
    filter: brightness(1.08);
}

.icon-btn--danger:hover {
    border-color: rgb(255 107 107 / 0.45);
    background: var(--danger-tint);
    color: var(--danger);
}

/* ---------- Section ---------- */

.section {
    display: grid;
    gap: 20px;
}

.section__header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.section__title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.section__text {
    margin-top: 4px;
    color: var(--text-muted);
}

/* ---------- Court alerts ---------- */

.alert-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.alert-card {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 20px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    transition: border-color 0.15s ease;
}

.alert-card:hover {
    border-color: var(--border-strong);
}

.alert-card__icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--accent-tint);
    color: var(--accent);
}

.alert-card__body {
    min-width: 0;
}

.alert-card__time {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.alert-card__dash {
    color: var(--text-faint);
    font-weight: 400;
}

.alert-card__days {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 14px;
}

.alert-card__actions {
    display: flex;
    gap: 8px;
}

.day-chips {
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.day-chip {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-faint);
    font-size: 12px;
    font-weight: 600;
}

.day-chip.is-on {
    border-color: transparent;
    background: var(--accent);
    color: var(--accent-ink);
}

/* ---------- Dialog ---------- */

.dialog {
    width: min(460px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid #262a33;
    border-radius: var(--radius-xl);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.7);
}

.dialog--small {
    width: min(400px, calc(100vw - 32px));
}

.dialog::backdrop {
    background: rgb(5 6 8 / 0.7);
    backdrop-filter: blur(2px);
}

.dialog[open] {
    animation: dialog-in 0.16s ease-out;
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

.dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.dialog__title {
    font-size: 18px;
    font-weight: 700;
}

.dialog__text {
    margin: 8px 0 4px;
    color: var(--text-muted);
}

.dialog__text strong {
    color: var(--text);
    font-weight: 600;
}

.dialog__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.dialog__footer .btn {
    height: 42px;
}

.form__fieldset {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
}

.form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form__input[type="time"] {
    font-variant-numeric: tabular-nums;
}

.day-picker {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.day-picker__option {
    position: relative;
}

.day-picker__option input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.day-picker__option span {
    display: grid;
    place-items: center;
    height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.day-picker__option:hover span {
    border-color: #3a404b;
    color: var(--text);
}

.day-picker__option input:checked + span {
    border-color: transparent;
    background: var(--accent);
    color: var(--accent-ink);
}

.day-picker__option input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.day-picker__option input[aria-invalid="true"] + span {
    border-color: var(--danger);
}

/* ---------- Toasts ---------- */

.toast-region {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 50;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 40px));
    pointer-events: none;
}

.toast {
    padding: 14px 16px 14px 18px;
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface-2);
    box-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.6);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: none;
}

.toast__title {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.toast__detail {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- Responsive: court alerts ---------- */

@media (max-width: 720px) {
    .alert-card {
        grid-template-columns: auto 1fr auto;
        gap: 14px 16px;
    }

    .day-chips {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .section__header .btn {
        width: 100%;
    }
}

/* ---------- Admin ---------- */

.flash {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    font-size: 14px;
}

.flash--success {
    border-color: rgb(159 209 28 / 0.4);
    background: var(--accent-tint);
    color: var(--accent-text);
}

.flash--error {
    border-color: rgb(255 107 107 / 0.4);
    background: var(--danger-tint);
    color: var(--danger);
}

.admin-list {
    display: grid;
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.admin-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.admin-card:hover {
    border-color: var(--border-strong);
}

.admin-card__form {
    display: grid;
    gap: 18px;
    padding: 20px;
}

.admin-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.admin-card__title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.admin-card__command {
    margin: 2px 0 0;
    color: var(--text-faint);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.admin-badge {
    flex: none;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-strong);
}

.admin-badge--on {
    border-color: rgb(159 209 28 / 0.4);
    background: var(--accent-tint);
    color: var(--accent-text);
}

.admin-badge--off {
    color: var(--text-muted);
}

.admin-switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.admin-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.admin-switch__track {
    position: relative;
    width: 46px;
    height: 26px;
    flex: none;
    border-radius: 999px;
    background: var(--input-bg);
    border: 1px solid var(--border-strong);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.admin-switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.15s ease, background 0.15s ease;
}

.admin-switch input:checked + .admin-switch__track {
    background: var(--accent-tint);
    border-color: var(--accent-strong);
}

.admin-switch input:checked + .admin-switch__track::after {
    transform: translateX(20px);
    background: var(--accent);
}

.admin-switch input:focus-visible + .admin-switch__track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.admin-switch__text {
    font-size: 14px;
    color: var(--text-soft);
}

.form__hint {
    margin: 2px 0 0;
    color: var(--text-faint);
    font-size: 12px;
}

.admin-card__actions {
    display: flex;
    justify-content: flex-end;
}
