/* ============================================================
   TECNOTIMBRI — Pannello "Pressroom"
   Tema dedicato al gestionale (admin + area utente + auth).
   Indipendente dal CSS del sito pubblico (/assets/css/style.css).
   ============================================================ */

:root {
    --ink:         #17251E;   /* verde-nero: sidebar, titoli scuri */
    --ink-2:       #21362B;   /* hover su sidebar */
    --ink-line:    #2C4237;   /* separatori su sidebar */
    --brand:       #1F7A4D;   /* verde pressroom: azioni, attivo */
    --brand-strong:#185F3C;   /* hover azioni */
    --brand-tint:  rgba(31,122,77,.12);
    --paper:       #F1F4F0;   /* sfondo app (carta) */
    --surface:     #FFFFFF;   /* card, barre */
    --line:        #E2E7E2;   /* bordi hairline */
    --text:        #1B241F;   /* testo primario */
    --muted:       #6C766F;   /* testo secondario */
    --danger:      #B23B3B;
    --danger-tint: rgba(178,59,59,.10);
    --warn:        #B8863B;

    --radius:      14px;
    --radius-sm:   10px;
    --radius-pill: 999px;
    --shadow-sm:   0 1px 2px rgba(16,24,20,.05);
    --shadow:      0 1px 2px rgba(16,24,20,.04), 0 8px 24px rgba(16,24,20,.06);

    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --sidebar-w: 256px;
}

* { box-sizing: border-box; }

body.app {
    margin: 0;
    min-height: 100vh;
    background: var(--paper);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 15px;
    line-height: 1.5;
}

/* ---------- Layout shell ---------- */
.app-layout { display: flex; min-height: 100vh; }

.app-shell {
    flex: 1;
    min-width: 0;                 /* evita overflow tabelle */
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--ink);
    color: #C6D3CB;
    display: flex;
    flex-direction: column;
    z-index: 1040;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid var(--ink-line);
    color: #fff;
    text-decoration: none;
}
.app-brand .regmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-size: 1rem;
    flex: 0 0 auto;
}
.app-brand .wordmark {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: .01em;
    line-height: 1;
}
.app-brand .wordmark small {
    display: block;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: .62rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: #7E9488;
    margin-top: .18rem;
}

.app-nav {
    list-style: none;
    margin: 0;
    padding: .85rem .75rem;
    flex: 1;
    overflow-y: auto;
}
.app-nav .nav-section {
    font-size: .68rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #6E8378;
    padding: .9rem .75rem .35rem;
}
.app-nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .62rem .75rem;
    margin-bottom: .12rem;
    border-radius: var(--radius-sm);
    color: #C6D3CB;
    text-decoration: none;
    font-weight: 500;
    font-size: .92rem;
    transition: background .15s ease, color .15s ease;
}
.app-nav a .bi { font-size: 1.05rem; opacity: .9; }
.app-nav a:hover { background: var(--ink-2); color: #fff; }
.app-nav a.active {
    background: var(--brand-tint);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand);
}

.app-sidebar-foot {
    border-top: 1px solid var(--ink-line);
    padding: .85rem;
}
.app-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .35rem .5rem .7rem;
}
.app-user .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    flex: 0 0 auto;
}
.app-user .meta { min-width: 0; }
.app-user .meta .name { color: #fff; font-weight: 600; font-size: .88rem; line-height: 1.1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-user .meta .role { color: #7E9488; font-size: .72rem; text-transform: capitalize; }
.app-logout {
    display: flex; align-items: center; gap: .5rem; justify-content: center;
    width: 100%;
    padding: .55rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--ink-line);
    color: #C6D3CB;
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
}
.app-logout:hover { background: var(--ink-2); color: #fff; }

/* ---------- Topbar ---------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.75rem;
    background: rgba(255,255,255,.86);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.app-topbar .crumb {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.05rem;
    color: var(--text);
}
.app-topbar .spacer { flex: 1; }
.app-menu-toggle {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: var(--radius-sm);
    width: 40px; height: 40px;
    font-size: 1.2rem;
    color: var(--text);
    cursor: pointer;
}

/* ---------- Main ---------- */
.app-main { padding: 1.9rem 1.75rem 3rem; }
.app-main > h1, .page-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.85rem;
    letter-spacing: -.01em;
    margin: 0 0 1.4rem;
    color: var(--ink);
}
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.page-head .page-title { margin: 0; }
.page-sub { color: var(--muted); font-size: .95rem; margin: -1rem 0 1.4rem; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1.25rem; }
.card-body { padding: 1.35rem 1.5rem; }
.card .card-body > h5,
.card .card-body > h6 { color: var(--ink); font-weight: 600; }

/* Stat cards (dashboard) */
.stat {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    padding: 1.3rem 1.4rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    height: 100%;
    position: relative;
    overflow: hidden;
}
.stat::after {
    content: "";
    position: absolute;
    right: -14px; top: -14px;
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--brand-tint);
}
.stat .stat-label {
    font-size: .78rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}
