:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(22, 30, 46, 0.85);
    --panel-bg: rgba(15, 23, 42, 0.6);

    --cyan-neon: #00d2ff;
    --cyan-glow: rgba(0, 210, 255, 0.4);

    --red-neon: #ff4757;
    --red-glow: rgba(255, 71, 87, 0.4);

    --green-neon: #2ed573;

    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --border-color: #2a364f;
}


/* =====================================================
   RESET
===================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}


/* =====================================================
   HTML / BODY
===================================================== */

html {
    width: 100%;
    min-height: 100%;
}

body {
    width: 100%;
    min-height: 100vh;
    min-height: 100svh;

    background-color: var(--bg-color);
    color: var(--text-primary);

    padding:
        max(20px, env(safe-area-inset-top))
        max(20px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom))
        max(20px, env(safe-area-inset-left));

    /*
       IMPORTANTE:
       flex + margin:auto sui riquadri.
       Se il riquadro entra nello schermo viene
       centrato verticalmente.
       Se è più alto dello schermo, parte dall'alto
       senza essere tagliato.
    */
    display: flex;
    flex-direction: column;

    overflow-x: hidden;
    overflow-y: auto;

    -webkit-overflow-scrolling: touch;
}


/* =====================================================
   SCHERMATE PRINCIPALI
===================================================== */

#login-screen,
#dashboard-screen {
    width: 100%;
    margin: auto;
}


/* =====================================================
   CARD
===================================================== */

.card {
    background: var(--card-bg);

    border: 1px solid var(--border-color);
    border-radius: 24px;

    padding: 32px 24px;

    width: 100%;
    max-width: 400px;

    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.5);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    text-align: center;

    transition:
        transform 0.3s ease,
        box-shadow 0.3s ease;
}


/* =====================================================
   NASCOSTO
===================================================== */

.hidden {
    display: none !important;
}


/* =====================================================
   LOGO
===================================================== */

.logo {
    font-size: 2rem;

    letter-spacing: 2px;

    margin-bottom: 8px;

    font-weight: 800;
}

.logo span {
    color: var(--cyan-neon);

    text-shadow:
        0 0 12px var(--cyan-glow);
}


/* =====================================================
   TESTI
===================================================== */

.subtitle {
    color: var(--text-secondary);

    font-size: 0.95rem;

    margin-bottom: 24px;

    line-height: 1.5;
}

.small-text {
    color: var(--text-secondary);

    font-size: 0.8rem;

    margin-top: 8px;
    margin-bottom: 24px;

    line-height: 1.4;
}


/* =====================================================
   INPUT
===================================================== */

input[type="text"],
input[type="time"],
input[type="number"],
input[type="datetime-local"],
textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;

    display: block;

    padding: 16px;

    border-radius: 12px;

    background: #131b2e;

    border: 1px solid var(--border-color);

    color: #fff;

    font-size: 1.1rem;

    text-align: center;

    outline: none;

    appearance: none;
    -webkit-appearance: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

textarea {
    min-height: 120px;

    resize: vertical;

    text-align: left;

    line-height: 1.5;

    margin-bottom: 12px;
}

input::placeholder,
textarea::placeholder {
    color: #71809b;
}

