/* Francobollino Cloud — design system (linguaggio moderno stile chemCloud,
   brand filatelico bordeaux). Card traslucide su gradient, bottoni con lift,
   focus glow, tooltip custom. */

:root {
    --bg-gradient-start: #7d1f2e;
    --bg-gradient-end: #3d1018;
    --accent: #8b2332;
    --accent-2: #b03a4a;
    --accent-gradient: linear-gradient(135deg, #a02c3d 0%, #6d1b27 100%);
    --accent-light: rgba(139, 35, 50, 0.08);
    --ink: #2b2b2b;
    --muted: #6b6b6b;
    --bg-card: rgba(255, 255, 255, 0.96);
    --bg-input: #fff;
    --border: #ddd6c9;
    --ok: #28a745;
    --warn: #ffc107;
    --err: #dc3545;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow-card: 0 8px 24px rgba(20, 8, 10, 0.25);
    --shadow-pop: 0 4px 15px rgba(139, 35, 50, 0.4);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
}

.center-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 34px 30px;
    width: 100%;
    max-width: 410px;
    backdrop-filter: blur(6px);
}

.brand { text-align: center; margin-bottom: 20px; }
.brand h1 {
    margin: 0;
    font-size: 1.8rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 0.5px;
}
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

h2 { font-size: 1.15rem; margin: 0 0 16px; }

label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin: 12px 0 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    padding: 11px 13px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-input);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(139, 35, 50, 0.22);
}

button, .btn {
    display: inline-block;
    width: 100%;
    margin-top: 18px;
    padding: 12px 18px;
    background: var(--accent-gradient);
    color: #fff;
    border: 0;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}

button:hover, .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-pop);
    filter: brightness(1.05);
}
button:active, .btn:active { transform: translateY(0); box-shadow: none; }
button:disabled { opacity: 0.55; cursor: wait; transform: none; box-shadow: none; }

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}
.btn-secondary:hover { background: var(--accent-light); box-shadow: none; }

