/* =====================================================================
   PADEL PLATFORM — design tokens
   Palette ispirata al campo: verde manto profondo, linee gesso,
   accento "pallina" verde-lime usato con parsimonia.
   ===================================================================== */
:root {
    --court: #163832;
    --court-light: #1f4d44;
    --court-line: rgba(246, 244, 236, 0.08);
    --chalk: #f6f4ec;
    --paper: #ffffff;
    --hairline: #e4ded0;
    --ink: #142320;
    --slate: #5c6d67;
    --slate-light: #8b9b95;
    --ball: #d7e05a;
    --ball-ink: #2b3400;
    --clay: #b5402e;
    --clay-bg: #fbe9e5;
    --ok: #2f7a55;
    --ok-bg: #e6f2ea;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 35, 32, 0.06), 0 8px 24px -12px rgba(20, 35, 32, 0.18);
    font-size: 16px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--chalk);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.01em;
}

a {
    color: inherit;
}

.eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--slate);
}

/* --- signature mark: angolo di linee, come lo spigolo di un campo --- */
.court-mark {
    width: 30px;
    height: 30px;
    position: relative;
    flex-shrink: 0;
}

    .court-mark::before,
    .court-mark::after {
        content: "";
        position: absolute;
        background: currentColor;
    }

    .court-mark::before {
        top: 0;
        left: 0;
        width: 100%;
        height: 2px;
    }

    .court-mark::after {
        top: 0;
        left: 0;
        width: 2px;
        height: 100%;
    }

    .court-mark span {
        display: none;
    }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ball);
}

.brand-name {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--paper);
}

    .brand-name b {
        color: var(--ball);
    }

/* =====================================================================
   AUTH LAYOUT (login / register) — pannello scuro + pannello chiaro
   ===================================================================== */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
}

@media (max-width: 860px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-side {
        display: none;
    }
}

.auth-side {
    background: var(--court);
    color: var(--paper);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    background-image: repeating-linear-gradient(0deg, var(--court-line) 0 1px, transparent 1px 96px), repeating-linear-gradient(90deg, var(--court-line) 0 1px, transparent 1px 96px);
}

    .auth-side::after {
        content: "";
        position: absolute;
        right: -140px;
        bottom: -140px;
        width: 380px;
        height: 380px;
        border: 2px solid var(--court-line);
        border-radius: 50%;
    }

.auth-side-copy {
    max-width: 380px;
}

    .auth-side-copy .eyebrow {
        color: var(--ball);
        margin-bottom: 14px;
    }

    .auth-side-copy h1 {
        font-size: 2.1rem;
        line-height: 1.15;
        color: var(--paper);
        margin-bottom: 16px;
    }

    .auth-side-copy p {
        color: rgba(246, 244, 236, 0.72);
        font-size: 0.98rem;
        line-height: 1.6;
    }

.auth-side-foot {
    font-size: 0.8rem;
    color: rgba(246, 244, 236, 0.45);
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

    .auth-card .eyebrow {
        margin-bottom: 10px;
    }

    .auth-card h2 {
        font-size: 1.6rem;
        margin-bottom: 6px;
    }

    .auth-card .sub {
        color: var(--slate);
        font-size: 0.94rem;
        margin-bottom: 28px;
    }

    .auth-card.wide {
        max-width: 560px;
    }

/* =====================================================================
   FORM ELEMENTS
   ===================================================================== */
.field {
    margin-bottom: 16px;
}

    .field label {
        display: block;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--ink);
        margin-bottom: 6px;
    }

    .field .hint {
        font-size: 0.78rem;
        color: var(--slate-light);
        margin-top: 4px;
    }

    .field input, .field select {
        width: 100%;
        padding: 11px 13px;
        border: 1px solid var(--hairline);
        border-radius: 8px;
        background: var(--paper);
        font-size: 0.95rem;
        color: var(--ink);
        font-family: inherit;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

        .field input:focus, .field select:focus {
            outline: none;
            border-color: var(--court-light);
            box-shadow: 0 0 0 3px rgba(31, 77, 68, 0.14);
        }

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 520px) {
    .field-row {
        grid-template-columns: 1fr;
    }
}

.divider-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 26px 0 16px;
}

    .divider-label span {
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--slate-light);
        white-space: nowrap;
    }

    .divider-label::before, .divider-label::after {
        content: "";
        height: 1px;
        background: var(--hairline);
        flex: 1;
    }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 18px;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.05s ease, opacity 0.15s ease;
}

    .btn:active {
        transform: translateY(1px);
    }

    .btn:disabled {
        opacity: 0.6;
        cursor: default;
    }

.btn-primary {
    background: var(--court);
    color: var(--paper);
}

    .btn-primary:hover:not(:disabled) {
        background: var(--court-light);
    }