.stat .stat-value {
    font-family: var(--font-mono);
    font-size: 2.1rem;
    font-weight: 600;
    line-height: 1;
    color: var(--ink);
}
.stat .stat-icon {
    position: absolute; right: 1rem; top: 1rem;
    color: var(--brand); font-size: 1.15rem; z-index: 1;
}

/* ---------- Data / mono ---------- */
.mono, .slug {
    font-family: var(--font-mono);
    font-size: .86em;
}
.slug {
    background: #F3F5F2;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: .1rem .4rem;
    color: #33463C;
}

/* ---------- Tables ---------- */
.table { color: var(--text); vertical-align: middle; margin-bottom: 0; }
.table > thead th {
    font-size: .72rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    padding: .7rem .85rem;
    background: transparent;
}
.table > tbody td { padding: .8rem .85rem; border-color: var(--line); }
.table > tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody tr:hover > * { background: #F6F8F5; }
.card > .table-wrap { padding: .35rem .35rem; }
.table-wrap { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; letter-spacing: .02em; padding: .4em .7em; border-radius: var(--radius-pill); }
.badge-on  { background: var(--brand-tint); color: var(--brand-strong); }
.badge-off { background: #EDEFEC; color: var(--muted); }
.chip {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: .74rem;
    padding: .18rem .55rem;
    border-radius: var(--radius-pill);
    background: #EEF2ED;
    color: #3B4E44;
    border: 1px solid var(--line);
    text-transform: none;
}

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; padding: .55rem 1rem;
    display: inline-flex; align-items: center; gap: .45rem; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: .8rem 1.3rem; font-size: 1rem; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }

.btn-outline-secondary { border-color: var(--line); color: var(--text); background: #fff; }
.btn-outline-secondary:hover { background: #F3F5F2; color: var(--text); border-color: #CDD5CD; }

.btn-secondary { background: #EDEFEC; border-color: #E0E4DF; color: #3B4E44; }
.btn-secondary:hover { background: #E1E5DF; color: var(--ink); }

.btn-warning { background: #F2E7CF; border-color: #EADFC0; color: #7A5B1E; }
.btn-warning:hover { background: #ECDDBB; color: #5E4614; }

.btn-danger { background: #fff; border-color: #E6C9C9; color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); border-color: var(--danger); color: var(--danger); }

.btn-success { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-success:hover { background: var(--brand-strong); border-color: var(--brand-strong); color:#fff; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .84rem; color: #3B4E44; margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    padding: .6rem .8rem;
    font-size: .95rem;
    color: var(--text);
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-tint);
}
.form-control::placeholder { color: #9AA69F; }
.form-text { color: var(--muted); font-size: .82rem; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-control-color { padding: .25rem; height: 42px; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); border: 1px solid transparent; font-size: .92rem; }
.alert-success { background: var(--brand-tint); border-color: rgba(31,122,77,.25); color: var(--brand-strong); }
.alert-danger  { background: var(--danger-tint); border-color: rgba(178,59,59,.25); color: var(--danger); }
.alert-warning { background: #FBF3E1; border-color: #EDDCB4; color: #7A5B1E; }

/* ---------- QR thumb ---------- */
.qr-thumb {
    width: 84px; height: 84px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

/* ---------- Empty state ---------- */
.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty .regmark {
    font-size: 1.8rem; color: var(--brand);
    display: block; margin-bottom: .6rem;
}

/* ---------- Auth (login) ---------- */
body.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.25rem;
    background:
        radial-gradient(circle at 15% 15%, rgba(31,122,77,.10), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(23,37,30,.08), transparent 45%),
        var(--paper);
}
.auth-sheet {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 2rem 1.85rem 2.1rem;
    box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 1.4rem; }
.auth-brand .regmark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; border-radius: 12px;
    background: var(--ink); color: #fff; font-size: 1.4rem;
    margin-bottom: .7rem;
}
.auth-sheet h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.5rem;
    text-align: center;
    margin: 0 0 .2rem;
    color: var(--ink);
}
.auth-sheet .subtitle { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.challenge-label { text-align: center; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; font-weight: 600; }
.challenge-box {
    background: #F3F5F2;
    border: 1px dashed #CBD4CC;
    border-radius: var(--radius-sm);
    padding: .8rem;
    text-align: center;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.2rem;
    letter-spacing: .35em;
    color: var(--ink);
    margin-bottom: .8rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-shell { margin-left: 0; }
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.3);
    }
    body.app.nav-open .app-sidebar { transform: translateX(0); }
    .app-menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .app-scrim {
        position: fixed; inset: 0; background: rgba(16,24,20,.45);
        opacity: 0; visibility: hidden; transition: opacity .2s ease; z-index: 1035;
    }
    body.app.nav-open .app-scrim { opacity: 1; visibility: visible; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
