/* =====================================================================
   CARTELLINO PRESENZE  (usa css/theme.css)
   ===================================================================== */

/* Alias usati dagli stili inline della pagina e di js/cartellino.js */
:root {
    --card-bg: var(--surface);
    --card-border: var(--line);
    --accent-blue: var(--brand);
    --accent-cyan: var(--amber);
    --accent-green: var(--ok);
    --accent-red: var(--danger);
    --text-main: var(--text);
    --text-muted: var(--text-3);
}

body { padding: 24px; }
.container { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.disclaimer-mini { max-width: 1280px; }

/* ------------------------- LAYOUT ------------------------- */
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }

/* ------------------------- TIMER ------------------------- */
.timer-hud {
    background:
        radial-gradient(420px 200px at 50% 0%, rgba(229, 56, 59, 0.16), transparent 70%),
        var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 38px 22px;
    text-align: center;
    box-shadow: var(--shadow);
}

.badge-status {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 16px; border-radius: 999px;
    font-size: 0.74rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-2);
    border: 1px solid var(--line-2);
    margin-bottom: 22px;
    transition: all 0.25s;
}
.badge-status.active {
    background: rgba(34, 197, 94, 0.14);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
    box-shadow: 0 0 22px rgba(34, 197, 94, 0.22);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge-status.active .status-dot { animation: pulse-dot 1.5s infinite; }
@keyframes pulse-dot {
    0%   { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
    70%  { transform: scale(1);    box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.timer-time {
    font-family: var(--mono);
    font-size: clamp(2.8rem, 8vw, 4.8rem);
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.12);
    margin-bottom: 12px;
}

/* ------------------------- STATISTICHE ------------------------- */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-val { font-size: 1.55rem; font-weight: 800; display: block; margin-top: 6px; }

/* ------------------------- STORICO ------------------------- */
.history-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; padding-right: 4px; }
.history-item {
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 12px 16px;
    border-radius: 11px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    font-size: 0.86rem;
}
.history-item:hover { border-color: var(--line-2); }

.week-nav {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--sunken);
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 4px 6px;
    font-size: 0.78rem; font-weight: 600; color: #ffb877;
}
.week-btn { background: transparent; border: none; color: var(--text); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; }
.week-btn:hover:not(:disabled) { background: rgba(229, 56, 59, 0.25); }
.week-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ------------------------- COLONNA LIVE ------------------------- */
.sidebar-live { display: flex; flex-direction: column; gap: 16px; }
.user-live-card {
    background: rgba(34, 197, 94, 0.07);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    padding: 14px;
}

/* ------------------------- PANNELLO GESTIONE CARTELLINI ------------------------- */
.gm-panel {
    width: 100%; max-width: 1120px; max-height: 94vh;
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 4px solid var(--brand);
    border-radius: 20px;
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.9);
    overflow: hidden;
}
.gm-head {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 18px 26px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(229, 56, 59, 0.12), transparent);
}
.gm-head h2 { font-size: 1.2rem; font-weight: 800; display: flex; align-items: center; gap: 12px; }
.gm-head h2 i { color: var(--amber); }
.gm-sub { font-size: 0.78rem; color: var(--text-3); font-weight: 500; margin-top: 2px; }

.gm-body { padding: 22px 26px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }

.gm-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.gm-kpi {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 14px; padding: 14px 16px;
    display: flex; align-items: center; gap: 14px;
}
.gm-kpi-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(229, 56, 59, 0.16); color: var(--amber);
    font-size: 1.1rem; flex-shrink: 0;
}
.gm-kpi-val { font-size: 1.4rem; font-weight: 800; display: block; line-height: 1.15; }

.gm-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }
.gm-section { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.gm-section h3 { font-size: 0.92rem; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.gm-section h3 i { color: var(--amber); }
.gm-count {
    margin-left: auto; font-size: 0.7rem; font-weight: 800;
    padding: 2px 10px; border-radius: 999px;
    background: rgba(229, 56, 59, 0.16); color: #fda4a4;
    border: 1px solid rgba(229, 56, 59, 0.35);
}
.gm-scroll { overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 8px; }

.rank-row {
    display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px;
    padding: 10px 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
}
.rank-pos {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.82rem;
    background: var(--surface-3); color: var(--text-2);
}
.rank-row.p1 { border-color: rgba(251, 191, 36, 0.5); background: linear-gradient(90deg, rgba(251, 191, 36, 0.12), var(--surface)); }
.rank-row.p1 .rank-pos { background: #fbbf24; color: #3b2300; }
.rank-row.p2 .rank-pos { background: #cbd5e1; color: #1e293b; }
.rank-row.p3 .rank-pos { background: #d97706; color: #2b1400; }
.rank-name { font-weight: 700; font-size: 0.88rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rank-meta { font-size: 0.74rem; color: var(--text-3); font-weight: 500; }
.rank-hours { font-family: var(--mono); font-weight: 700; color: var(--amber); font-size: 0.92rem; text-align: right; }

.open-card {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 12px 14px;
    background: rgba(34, 197, 94, 0.07); border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 11px;
}
.open-timer { font-family: var(--mono); font-weight: 700; color: #4ade80; font-size: 0.95rem; }

.reg-head, .reg-row {
    display: grid; grid-template-columns: 2.2fr 1.4fr 0.7fr 1fr 1fr 0.9fr;
    gap: 12px; align-items: center; padding: 10px 14px;
}
.reg-head {
    font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3);
    position: sticky; top: 0; background: var(--surface-3); border-radius: 8px; z-index: 2;
}
.reg-row { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; font-size: 0.85rem; }
.reg-row:hover { border-color: rgba(229, 56, 59, 0.45); }

.gm-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 16px 26px;
    border-top: 1px solid var(--line);
    background: var(--sunken);
}
.gm-foot small { color: var(--text-3); font-size: 0.78rem; line-height: 1.45; max-width: 600px; }
.btn-reset-week {
    background: linear-gradient(180deg, #ee4447, #8f1d21);
    color: #fff; border: 1px solid rgba(255, 255, 255, 0.14);
    min-height: 44px; padding: 0 22px; border-radius: 11px;
    font: 700 0.88rem var(--font); cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn-reset-week:hover:not(:disabled) { filter: brightness(1.15); }
.btn-reset-week:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; border: 1px dashed var(--line-2); }

/* ------------------------- RESPONSIVE ------------------------- */
@media (max-width: 960px) {
    .main-grid, .gm-cols { grid-template-columns: minmax(0, 1fr); }
    .gm-kpis { grid-template-columns: repeat(2, 1fr); }
    .reg-head { display: none; }
    .reg-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    body { padding: 14px; }
    .stats-grid { grid-template-columns: 1fr; }
    .gm-body, .gm-head, .gm-foot { padding-left: 16px; padding-right: 16px; }
}
