body {
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Ritinteggia il blu "primary" di Bootstrap (#0d6efd) con il blu elettrico
   del logo (#0052ff), su tutto il sito (non solo le pagine di login).
   .text-primary/.bg-primary/.text-bg-primary leggono --bs-primary-rgb a
   runtime: basta ridefinirla. .btn-primary/.btn-outline-primary hanno invece
   i colori scritti in chiaro nella build di Bootstrap: vanno ridefiniti per
   classe con le stesse variabili CSS che Bootstrap stesso usa al suo interno. */
:root {
    --bs-primary: #0052ff;
    --bs-primary-rgb: 0, 82, 255;
}

.btn-primary {
    --bs-btn-bg: #0052ff;
    --bs-btn-border-color: #0052ff;
    --bs-btn-hover-bg: #0041cc;
    --bs-btn-hover-border-color: #0041cc;
    --bs-btn-active-bg: #0041cc;
    --bs-btn-active-border-color: #0041cc;
    --bs-btn-disabled-bg: #0052ff;
    --bs-btn-disabled-border-color: #0052ff;
    --bs-btn-focus-shadow-rgb: 0, 82, 255;
}

.btn-outline-primary {
    --bs-btn-color: #0052ff;
    --bs-btn-border-color: #0052ff;
    --bs-btn-hover-bg: #0052ff;
    --bs-btn-hover-border-color: #0052ff;
    --bs-btn-active-bg: #0052ff;
    --bs-btn-active-border-color: #0052ff;
    --bs-btn-disabled-color: #0052ff;
    --bs-btn-disabled-border-color: #0052ff;
    --bs-btn-focus-shadow-rgb: 0, 82, 255;
}

.navbar-brand {
    letter-spacing: -0.02em;
}

/* Menu utente a tendina (navbar dashboard) — <details>/<summary> nativi, niente JS */
.prestats-user-menu {
    position: relative;
}

.prestats-user-menu summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.prestats-user-menu summary::-webkit-details-marker {
    display: none;
}

.prestats-user-menu summary::after {
    content: ' \25BE';
}

.prestats-user-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.6rem);
    background: #fff;
    border-radius: 0.6rem;
    box-shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.25);
    min-width: 190px;
    padding: 0.4rem;
    z-index: 20;
}

.prestats-user-menu-panel a,
.prestats-user-menu-panel button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-radius: 0.4rem;
    text-decoration: none;
    color: #0f172a;
    font-size: 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
}

.prestats-user-menu-panel a:hover,
.prestats-user-menu-panel button:hover {
    background: #f1f5f9;
}

/* Tag input "Domini gestiti" (form utente admin) */
.prestats-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #eff6ff;
    color: #0052ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 0.25rem 0.3rem 0.25rem 0.7rem;
    font-size: 0.8rem;
}

.prestats-tag-chip button {
    background: none;
    border: none;
    color: #0052ff;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0 0.25rem;
}

.card {
    border-radius: 0.75rem;
}

pre code {
    white-space: pre-wrap;
}

/* --- Pagine di autenticazione (login, "non installato") ---
   Nota: assets/vendor/bootstrap/bootstrap.min.css non è ancora stato
   incluso nel progetto (solo un .gitkeep segnaposto, il link nel layout
   risponde 404): le regole sotto ricreano a mano solo le classi Bootstrap
   usate in templates/login.php e templates/not_installed.php, così le
   pagine di autenticazione restano leggibili indipendentemente da questo. */

.prestats-auth-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(160deg, #e0f2fe 0%, #f8fafc 45%, #ffffff 100%);
}

.prestats-auth-header {
    display: flex;
    justify-content: center;
    padding: 2.5rem 1rem 1rem;
}

.prestats-auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
}

.prestats-logo {
    display: block;
    width: auto;
}