.btn-accent {
    background: var(--ball);
    color: var(--ball-ink);
}

    .btn-accent:hover:not(:disabled) {
        filter: brightness(1.04);
    }

.btn-ghost {
    background: transparent;
    color: var(--slate);
    border: 1px solid var(--hairline);
    width: auto;
}

    .btn-ghost:hover {
        border-color: var(--slate-light);
        color: var(--ink);
    }

.btn-small {
    width: auto;
    padding: 8px 14px;
    font-size: 0.85rem;
}

.btn-danger {
    background: var(--clay-bg);
    color: var(--clay);
}

.foot-link {
    text-align: center;
    margin-top: 22px;
    font-size: 0.88rem;
    color: var(--slate);
}

    .foot-link a {
        font-weight: 700;
        color: var(--court);
        text-decoration: none;
    }

        .foot-link a:hover {
            text-decoration: underline;
        }

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.87rem;
    margin-bottom: 18px;
    display: none;
}

    .alert.show {
        display: block;
    }

.alert-error {
    background: var(--clay-bg);
    color: var(--clay);
    border: 1px solid rgba(181, 64, 46, 0.18);
}

.alert-ok {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid rgba(47, 122, 85, 0.18);
}

.code-check {
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.84rem;
    margin-top: 8px;
    display: none;
    align-items: center;
    gap: 8px;
}

    .code-check.show {
        display: flex;
    }

/* =====================================================================
   LANDING PUBBLICA (/) — pagina neutra, non promuove la registrazione
   ===================================================================== */
.landing-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--court);
    position: relative;
    overflow: hidden;
    background-image: repeating-linear-gradient(0deg, var(--court-line) 0 1px, transparent 1px 96px), repeating-linear-gradient(90deg, var(--court-line) 0 1px, transparent 1px 96px);
}

    .landing-shell::after {
        content: "";
        position: absolute;
        right: -140px;
        bottom: -140px;
        width: 380px;
        height: 380px;
        border: 2px solid var(--court-line);
        border-radius: 50%;
    }

.landing-card {
    position: relative;
    z-index: 1;
    background: var(--paper);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px -20px rgba(20, 35, 32, 0.4);
    padding: 44px 40px;
    max-width: 440px;
    width: 100%;
    text-align: center;
}

    .landing-card .brand {
        justify-content: center;
        color: var(--court);
        margin-bottom: 26px;
    }

    .landing-card .brand-name {
        color: var(--ink);
    }

        .landing-card .brand-name b {
            color: var(--court);
        }

    .landing-card h1 {
        font-size: 1.35rem;
        line-height: 1.3;
        margin-bottom: 12px;
    }

    .landing-card p {
        color: var(--slate);
        font-size: 0.92rem;
        line-height: 1.6;
        margin-bottom: 30px;
    }

.landing-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .landing-actions .btn {
        text-decoration: none;
    }

.landing-foot {
    margin-top: 22px;
    font-size: 0.78rem;
    color: var(--slate-light);
    line-height: 1.5;
}

.player-search {
    position: relative;
}

    .player-search.has-selection input {
        border-color: var(--ok);
        background: var(--ok-bg);
        font-weight: 600;
    }

.player-results {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-height: 220px;
    overflow-y: auto;
    z-index: 10;
}

    .player-results.show {
        display: block;
    }

.player-result-item {
    padding: 10px 12px;
    font-size: 0.86rem;
    cursor: pointer;
    border-bottom: 1px solid var(--hairline);
}

    .player-result-item:last-child {
        border-bottom: none;
    }

    .player-result-item:hover {
        background: var(--chalk);
    }

    .player-result-item .email {
        color: var(--slate-light);
        font-size: 0.78rem;
    }

.player-result-empty {
    padding: 10px 12px;
    font-size: 0.82rem;
    color: var(--slate-light);
}

/* =====================================================================
   DASHBOARD LAYOUT
   ===================================================================== */
.app-shell {
    min-height: 100vh;
    display: grid;
    /* MODIFICATO: minmax(0, 1fr) invece di 1fr, così un contenuto largo non allarga la colonna oltre lo schermo */
    grid-template-columns: 240px minmax(0, 1fr);
}

@media (max-width: 780px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        display: none;
    }
}

.sidebar {
    background: var(--court);
    color: var(--paper);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

    .sidebar .brand {
        padding: 0 6px 18px;
        border-bottom: 1px solid var(--court-line);
    }

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: rgba(246, 244, 236, 0.68);
    cursor: pointer;
    border: none;
    background: transparent;
    text-align: left;
    font-family: inherit;
    width: 100%;
}

    .nav-item:hover {
        color: var(--paper);
        background: rgba(255, 255, 255, 0.05);
    }

    .nav-item.active {
        color: var(--ball-ink);
        background: var(--ball);
    }