.msg {
    margin-top: 14px;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    display: none;
}
.msg.show { display: block; }
.msg.error { background: #fbeaea; color: var(--err); border: 1px solid #eec9c9; }
.msg.success { background: #e9f5ec; color: var(--ok); border: 1px solid #c6e3cd; }
.msg.info { background: #eef2f8; color: #3a5a8c; border: 1px solid #cfdcee; }

.footline { margin-top: 18px; text-align: center; font-size: 0.9rem; color: var(--muted); }
.footline a { color: var(--accent); font-weight: 600; }

.lang-switch { text-align: center; margin-top: 14px; font-size: 0.85rem; }
.lang-switch a { color: var(--muted); text-decoration: none; margin: 0 4px; cursor: pointer; }
.lang-switch a.active { color: var(--accent); font-weight: 700; }

.hidden { display: none !important; }

/* --- Tooltip custom (sostituisce i title nativi) --- */
#fbcTip {
    position: fixed;
    z-index: 9999;
    max-width: 290px;
    background: rgba(30, 22, 20, 0.94);
    color: #f4efe8;
    font-size: 0.78rem;
    line-height: 1.35;
    padding: 8px 11px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s, transform 0.15s;
}
#fbcTip.show { opacity: 1; transform: translateY(0); }
#fbcTip::after {
    content: "";
    position: absolute;
    top: -5px;
    left: 16px;
    border: 5px solid transparent;
    border-bottom-color: rgba(30, 22, 20, 0.94);
    border-top: 0;
}

/* --- Shell privata --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 12px rgba(20, 8, 10, 0.25);
    padding: 10px 22px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar .logo { font-weight: 800; font-size: 1.25rem; }
.topbar .logo a {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent !important;
}
.topbar .user { font-size: 0.9rem; color: var(--muted); }
.topbar .section { color: var(--accent); font-weight: 700; margin-right: 10px; }
.topbar button { width: auto; margin: 0 0 0 12px; padding: 8px 16px; font-size: 0.88rem; }

.content { max-width: 1000px; margin: 28px auto; padding: 0 18px; }

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 18px;
}
.tile {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 26px 16px;
    text-align: center;
    color: var(--muted);
    transition: transform 0.15s, box-shadow 0.15s;
}
a.tile:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(20, 8, 10, 0.35); }
.tile .icon { font-size: 2rem; }
.tile .name { margin-top: 10px; font-weight: 700; color: var(--ink); font-size: 1.02rem; }
.tile .soon { font-size: 0.75rem; margin-top: 4px; }

.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 22px;
    margin-top: 24px;
}
.panel h2 { color: var(--accent); }
.panel .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel button { width: auto; margin-top: 0; padding: 9px 16px; font-size: 0.9rem; }

.qr-box { text-align: center; margin: 14px 0; }
.qr-box img { width: 200px; height: 200px; border: 1px solid var(--border); border-radius: 10px; }
.manual-key {
    font-family: Consolas, monospace;
    background: #f4f0e8;
    padding: 6px 10px;
    border-radius: 8px;
    word-break: break-all;
    display: inline-block;
    margin-top: 6px;
}
.backup-codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    font-family: Consolas, monospace;
    margin: 12px 0;
}
.backup-codes span { background: #f4f0e8; padding: 6px 8px; border-radius: 8px; text-align: center; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.badge.on { background: #e9f5ec; color: var(--ok); }
.badge.off { background: #f4f0e8; color: var(--muted); }

/* --- Left menu (stile chemCloud: sidebar fissa, icona sopra/label sotto) --- */
left-menu {
    position: fixed;
    left: 0;
    top: 0;
    width: 150px;
    height: 100%;
    /* Quercia antica (texture generata, in tinta con la Camera del Tesoro)
       + velo scuro per la leggibilita' */
    background:
        linear-gradient(180deg, rgba(12, 7, 3, 0.42) 0%, rgba(12, 7, 3, 0.30) 18%,
                          rgba(12, 7, 3, 0.30) 75%, rgba(12, 7, 3, 0.52) 100%),
        url("/imgs/tesoro/menu-legno.jpg") center / cover no-repeat;
    box-shadow:
        inset -6px 0 14px rgba(0, 0, 0, 0.55),
        inset -1px 0 0 rgba(227, 194, 124, 0.35),
        2px 0 16px rgba(10, 4, 2, 0.55);
    z-index: 90;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding-top: 16px;
}
body.has-menu { padding-left: 150px; }
body.has-menu .topbar { padding-left: 18px; }

left-menu .lm-logo { text-align: center; margin: 6px 8px 20px; font-weight: 700; font-size: 1.06rem; }
left-menu .lm-logo a {
    font-family: Georgia, "Times New Roman", serif;
    color: #f0d391;
    text-decoration: none;
    letter-spacing: 0.02em;
    text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(0, 0, 0, 0.6);
}
left-menu .lm-items { flex: 1; overflow-y: auto; }
left-menu .lm-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 14px 8px;
    color: #e8d2a0;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 600;
    text-align: center;
    border-left: 3px solid transparent;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    transition: background 0.12s, color 0.12s;
}
left-menu .lm-item:hover { background: rgba(240, 211, 145, 0.10); color: #ffe3a1; }
left-menu .lm-item.active {
    background: linear-gradient(90deg, rgba(240, 211, 145, 0.18), rgba(240, 211, 145, 0.05));
    color: #ffe3a1;
    border-left-color: #f0d391;
}
left-menu .lm-icon {
    width: 28px; height: 28px;
    color: #d9b56c;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}
left-menu .lm-item:hover .lm-icon, left-menu .lm-item.active .lm-icon {
    color: #ffd882;
    filter: drop-shadow(0 0 5px rgba(255, 216, 130, 0.55)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}
left-menu .lm-icon svg { width: 100%; height: 100%; }

left-menu .lm-user {
    position: relative;
    border-top: 1px solid rgba(227, 194, 124, 0.35);
    padding: 14px 10px;
    text-align: center;
    background: rgba(10, 5, 2, 0.30);
}
left-menu .lm-greet {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.88rem;
    font-weight: 700;
    color: #f0d391;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    margin: 2px 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
left-menu .lm-logout {
    width: 100%;
    margin: 0;
    padding: 8px;
    font-size: 0.8rem;
}
left-menu .lm-shield {
    position: absolute;
    top: -16px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 35% 30%, #3a2410, #1c1006);
    border: 1px solid rgba(227, 194, 124, 0.6);
    border-radius: 50%;
    color: #d9b56c;
    padding: 5px;
    box-sizing: border-box;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
    transition: transform 0.12s;
}
left-menu .lm-shield svg { width: 100%; height: 100%; }
left-menu .lm-shield:hover { transform: translateY(-2px); }
left-menu .lm-shield.ok { color: var(--ok); }
left-menu .lm-shield.alert { color: #e0a800; }
left-menu .lm-shield.on-page { border-color: var(--accent); color: var(--accent); }
left-menu .lm-shield-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #dc3545;
    border: 1.5px solid var(--bg-card);
}
left-menu .lm-shield-dot.hidden { display: none; }

/* --- Home: tavolo di lavoro filatelico --- */
body.home-desk { overflow: hidden; }
.desk {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Legno noce: vignetta + fughe assi orizzontali + venature fini +
       bande di tonalita' (periodi diversi per rompere la regolarita') */
    background:
        radial-gradient(ellipse at 46% 36%, rgba(255, 233, 195, 0.18), rgba(15, 6, 3, 0.42) 78%),
        repeating-linear-gradient(0deg, rgba(25, 10, 4, 0.35) 0 2px, rgba(255, 240, 220, 0.05) 2px 3px, transparent 3px 138px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(0deg, rgba(30, 12, 5, 0.10) 0 7px, transparent 7px 23px),
        repeating-linear-gradient(90deg, rgba(60, 28, 12, 0.09) 0 210px, transparent 210px 470px),
        linear-gradient(180deg, #6d4322 0%, #5e3519 55%, #522c14 100%);
}
.desk-pad {
    position: relative;
    width: min(760px, 82%);
    padding: 58px 30px 64px;
    border-radius: 18px;
    text-align: center;
    /* Pelle verde scuro con cucitura */
    background:
        radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.07), transparent 60%),
        repeating-conic-gradient(rgba(0, 0, 0, 0.06) 0% 25%, transparent 0% 50%) 50% / 5px 5px,
        linear-gradient(160deg, #2e4636 0%, #24382b 60%, #1d2f24 100%);
    box-shadow:
        inset 0 0 0 2px rgba(0, 0, 0, 0.25),
        inset 0 0 0 14px rgba(0, 0, 0, 0.10),
        inset 0 2px 6px rgba(255, 255, 255, 0.08),
        0 24px 60px rgba(10, 4, 2, 0.55);
}
.desk-pad::after { /* cucitura */
    content: "";
    position: absolute;
    inset: 9px;
    border: 2px dashed rgba(235, 220, 190, 0.28);
    border-radius: 12px;
    pointer-events: none;
}
.desk-stamp {
    display: inline-block;
    transform: rotate(-2.5deg);
    filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.45));
}
.desk-stamp svg { display: block; width: min(420px, 70vw); height: auto; }
.desk-lens {
    position: absolute;
    right: 6%;
    bottom: 8%;
    width: 170px;
    height: 170px;
    color: rgba(240, 225, 195, 0.16);
    transform: rotate(12deg);
    pointer-events: none;
}
.desk-lens svg { width: 100%; height: 100%; }
.desk-hint {
    margin-top: 26px;
    color: rgba(235, 224, 200, 0.55);
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}

/* --- Tema sezioni (uniforme alla home medievale): pietra scura +
       riquadri pergamena con bordi oro antico. Vale per tutte le pagine
       col left menu; niente dentellatura ne' topbar. --- */
body.has-menu::before { display: none; }
body.has-menu {
    --bg-card: #f6eedb;
    --bg-input: #fdf8ec;
    --border: #c9a76b;
    /* Panno verde: il tavolo d'esame del filatelico */
    background: url("/imgs/tesoro/panno-verde.jpg") #2c5240;
}
body.has-menu .topbar { display: none; }

/* Cornice INTAGLIATA vera (immagine generata, 9-slice) + fondo legno
   chiaro per i riquadri delle sezioni: stessa materia della targa. */
body.has-menu .fgroup,
body.has-menu .arch-actions,
body.has-menu .panel,
body.has-menu .odo-bar,
body.has-menu .odo-card,
body.has-menu .viewer-shell,
body.has-menu .editor-shell,
body.has-menu .drop-zone,
body.has-menu .racc-bar,
body.has-menu .modal,
body.has-menu .dlg {
    background: url("/imgs/tesoro/legno-chiaro.jpg") #ecdcbc;
    border: 16px solid transparent;
    border-image: url("/imgs/tesoro/cornice.png") 250 round;
    border-radius: 0;
    box-shadow: 0 12px 28px rgba(20, 8, 10, 0.45);
}
/* Controlli (paginazione, select, input) con lo stesso filetto bronzo */
body.has-menu .pager2 button,
body.has-menu .pager2 select,
body.has-menu .pager2 input,
body.has-menu .btn-ghost {
    background: var(--bg-input);
    border-color: #a9834a;
}
body.has-menu input[type="text"],
body.has-menu select,
body.has-menu textarea {
    border-color: #b28c50;
}
/* Pulsante flottante di pagina (es. Parcheggio) in alto a destra */
.page-fab {
    position: fixed;
    top: 14px;
    right: 22px;
    z-index: 80;
    width: auto;
    margin: 0;
    padding: 9px 18px;
    font-size: 0.88rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

left-menu .lm-gear {
    position: absolute; top: -16px; left: 14px;
    width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 35% 30%, #3a2410, #1c1006);
    border: 1px solid rgba(227, 194, 124, 0.6); border-radius: 50%;
    color: #d9b56c; padding: 6px; box-sizing: border-box;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6); transition: transform 0.12s;
}
left-menu .lm-gear svg { width: 100%; height: 100%; }
left-menu .lm-gear:hover { transform: translateY(-2px); color: #ffd882; }

.marquee-box {
    position: absolute; z-index: 90; pointer-events: none;
    border: 2px dashed #1e6fd9; background: rgba(30, 111, 217, 0.12);
}