.prestats-auth-main {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

/* Card */
.prestats-auth-main .card {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
}

.prestats-auth-main .card-body {
    padding: 2rem;
}

.prestats-auth-main h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.prestats-auth-main p {
    margin: 0.35rem 0 0;
}

.prestats-auth-main .text-muted {
    color: #64748b;
}

.prestats-auth-main .small {
    font-size: 0.85rem;
}

.prestats-auth-main .text-center {
    text-align: center;
}

.prestats-auth-main .mb-0 { margin-bottom: 0; }
.prestats-auth-main .mb-3 { margin-bottom: 1rem; }
.prestats-auth-main .mb-4 { margin-bottom: 1.5rem; }

/* Form */
.prestats-auth-main label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.prestats-auth-main .form-control,
.prestats-auth-main input[type="email"],
.prestats-auth-main input[type="password"] {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.6rem;
    background: #f8fafc;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.prestats-auth-main .form-control:focus,
.prestats-auth-main input:focus {
    outline: none;
    background: #fff;
    border-color: #0052ff;
    box-shadow: 0 0 0 0.2rem rgba(0, 82, 255, 0.16);
}

/* Bottone */
.prestats-auth-main .btn,
.prestats-auth-main button[type="submit"] {
    display: inline-block;
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: #0052ff;
    border: none;
    border-radius: 0.6rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.prestats-auth-main .btn:hover,
.prestats-auth-main .btn:focus,
.prestats-auth-main button[type="submit"]:hover {
    background: #0041cc;
}

/* Alert (errori / avvisi) */
.prestats-auth-main .alert {
    padding: 0.6rem 0.9rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.prestats-auth-main .alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.prestats-auth-main .alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.prestats-auth-main .alert-info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}


/* Mappa visitatori (dashboard utente) */
.prestats-map-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.prestats-map-controls .prestats-map-select-country {
    width: auto;
    max-width: 15rem;
}

.prestats-map-controls .prestats-map-select-metric {
    width: auto;
    max-width: 12rem;
}

.prestats-map {
    position: relative;
    background: #f1f5f9;
    border-radius: 0.5rem;
    overflow: hidden;
}

.prestats-map-svg {
    display: block;
    width: 100%;
    height: auto;
}

.prestats-map-country {
    fill: #e2e8f0;
    stroke: #ffffff;
    stroke-width: 0.6;
    vector-effect: non-scaling-stroke;
    transition: opacity 0.15s;
}

.prestats-map-country:not(.is-empty) {
    cursor: pointer;
}

.prestats-map-country:hover {
    opacity: 0.8;
    stroke: #0f172a;
}

.prestats-map-marker {
    stroke-width: 1;
}

.prestats-map-tooltip {
    position: absolute;
    z-index: 2;
    padding: 0.35rem 0.6rem;
    background: rgba(15, 23, 42, 0.92);
    color: #ffffff;
    font-size: 0.8rem;
    line-height: 1.3;
    border-radius: 0.4rem;
    pointer-events: none;
    white-space: nowrap;
}

.prestats-map-legend {
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.7rem;
    color: #475569;
    pointer-events: none;
}

.prestats-map-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.prestats-map-legend-swatch {
    display: inline-block;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 2px;
}

.prestats-map-total {
    position: absolute;
    top: 0.6rem;
    left: 0.75rem;
    font-size: 0.85rem;
    color: #475569;
    pointer-events: none;
}

.prestats-map-total strong {
    font-size: 1rem;
    color: #1e293b;
}

/* Menu laterale della dashboard di un sito (Panoramica, Dispositivi, Software, Orari, Tempo reale) */
.prestats-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.prestats-grow {
    flex: 1 0 auto;
}

.prestats-footer {
    flex-shrink: 0;
    text-align: center;
    font-size: 0.8rem;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    padding: 1rem;
}

.prestats-shell {
    position: relative;
    display: flex;
    align-items: stretch;
    flex: 1 0 auto;
}

.prestats-sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: #64748b;
    font-size: 0.85rem;
    text-align: left;
}

.prestats-sidebar-toggle:hover,
.prestats-sidebar-toggle:focus-visible {
    background: #f1f5f9;
    color: #0f172a;
}

.prestats-sidebar-toggle svg {
    flex: 0 0 auto;
}

.prestats-sidebar > .prestats-sidebar-toggle {
    margin-bottom: 0.5rem;
}

.prestats-mobilebar {
    display: none;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.25rem 0.75rem;
}

.prestats-mobilebar .prestats-sidebar-toggle {
    width: auto;
}

.prestats-only-narrow {
    display: none;
}

.prestats-sidebar-backdrop {
    display: none;
}

.prestats-guide-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: rgba(15, 20, 30, 0.55);
    padding: 3vh 4vw;
}

.prestats-guide-overlay[data-open="true"] {
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.prestats-guide-frame {
    width: 100%;
    max-width: 1100px;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.prestats-guide-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

@media (min-width: 768px) {
    /* Menu ridotto: resta una colonna stretta con le sole icone */
    .prestats-shell[data-sidebar="closed"] .prestats-sidebar {
        flex-basis: 56px;
        width: 56px;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .prestats-shell[data-sidebar="closed"] .prestats-sidebar-site,
    .prestats-shell[data-sidebar="closed"] .prestats-sidebar-toggle-label,
    .prestats-shell[data-sidebar="closed"] .prestats-nav-label {
        display: none;
    }

    .prestats-shell[data-sidebar="closed"] .prestats-sidebar-toggle,
    .prestats-shell[data-sidebar="closed"] .prestats-nav a {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }
}

.prestats-sidebar {
    flex: 0 0 220px;
    width: 220px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    padding: 1.25rem 0.75rem;
}

.prestats-sidebar-site {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin: 0 0 1rem;
    padding: 0.65rem 0.75rem;
    background: #eff5ff;
    border: 1px solid #cfe0ff;
    border-left: 4px solid #0052ff;
    border-radius: 0.6rem;
    min-width: 0;
}

.prestats-sidebar-site-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.prestats-sidebar-site-name {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.prestats-sidebar-site-domain {
    font-size: 0.8rem;
    color: #0052ff;
    overflow-wrap: anywhere;
}

/* Cambio sito (utenti con più siti): il riquadro del sito è un menu a discesa */
.prestats-site-switch details {
    min-width: 0;
}

.prestats-site-switch summary {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    position: relative;
    padding-right: 1.4rem;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.prestats-site-switch summary::-webkit-details-marker {
    display: none;
}

.prestats-site-switch summary::after {
    content: '\25BE';
    position: absolute;
    right: 0.1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    line-height: 1;
    color: #0052ff;
}

.prestats-site-switch details[open] summary::after {
    transform: translateY(-50%) rotate(180deg);
}

.prestats-site-switch summary:focus-visible {
    outline: 2px solid #0052ff;
    outline-offset: 3px;
    border-radius: 0.3rem;
}

.prestats-site-switch-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid #cfe0ff;
    max-height: 50vh;
    overflow-y: auto;
}

.prestats-site-switch-list a,
.prestats-site-switch-list .is-current {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.5rem;
    border-radius: 0.4rem;
    text-decoration: none;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.prestats-site-switch-list a:hover,
.prestats-site-switch-list a:focus-visible {
    background: #dbe8ff;
}

.prestats-site-switch-list .is-current {
    background: #fff;
    font-weight: 700;
    cursor: default;
}

.prestats-site-switch-name {
    font-size: 0.9rem;
    line-height: 1.25;
}

.prestats-site-switch-domain {
    font-size: 0.75rem;
    font-weight: 400;
    color: #64748b;
}

.prestats-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.prestats-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    color: #334155;
    font-size: 0.9rem;
    text-decoration: none;
}

.prestats-nav a:hover {
    background: #f1f5f9;
}

.prestats-nav a.is-active {
    background: #e7f0ff;
    color: #0052ff;
    font-weight: 600;
}

.prestats-main {
    flex: 1 1 0;
    min-width: 0;
    max-width: 1400px;
    padding: 1.5rem;
}

@media (max-width: 767.98px) {
    .prestats-mobilebar {
        display: block;
    }

    .prestats-only-wide {
        display: none;
    }

    .prestats-only-narrow {
        display: inline;
    }

    .prestats-sidebar {
        position: fixed;
        top: var(--prestats-navbar-h, 56px);
        bottom: 0;
        left: 0;
        z-index: 1040;
        width: 260px;
        max-width: 85vw;
        overflow-y: auto;
        border-right: 1px solid #e2e8f0;
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0s linear 0.2s;
    }

    .prestats-shell[data-sidebar="open"] .prestats-sidebar {
        transform: none;
        visibility: visible;
        box-shadow: 0 0 1.5rem rgba(15, 23, 42, 0.25);
        transition: transform 0.2s ease;
    }

    .prestats-shell[data-sidebar="open"] .prestats-sidebar-backdrop {
        display: block;
        position: fixed;
        top: var(--prestats-navbar-h, 56px);
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1039;
        background: rgba(15, 23, 42, 0.45);
    }

    .prestats-main {
        padding: 1rem;
    }
}

/* Selettore del periodo (pulsanti rapidi + intervallo personalizzato) */
.prestats-range {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.prestats-range-custom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}

.prestats-range-custom input[type="date"] {
    width: auto;
}

/* Tabelle di ripartizione (Dispositivi / Software) */
.prestats-breakdown th {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.prestats-chart-box {
    position: relative;
    height: 280px;
}

.prestats-chart-box--tall {
    height: 300px;
}

/* Tempo reale */
.prestats-live-dot {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: 0.35rem;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    animation: prestats-pulse 1.8s infinite;
}

.prestats-live-dot.is-stale {
    background: #94a3b8;
    animation: none;
}

@keyframes prestats-pulse {
    70% { box-shadow: 0 0 0 0.5rem rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.prestats-visit-active {
    color: #16a34a;
    font-weight: 600;
}