.sidebar-foot {
    margin-top: auto;
}

    .sidebar-foot .btn-ghost {
        color: rgba(246, 244, 236, 0.7);
        border-color: var(--court-line);
        width: 100%;
    }

        .sidebar-foot .btn-ghost:hover {
            color: var(--paper);
            border-color: rgba(255,255,255,0.3);
        }

/* MODIFICATO: niente più larghezza massima di 1100px, le card occupano tutto lo spazio disponibile */
.main {
    padding: 32px 40px;
    min-width: 0;
}

@media (max-width: 780px) {
    .main {
        padding: 20px;
    }
}

.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

    .topbar h1 {
        font-size: 1.5rem;
    }

    .topbar .sub {
        color: var(--slate);
        font-size: 0.92rem;
        margin-top: 4px;
    }

.view {
    display: none;
}

    .view.active {
        display: block;
    }

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 16px 18px;
}

    .stat-card .num {
        font-size: 1.7rem;
        font-weight: 800;
        font-variant-numeric: tabular-nums;
    }

    .stat-card .label {
        font-size: 0.78rem;
        color: var(--slate);
        margin-top: 2px;
    }

.card {
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--hairline);
    gap: 12px;
    flex-wrap: wrap;
}

    .card-head h3 {
        font-size: 1.02rem;
    }

    .card-head .sub {
        font-size: 0.82rem;
        color: var(--slate);
        margin-top: 2px;
    }

.card-body {
    padding: 20px 22px;
}

    .card-body.pad-0 {
        padding: 0;
        /* NUOVO: su schermi stretti la tabella scorre dentro la card invece di uscirne */
        overflow-x: auto;
    }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--slate-light);
    padding: 12px 22px;
    border-bottom: 1px solid var(--hairline);
    white-space: nowrap; /* NUOVO: le intestazioni non vanno a capo ("NOME CAMPO") */
}

tbody td {
    padding: 14px 22px;
    border-bottom: 1px solid var(--hairline);
    font-size: 0.9rem;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(22, 56, 50, 0.02);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok);
}

.badge-off {
    background: var(--clay-bg);
    color: var(--clay);
}

.badge-role {
    background: var(--chalk);
    color: var(--slate);
    border: 1px solid var(--hairline);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--slate);
}

    .empty-state .court-mark {
        margin: 0 auto 14px;
        color: var(--slate-light);
    }

    .empty-state p {
        font-size: 0.88rem;
    }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 35, 32, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}

    .modal-backdrop.show {
        display: flex;
    }

.modal {
    background: var(--paper);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    padding: 26px;
    box-shadow: 0 20px 60px -20px rgba(20, 35, 32, 0.4);
}

    .modal h3 {
        margin-bottom: 4px;
    }

    .modal .sub {
        color: var(--slate);
        font-size: 0.86rem;
        margin-bottom: 20px;
    }

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
}

    .modal-actions .btn {
        width: auto;
        flex: 1;
    }

.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* MODIFICATO: la classe sta su un <td>. Con display:flex la cella usciva dalla tabella
   e, se vuota (es. operatore reception, riga dell'utente collegato), collassava ad
   altezza zero spostando i bordi delle righe. Ora resta una cella normale. */
.row-actions {
    text-align: right;
}

    /* i pulsanti vanno a capo come blocchi interi, mai a metà testo */
    .row-actions > * {
        vertical-align: middle;
        white-space: nowrap;
        margin: 3px 0 3px 4px;
    }

/* NUOVO: le etichette di stato nelle tabelle ("Tablet offline", ...) non si spezzano su più righe */
tbody td .badge {
    white-space: nowrap;
    margin: 2px 0;
}

.center-tag {
    font-size: 0.8rem;
    color: rgba(246, 244, 236, 0.55);
    padding: 0 6px;
}

.monitor-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--hairline);
    font-size: 0.85rem;
}

    .monitor-row:last-child {
        border-bottom: none;
    }

    .monitor-row .email {
        color: var(--slate-light);
        font-size: 0.78rem;
    }

/* ---------------------------------------------------------------------
   NUOVO — Comandi riservati (dashboard)
   Un elemento con data-roles="admin" o data-roles="admin manager" si vede solo
   se il ruolo dell'operatore (body[data-role], impostato da dashboard.js) è nell'elenco.
   Finché il ruolo non è noto restano nascosti: niente pulsanti che compaiono e spariscono.
   Solo comodità: i permessi veri li controlla il server (require_role).
   --------------------------------------------------------------------- */
body:not([data-role="admin"]) [data-roles="admin"],
body:not([data-role="admin"]):not([data-role="manager"]) [data-roles="admin manager"] {
    display: none !important;
}