input[type="text"]:focus,
input[type="time"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
textarea:focus {
    border-color: var(--cyan-neon);

    box-shadow:
        0 0 10px var(--cyan-glow);
}


/* =====================================================
   BUTTONS
===================================================== */

.btn {
    width: 100%;

    padding: 16px;

    border-radius: 14px;

    border: none;

    font-size: 1rem;

    font-weight: bold;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease;

    letter-spacing: 1px;

    min-width: 0;

    -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
    background: var(--cyan-neon);

    color: #000;

    box-shadow:
        0 0 15px var(--cyan-glow);
}

.btn-primary:hover {
    box-shadow:
        0 0 25px var(--cyan-glow);
}

.btn-danger {
    background: var(--red-neon);

    color: #fff;

    box-shadow:
        0 0 15px var(--red-glow);
}

.btn-success {
    background: var(--green-neon);

    color: #000;

    box-shadow:
        0 0 15px rgba(46, 213, 115, 0.3);
}

.btn-secondary {
    background: transparent;

    color: var(--text-secondary);

    margin-top: 8px;
}

.btn-secondary:hover {
    color: #fff;
}


/* =====================================================
   PULSANTE ICONA
===================================================== */

.btn-icon {
    background: none;

    border: none;

    font-size: 1.4rem;

    cursor: pointer;

    flex-shrink: 0;

    padding: 6px;

    line-height: 1;
}


/* =====================================================
   HEADER
===================================================== */

.header {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 15px;

    margin-bottom: 24px;
}

.header h2 {
    min-width: 0;

    overflow-wrap: anywhere;
}


/* =====================================================
   STATO PLAY
===================================================== */

.status-box {
    padding: 20px;

    border-radius: 16px;

    margin-bottom: 24px;

    border: 1px solid transparent;

    overflow-wrap: anywhere;
}

.status-box h3 {
    margin-bottom: 8px;

    font-size: 1.2rem;
}

.status-box p {
    font-size: 1rem;

    line-height: 1.5;
}

.status-box.available {
    background: rgba(0, 210, 255, 0.05);

    border-color: var(--cyan-neon);

    color: var(--cyan-neon);
}

.status-box.booked {
    background: rgba(255, 71, 87, 0.05);

    border-color: var(--red-neon);

    color: var(--red-neon);
}


/* =====================================================
   TIMER
===================================================== */

.timer-container {
    position: relative;

    width: 200px;
    height: 200px;

    margin: 20px auto;

    max-width: 100%;
}

.timer-ring {
    display: block;

    width: 200px;
    height: 200px;

    max-width: 100%;

    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;

    stroke: #1e293b;

    stroke-width: 10;
}

.timer-ring-progress {
    fill: none;

    stroke: var(--cyan-neon);

    stroke-width: 10;

    stroke-linecap: round;

    transition:
        stroke-dashoffset 0.5s linear;
}

.timer-text {
    position: absolute;

    top: 50%;
    left: 50%;

    transform:
        translate(-50%, -50%);

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    width: 100%;

    pointer-events: none;
}

.timer-label {
    font-size: 0.75rem;

    color: var(--text-secondary);

    letter-spacing: 1px;
}

#countdown {
    font-size: 1.6rem;

    font-weight: bold;

    letter-spacing: 2px;

    white-space: nowrap;
}


/* =====================================================
   AZIONI
===================================================== */

.actions {
    display: flex;

    flex-direction: column;

    gap: 10px;
}


/* =====================================================
   DASHBOARD
===================================================== */

.dashboard-grid {
    display: flex;

    flex-direction: column;

    gap: 20px;
}

.grid-section {
    width: 100%;
    min-width: 0;
}


/* =====================================================
   PANEL
===================================================== */

.panel-box {
    background: var(--panel-bg);

    border: 1px solid var(--border-color);

    border-radius: 16px;

    padding: 16px;

    margin-top: 16px;

    text-align: left;

    min-width: 0;

    overflow: hidden;
}

.panel-title {
    font-size: 0.95rem;

    color: var(--cyan-neon);

    margin-bottom: 12px;

    letter-spacing: 0.5px;

    line-height: 1.4;
}

.empty-msg {
    font-size: 0.85rem;

    color: var(--text-secondary);

    text-align: center;

    padding: 10px 0;

    line-height: 1.5;
}


/* =====================================================
   CRONOLOGIA
===================================================== */

.history-list {
    list-style: none;

    max-height: 160px;

    overflow-y: auto;

    min-width: 0;

    -webkit-overflow-scrolling: touch;
}

.history-item {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 10px;

    padding: 8px 10px;

    border-bottom:
        1px solid rgba(255, 255, 255, 0.05);

    font-size: 0.85rem;

    min-width: 0;
}

