/* Badge Online — interfaccia dei backend (piattaforma e cliente) */

:root {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --accent: #0f172a;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --text: #0f172a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    --ok: #059669;
    --ok-bg: #ecfdf5;
    --warn: #d97706;
    --warn-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #0284c7;
    --info-bg: #f0f9ff;

    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 12px rgba(15, 23, 42, .08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);

    --sidebar-width: 250px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 1rem; }
small { font-size: .82rem; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- impalcatura */

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

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--accent);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    display: flex;
    align-items: center;
    gap: .7rem;
}

.sidebar__brand img {
    max-width: 40px;
    max-height: 40px;
    border-radius: 8px;
    background: #fff;
    padding: 3px;
}

.sidebar__mark {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .95rem;
    flex-shrink: 0;
}

.sidebar__title {
    font-weight: 650;
    color: #fff;
    font-size: .98rem;
    line-height: 1.2;
}

.sidebar__subtitle {
    font-size: .76rem;
    color: #94a3b8;
}

.sidebar nav {
    padding: .75rem .6rem;
    flex: 1;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .7rem;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: .92rem;
    margin-bottom: 2px;
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
    text-decoration: none;
}

.sidebar nav a.is-active {
    background: var(--brand);
    color: #fff;
    font-weight: 550;
}

.sidebar nav .nav-group {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    padding: 1rem .7rem .35rem;
}

.sidebar__footer {
    padding: .9rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
    font-size: .82rem;
}

.sidebar__footer .user-name { color: #fff; font-weight: 550; }
.sidebar__footer .user-mail { color: #94a3b8; word-break: break-all; }

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .9rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar h1 { margin: 0; font-size: 1.25rem; }
.topbar .topbar__actions { display: flex; gap: .5rem; align-items: center; }

.content {
    padding: 1.5rem 1.75rem 3rem;
    max-width: 1400px;
    width: 100%;
}

/* ------------------------------------------------------------------- carte */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.card__header h2 { margin: 0; font-size: 1.02rem; }
.card__header p { margin: .15rem 0 0; font-size: .85rem; color: var(--text-muted); }

.card__body { padding: 1.25rem; }
.card__body--flush { padding: 0; }
.card__footer {
    padding: .9rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
}

/* ------------------------------------------------------------------ griglie */

.grid { display: grid; gap: 1.25rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat__label {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 600;
}

.stat__value {
    font-size: 1.85rem;
    font-weight: 680;
    line-height: 1.15;
    margin-top: .35rem;
    font-variant-numeric: tabular-nums;
}

.stat__hint { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }
.stat--ok .stat__value { color: var(--ok); }
.stat--warn .stat__value { color: var(--warn); }
.stat--danger .stat__value { color: var(--danger); }

/* ------------------------------------------------------------------ tabelle */

.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

table.data th {
    text-align: left;
    padding: .65rem 1rem;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    font-weight: 650;
    white-space: nowrap;
}

table.data td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-alt); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

/* ------------------------------------------------------------------ moduli */

.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }

label, .label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .3rem;
    color: #334155;
}

.hint { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=time], input[type=search],
input[type=month], input[type=tel], select, textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color .12s, box-shadow .12s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

input[type=color] {
    width: 54px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
}

textarea { min-height: 90px; resize: vertical; }

.check {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    margin-bottom: .6rem;
    font-size: .9rem;
}

.check input { width: 17px; height: 17px; margin-top: 2px; flex-shrink: 0; }
.check label { margin: 0; font-weight: 500; }

.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

.filters {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filters .field { margin-bottom: 0; min-width: 150px; }

/* ------------------------------------------------------------------ bottoni */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .5rem .95rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 550;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s, border-color .12s, opacity .12s;
    white-space: nowrap;
}

.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn--ghost {
    background: #fff;
    color: var(--text);
    border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #b91c1c; }

.btn--sm { padding: .32rem .65rem; font-size: .82rem; }
.btn--block { width: 100%; }

.btn-link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--brand);
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
}
.btn-link--danger { color: var(--danger); }

/* ------------------------------------------------------------------ badge */

.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .16rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.5;
    background: var(--surface-alt);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.badge--ok { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.badge--warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.badge--danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.badge--info { background: var(--info-bg); color: var(--info); border-color: #bae6fd; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--in { background: var(--ok); }
.dot--out { background: var(--text-faint); }

/* ------------------------------------------------------------------ avviso */

.alert {
    padding: .8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid;
    font-size: .9rem;
    display: flex;
    gap: .6rem;
    align-items: flex-start;
}

.alert--success { background: var(--ok-bg); border-color: #a7f3d0; color: #065f46; }
.alert--error { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.alert--warning { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }
.alert--info { background: var(--info-bg); border-color: #bae6fd; color: #075985; }
.alert ul { margin: .3rem 0 0; padding-left: 1.1rem; }

/* ------------------------------------------------------------------- login */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #334155 100%);
}

.auth__card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.auth__logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.auth__logo img { max-width: 160px; max-height: 70px; }

.auth__mark {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    font-weight: 700;
}

.auth h1 { text-align: center; font-size: 1.3rem; margin-bottom: .25rem; }
.auth__sub { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth__foot { text-align: center; margin-top: 1.25rem; font-size: .85rem; color: var(--text-muted); }

/* ------------------------------------------------------------------ avatar */

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: inline-grid;
    place-items: center;
    font-size: .78rem;
    font-weight: 650;
    flex-shrink: 0;
    object-fit: cover;
}

.person { display: flex; align-items: center; gap: .65rem; }
.person__name { font-weight: 550; }
.person__meta { font-size: .8rem; color: var(--text-muted); }

/* ------------------------------------------------------------- impaginazione */

.pagination {
    display: flex;
    gap: .35rem;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: .35rem .7rem;
    border-radius: 7px;
    border: 1px solid var(--border);
    font-size: .85rem;
    background: #fff;
    color: var(--text);
}

.pagination .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .is-disabled { color: var(--text-faint); background: var(--surface-alt); }

/* -------------------------------------------------------------- cartellino */

.timesheet td.day-off { background: #fafafa; color: var(--text-muted); }
.timesheet td.today { background: #eff6ff; }
.timesheet .anomaly-row td { background: var(--warn-bg); }

.codebox {
    background: var(--accent);
    color: #e2e8f0;
    padding: .9rem 1rem;
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.copy-row { display: flex; gap: .5rem; align-items: center; }
.copy-row input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

/* ----------------------------------------------------------------- tessera */

.badge-card {
    width: 320px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    padding: 1.25rem;
    background: #fff;
    text-align: center;
}

.badge-card__company { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.badge-card__name { font-size: 1.25rem; font-weight: 680; margin: .5rem 0 .1rem; }
.badge-card__qr { margin: 1rem auto; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 900px) {
    .shell { flex-direction: column; }

    .sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: static;
    }

    .sidebar nav { display: flex; flex-wrap: wrap; gap: .25rem; }
    .sidebar nav a { flex: 0 0 auto; }
    .sidebar nav .nav-group { display: none; }
    .sidebar__footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

    .content { padding: 1rem; }
    .topbar { padding: .8rem 1rem; }
}

@media print {
    .sidebar, .topbar, .no-print, .form-actions { display: none !important; }
    body { background: #fff; }
    .content { padding: 0; max-width: none; }
    .card { border: 0; box-shadow: none; margin-bottom: 1rem; }
    table.data th { background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
