/* =====================================================================
   TEMA CONDIVISO - Vigili del Fuoco (progetto ludico)
   Usato da tutte le pagine: colori, tipografia e componenti comuni.
   ===================================================================== */

:root {
    /* Superfici (dal più scuro al più chiaro) */
    --bg: #0b0808;
    --sunken: #0a0707;
    --surface: #151010;
    --surface-2: #1d1616;
    --surface-3: #271d1d;

    /* Bordi */
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.16);

    /* Testo */
    --text: #f6f2f1;
    --text-2: #c9bcba;
    --text-3: #a09391;

    /* Brand e stati */
    --brand: #e5383b;
    --brand-2: #c1272d;
    --brand-dark: #8f1d21;
    --amber: #ff9d4d;
    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #f87171;
    --info: #60a5fa;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;
    --shadow: 0 14px 34px -16px rgba(0, 0, 0, 0.75);

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', monospace;
}

/* ------------------------- BASE ------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background-image:
        radial-gradient(900px 420px at 12% -8%, rgba(229, 56, 59, 0.17), transparent 60%),
        radial-gradient(700px 380px at 100% 0%, rgba(255, 157, 77, 0.07), transparent 60%),
        linear-gradient(rgba(255, 255, 255, 0.017) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.017) 1px, transparent 1px);
    background-size: auto, auto, 44px 44px, 44px 44px;
    background-attachment: fixed;
}

/* Filo tricolore-fuoco in cima a ogni pagina */
body::before {
    content: '';
    position: fixed;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand), var(--amber));
    z-index: 3000;
}

:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
::selection { background: rgba(229, 56, 59, 0.45); }
::placeholder { color: #7a6d6b; }

a { color: inherit; }
code { font-family: var(--mono); font-size: 0.85em; background: rgba(255, 255, 255, 0.07); padding: 1px 6px; border-radius: 5px; }

/* Barre di scorrimento coerenti */
* { scrollbar-width: thin; scrollbar-color: rgba(229, 56, 59, 0.5) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(229, 56, 59, 0.45); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------- INTESTAZIONE PAGINA ------------------------- */
.header-bar {
    background: rgba(21, 16, 16, 0.85);
    backdrop-filter: blur(14px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 14px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: var(--shadow);
}
.brand-zone { display: flex; align-items: center; gap: 14px; }
.brand-icon {
    width: 46px; height: 46px;
    border-radius: 13px;
    background: linear-gradient(145deg, rgba(229, 56, 59, 0.28), rgba(21, 16, 16, 0.9));
    border: 1px solid rgba(229, 56, 59, 0.4);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.brand-icon img { height: 30px; width: 30px; object-fit: contain; }
.brand-titles h1 { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.brand-titles span { display: block; font-size: 0.7rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

/* ------------------------- PULSANTI ------------------------- */
.btn, .btn-action {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 16px;
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--line);
    font: 600 0.85rem var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn:hover:not(:disabled), .btn-action:hover:not(:disabled) { background: #33262a; border-color: var(--line-2); transform: translateY(-1px); }
.btn:active:not(:disabled), .btn-action:active:not(:disabled) { transform: translateY(0); }
.btn:disabled, .btn-action:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary, .btn-manage {
    background: linear-gradient(180deg, #ee4447 0%, #c1272d 100%);
    border-color: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: 0 10px 22px -10px rgba(229, 56, 59, 0.85);
}
.btn-primary:hover:not(:disabled), .btn-manage:hover:not(:disabled) { background: linear-gradient(180deg, #f5585b 0%, #d12e34 100%); border-color: rgba(255, 255, 255, 0.25); }
.btn-secondary { background: var(--surface-3); }
.btn-outline, .btn-ghost { background: transparent; }
.btn-danger { background: rgba(248, 113, 113, 0.1); color: #fca5a5; border-color: rgba(248, 113, 113, 0.32); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.2); border-color: rgba(248, 113, 113, 0.5); }
.btn-ok { background: rgba(34, 197, 94, 0.14); color: #4ade80; border-color: rgba(34, 197, 94, 0.35); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 0.76rem; border-radius: 8px; }
.btn-big { min-height: 50px; padding: 0 28px; font-size: 0.95rem; font-weight: 700; }

/* Campo "Codice": testo mascherato con i pallini (non è un campo password del browser) */
.mask-codice { -webkit-text-security: disc; text-security: disc; }

/* ------------------------- CAMPI ------------------------- */
.input, .custom-input {
    background: var(--sunken);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 11px 14px;
    border-radius: 10px;
    font: 500 0.9rem var(--font);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 0;
}
.input:hover, .custom-input:hover { border-color: var(--line-2); }
.input:focus, .custom-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(229, 56, 59, 0.22); }
select.input option { background: #1d1616; color: var(--text); }
textarea.input { resize: vertical; line-height: 1.5; }

.input-label, .field > label, .field-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.09em;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.input-group { display: flex; flex-direction: column; gap: 6px; }

/* ------------------------- CARD ------------------------- */
.panel, .card-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 22px;
    box-shadow: var(--shadow);
    min-width: 0;
}

/* ------------------------- BADGE ------------------------- */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.63rem; font-weight: 800; letter-spacing: 0.06em;
    padding: 3px 9px; border-radius: 999px;
    text-transform: uppercase; white-space: nowrap;
    border: 1px solid transparent;
}
.pill.on   { background: rgba(34, 197, 94, 0.14);  color: #4ade80; border-color: rgba(34, 197, 94, 0.35); }
.pill.off  { background: rgba(255, 255, 255, 0.06); color: #b5a8a6; border-color: var(--line); }
.pill.role { background: rgba(255, 157, 77, 0.13);  color: #ffb877; border-color: rgba(255, 157, 77, 0.35); }
.pill.gold { background: rgba(251, 191, 36, 0.15);  color: #fbbf24; border-color: rgba(251, 191, 36, 0.45); }
.pill.warn { background: rgba(229, 56, 59, 0.16);   color: #fda4a4; border-color: rgba(229, 56, 59, 0.4); }

/* Barra di avanzamento */
.bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.07); margin-top: 7px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), var(--amber)); }

.mono { font-family: var(--mono); font-weight: 700; }
.muted { color: var(--text-3); font-size: 0.76rem; font-weight: 500; }
.empty, .gm-empty { color: var(--text-3); font-size: 0.86rem; padding: 26px; text-align: center; }

/* ------------------------- FINESTRE (MODALI) ------------------------- */
.overlay, .gm-overlay, .modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(6, 3, 3, 0.78);
    backdrop-filter: blur(6px);
    z-index: 1000;
    justify-content: center; align-items: center;
    padding: 20px;
}
.overlay.open, .gm-overlay.open { display: flex; }

.x-btn, .gm-close {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    color: var(--text);
    width: 38px; height: 38px;
    border-radius: 10px;
    cursor: pointer;
    flex-shrink: 0;
}
.x-btn:hover, .gm-close:hover { background: rgba(229, 56, 59, 0.3); }

/* ------------------------- NOTIFICHE E AVVISI ------------------------- */
.toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translate(-50%, 20px);
    background: var(--surface-2);
    border: 1px solid rgba(255, 157, 77, 0.5);
    color: var(--text);
    padding: 12px 20px; border-radius: 12px;
    font-size: 0.86rem; font-weight: 600;
    opacity: 0; pointer-events: none;
    transition: all 0.3s;
    z-index: 2000; max-width: 90vw;
    box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--danger); color: #fca5a5; }

.disclaimer, .disclaimer-mini {
    margin: 26px auto 4px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.6;
    color: var(--text-3);
}
.disclaimer strong { color: var(--text-2); }

/* ------------------------- ANIMAZIONI RIDOTTE ------------------------- */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