.history-item:last-child {
    border-bottom: none;
}

.history-user {
    font-weight: bold;

    color: var(--text-primary);

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

    min-width: 0;
}

.history-time {
    color: var(--text-secondary);

    font-size: 0.78rem;

    white-space: nowrap;
}


/* =====================================================
   STATISTICHE
===================================================== */

.stat-row {
    display: flex;

    justify-content: space-between;

    gap: 10px;

    margin-bottom: 6px;

    font-size: 0.85rem;
}

.progress-bar-bg {
    background: #1e293b;

    border-radius: 8px;

    height: 8px;

    width: 100%;

    overflow: hidden;

    margin-bottom: 12px;
}

.progress-bar-fill {
    background: var(--cyan-neon);

    height: 100%;

    width: 0%;

    transition:
        width 0.4s ease;
}


/* =====================================================
   MODALI
===================================================== */

.overlay,
.system-overlay {
    position: fixed;

    inset: 0;

    width: 100%;
    height: 100%;

    background: rgba(0, 0, 0, 0.7);

    display: flex;

    justify-content: center;
    align-items: center;

    padding:
        max(20px, env(safe-area-inset-top))
        max(20px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom))
        max(20px, env(safe-area-inset-left));

    z-index: 100;

    overflow-y: auto;

    -webkit-overflow-scrolling: touch;
}


/* =====================================================
   MODALE PRENOTAZIONE
===================================================== */

.modal-content {
    width: min(100%, 400px);

    max-width: 400px;

    min-width: 0;

    max-height: calc(100dvh - 40px);

    overflow-y: auto;

    overflow-x: hidden;

    margin: auto;

    flex-shrink: 1;
}


/* =====================================================
   POPUP SISTEMA
===================================================== */

.system-popup {
    width: min(100%, 430px);

    max-width: 430px;

    max-height: calc(100dvh - 40px);

    overflow-y: auto;

    margin: auto;

    padding: 28px 24px;

    background: var(--card-bg);

    border:
        1px solid var(--border-color);

    border-radius: 22px;

    text-align: center;

    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.6);

    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.system-icon {
    font-size: 3rem;

    margin-bottom: 12px;
}

.system-popup h2 {
    margin-bottom: 12px;

    font-size: 1.4rem;
}

.system-popup p {
    color: var(--text-secondary);

    line-height: 1.5;

    margin-bottom: 20px;
}


/* =====================================================
   INPUT ORARI
===================================================== */

.time-input-group {
    width: 100%;

    min-width: 0;

    margin-top: 8px;

    text-align: left;
}

.time-input-group label {
    display: block;

    margin-bottom: 6px;

    color: var(--text-secondary);

    font-size: 0.9rem;
}

.time-input-group input {
    width: 100% !important;

    max-width: 100% !important;

    min-width: 0 !important;

    margin: 0;
}


/* =====================================================
   PULSANTI ORARIO
===================================================== */

.time-buttons {
    display: flex;

    gap: 8px;

    margin-bottom: 10px;

    flex-wrap: wrap;
}

.time-buttons .btn-chip {
    flex: 1;

    min-width: 120px;
}


/* =====================================================
   QUICK ADD
===================================================== */

.quick-add {
    display: flex;

    gap: 10px;

    margin: 16px 0;

    justify-content: center;

    flex-wrap: wrap;
}

.btn-chip {
    background: #1e293b;

    border:
        1px solid var(--border-color);

    color: #fff;

    padding: 8px 16px;

    border-radius: 20px;

    cursor: pointer;

    flex-shrink: 0;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease;
}

.btn-chip:hover {
    border-color: var(--cyan-neon);
}

.btn-chip:active {
    transform: scale(0.96);
}


/* =====================================================
   AZIONI MODALE
===================================================== */

.modal-actions {
    width: 100%;

    min-width: 0;

    display: flex;

    flex-direction: column;

    gap: 8px;
}

.modal-actions .btn {
    max-width: 100%;
}


/* =====================================================
   SCADENZA SESSIONE
===================================================== */

.expired-actions {
    width: 100%;

    margin-top: 12px;

    display: flex;

    flex-direction: column;

    gap: 10px;
}

.expired-minutes-group {
    width: 100%;

    display: flex;

    gap: 8px;

    align-items: stretch;

    min-width: 0;
}

.expired-minutes-group input {
    flex: 1;

    min-width: 0;

    width: auto;

    padding: 12px 10px;

    font-size: 1rem;
}

.expired-minutes-group button {
    flex: 1;

    min-width: 0;

    padding: 12px 8px;

    font-size: 0.85rem;
}

.expired-quick {
    display: flex;

    gap: 8px;

    justify-content: center;

    flex-wrap: wrap;
}

.expired-quick .btn-chip {
    padding: 8px 14px;
}


/* =====================================================
   ADMIN
===================================================== */

.admin-panel {
    width: 100%;

    margin-top: 28px;

    padding-top: 24px;

    border-top:
        1px solid var(--border-color);

    text-align: left;
}

.admin-header {
    margin-bottom: 18px;

    padding: 16px;

    border-radius: 16px;

    background:
        rgba(255, 215, 0, 0.05);

    border:
        1px solid rgba(255, 215, 0, 0.25);
}

.admin-header h2 {
    color: #ffd700;

    margin-bottom: 6px;

    font-size: 1.2rem;
}

.admin-header span {
    color: var(--text-secondary);

    font-size: 0.8rem;
}


/* =====================================================
   ADMIN GRID
===================================================== */

.admin-grid {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 10px;

    margin-bottom: 18px;
}

.admin-btn {
    width: 100%;

    padding: 13px 10px;

    border-radius: 12px;

    border:
        1px solid var(--border-color);

    background: #172033;

    color: #fff;

    font-size: 0.82rem;

    font-weight: bold;

    cursor: pointer;

    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        transform 0.15s ease;
}

.admin-btn:hover {
    border-color: var(--cyan-neon);

    background: #1b2940;
}

.admin-btn:active {
    transform: scale(0.98);
}

.danger-admin {
    border-color:
        rgba(255, 71, 87, 0.45);

    color: #ff6b78;
}

.danger-admin:hover {
    border-color: var(--red-neon);

    background:
        rgba(255, 71, 87, 0.08);
}


/* =====================================================
   BOX ADMIN
===================================================== */

.admin-booking-box {
    background:
        rgba(15, 23, 42, 0.7);

    border:
        1px solid var(--border-color);

    border-radius: 16px;

    padding: 16px;

    margin-top: 14px;

    min-width: 0;

    overflow: hidden;
}

.admin-booking-box h3 {
    color: var(--cyan-neon);

    font-size: 0.95rem;

    margin-bottom: 14px;
}

.admin-booking-box input,
.admin-booking-box textarea {
    margin-bottom: 10px;
}


/* =====================================================
   ADMIN PRENOTAZIONE ATTUALE
===================================================== */

#admin-current-booking {
    color: var(--text-secondary);

    font-size: 0.9rem;

    line-height: 1.6;

    overflow-wrap: anywhere;
}


/* =====================================================
   ADMIN STATISTICHE
===================================================== */

#admin-stats {
    color: var(--text-secondary);

    font-size: 0.9rem;

    line-height: 1.7;

    overflow-wrap: anywhere;
}


/* =====================================================
   MESSAGGIO GLOBALE
===================================================== */

#global-message-text {
    white-space: pre-wrap;

    overflow-wrap: anywhere;
}


/* =====================================================
   ACCESSIBILITÀ / TOUCH
===================================================== */

button,
input,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button {
    touch-action: manipulation;
}


/* =====================================================
   RESPONSIVE TELEFONI
===================================================== */

@media (max-width: 480px) {

    body {
        padding:
            max(12px, env(safe-area-inset-top))
            max(12px, env(safe-area-inset-right))
            max(12px, env(safe-area-inset-bottom))
            max(12px, env(safe-area-inset-left));
    }

    .card {
        padding: 26px 18px;

        border-radius: 22px;
    }

    .logo {
        font-size: 1.8rem;
    }

    .modal-content {
        width: 100%;

        max-width: 400px;

        max-height: calc(100dvh - 24px);
    }

    .system-popup {
        width: 100%;

        max-height: calc(100dvh - 24px);

        padding: 24px 18px;
    }

    .history-item {
        align-items: flex-start;

        flex-direction: column;

        gap: 3px;
    }

    .history-time {
        white-space: normal;
    }

    .stat-row {
        align-items: flex-start;

        flex-direction: column;

        gap: 3px;
    }

    .expired-minutes-group {
        flex-direction: column;
    }

    .expired-minutes-group input,
    .expired-minutes-group button {
        width: 100%;
    }

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

    .time-buttons {
        flex-direction: column;
    }

    .time-buttons .btn-chip {
        width: 100%;
    }
}


/* =====================================================
   TABLET / DESKTOP
===================================================== */

@media (min-width: 768px) {

    #login-screen {
        max-width: 400px;
    }

    #dashboard-screen {
        max-width: 850px;

        padding: 36px;
    }

    .dashboard-grid {
        display: grid;

        grid-template-columns: 1fr 1fr;

        gap: 24px;

        align-items: start;
    }

    .panel-box {
        margin-top: 0;

        margin-bottom: 16px;
    }

    .admin-panel {
        grid-column: 1 / -1;
    }
}


/* =====================================================
   SCHERMI MOLTO BASSI
===================================================== */

@media (max-height: 650px) {

    body {
        align-items: flex-start;
    }

    #login-screen,
    #dashboard-screen {
        margin-top: 20px;
        margin-bottom: 20px;
    }
}
/* =====================================================
   PLAYBOOKING V2 - AZIONI SESSIONE / ADMIN
===================================================== */
.expired-actions { gap: 12px; }
.expired-quick, .admin-extension, .admin-action-row { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-top:10px; }
.expired-quick .btn-chip, .admin-extension .btn-chip { flex:0 0 auto; }
.expired-custom { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; width:100%; }
.expired-custom input, .admin-extension input { min-width:0; width:100%; padding:12px; }
.admin-action-row .btn { flex:1 1 180px; }
.admin-extension { padding-top:12px; border-top:1px solid var(--border-color); }
.admin-extension > span { color:var(--text-secondary); font-size:.85rem; }
.important-admin-box { border-color:rgba(255,71,87,.55); box-shadow:0 0 20px rgba(255,71,87,.08); }
.important-admin-box h3 { color:#ff6b78; }
.important-message-overlay { background:rgba(40,0,5,.82); z-index:120; }
.important-message-overlay .system-popup { border-color:#ff4757; box-shadow:0 0 35px rgba(255,71,87,.35); }
.important-message-overlay .system-popup h2 { color:#ff6b78; }
@media (max-width:480px) {
  .expired-quick { display:grid; grid-template-columns:repeat(3,1fr); width:100%; }
  .expired-quick .btn-chip { width:100%; padding:10px 6px; }
  .expired-custom { grid-template-columns:1fr; }
  .admin-extension { display:grid; grid-template-columns:repeat(3,1fr); }
  .admin-extension > span { grid-column:1/-1; }
  .admin-extension input { grid-column:1/3; }
  .admin-extension #admin-extension-custom { grid-column:3; }
}
/* =====================================================
   ADMIN - MESSAGGIO IMPORTANTE
   ===================================================== */

.important-admin-box #admin-send-important-btn,
.important-admin-box #admin-clear-important-btn {
    display: block;
    width: 100%;
}

.important-admin-box #admin-send-important-btn {
    margin-bottom: 14px !important;
}
