/* ═══════════════════════════════════════════════════════
   ETS2 Live Map — Stylesheet
   Skull Network Italia
   ═══════════════════════════════════════════════════════ */

/* ── Variabili colore ── */
:root {
    --bg: #080b10;
    --surface: #0d1118;
    --panel: #111720;
    --border: #1c2535;
    --border2: #243040;
    --accent: #e8a000;
    --accent2: #00b8d9;
    --green: #00e676;
    --red: #ff5252;
    --text: #c5d0de;
    --dim: #4e5f74;
    --glow-a: rgba(232, 160, 0, .18);
}

/* ── Reset & base ── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
}

body.is-loading {
    cursor: progress;
}

#loading {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-content: center;
    gap: 14px;
    padding: 28px;
    text-align: center;
    background:
        radial-gradient(circle at 30% 15%, rgba(0, 184, 217, .16), transparent 38%),
        radial-gradient(circle at 72% 74%, rgba(232, 160, 0, .14), transparent 34%),
        linear-gradient(165deg, #04070d 0%, #090f19 50%, #060a13 100%);
}

#loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, .05) 48%, transparent 80%);
    transform: translateX(-130%);
    animation: loadingSweep 2.5s ease-in-out infinite;
    pointer-events: none;
}

#loading-text {
    position: relative;
    font-size: clamp(1.25rem, 4vw, 2.2rem);
    letter-spacing: .36rem;
    font-weight: 700;
    color: #f5f8ff;
    text-transform: uppercase;
    text-shadow: 0 0 22px rgba(0, 184, 217, .2), 0 0 8px rgba(232, 160, 0, .18);
}

#loading-bar-wrap {
    position: relative;
    width: min(460px, 82vw);
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .05);
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
}

#loading-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #00b8d9 0%, #2be6ff 30%, #e8a000 100%);
    box-shadow: 0 0 16px rgba(0, 184, 217, .55), 0 0 26px rgba(232, 160, 0, .25);
    transition: width .5s cubic-bezier(.16, .86, .36, 1);
}

#loading-sub {
    position: relative;
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(.72rem, 2.2vw, .9rem);
    letter-spacing: .16rem;
    color: #b3c2d8;
    text-transform: uppercase;
    animation: loadingPulse 1.2s ease-in-out infinite;
}

#loading.loading-done {
    opacity: 0;
    visibility: hidden;
    transition: opacity .45s ease, visibility .45s ease;
}

@keyframes loadingSweep {
    to {
        transform: translateX(130%);
    }
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: .72;
    }
    50% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    #loading::before,
    #loading-sub {
        animation: none;
    }
}

/* ── Header ── */
header {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 200;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    background: rgba(8, 11, 16, .96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}
.mobile-menu-btn {
    display: none;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border2);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.logo-truck {
    font-size: 1.35rem;
    filter: drop-shadow(0 0 6px var(--accent));
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.logo-text em {
    color: var(--accent);
    font-style: normal;
}

.logo-badge {
    font-size: .6rem;
    letter-spacing: 2px;
    font-family: 'Share Tech Mono', monospace;
    background: var(--accent);
    color: #000;
    padding: 2px 6px;
    border-radius: 2px;
    font-weight: 700;
}

.hdr-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.live-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(0, 230, 118, .25);
    background: rgba(0, 230, 118, .07);
    font-size: .75rem;
    letter-spacing: 1.5px;
    color: var(--green);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: blink 1.6s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .2;
    }
}

.hdr-stat {
    font-size: .78rem;
    font-family: 'Share Tech Mono', monospace;
    color: var(--dim);
}

.hdr-stat b {
    color: var(--text);
}

.hdr-clock {
    font-size: .8rem;
    font-family: 'Share Tech Mono', monospace;
    color: var(--dim);
    min-width: 52px;
}

/* ── Layout principale ── */
.layout {
    position: fixed;
    top: 52px;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
}

/* ── Sidebar ── */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sb-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.sb-tab {
    flex: 1;
    padding: 11px 6px;
    text-align: center;
    font-size: .7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .2s;
}

.sb-tab.on {
    color: var(--accent);
    border-color: var(--accent);
}

.sb-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.sb-body::-webkit-scrollbar {
    width: 3px;
}

.sb-body::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 2px;
}

.sec {
    font-size: .65rem;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--dim);
    padding: 6px 2px 5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

/* ── Ricerca ── */
.search {
    position: relative;
    margin-bottom: 10px;
}

.search input {
    width: 100%;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    font-size: .9rem;
    padding: 7px 10px 7px 32px;
    border-radius: 4px;
    outline: none;
    transition: border-color .2s;
}

.search input:focus {
    border-color: var(--accent);
}

.search input::placeholder {
    color: var(--dim);
}

.search::before {
    content: '⌕';
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-52%);
    font-size: 1rem;
    color: var(--dim);
    pointer-events: none;
}

/* ── Card giocatore ── */
.pcard {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .02);
    margin-bottom: 5px;
    cursor: pointer;
    transition: all .18s;
}

.pcard:hover,
.pcard.sel {
    border-color: var(--accent);
    background: var(--glow-a);
}

.pcard-av {
    width: 34px;
    height: 34px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.pcard-av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pcard-info {
    flex: 1;
    min-width: 0;
}

.pcard-name {
    font-weight: 600;
    font-size: .88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pcard-sub {
    font-size: .72rem;
    color: var(--dim);
    font-family: 'Share Tech Mono', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pcard-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-on {
    background: var(--green);
    box-shadow: 0 0 5px var(--green);
}

.dot-idle {
    background: var(--accent);
    box-shadow: 0 0 5px var(--accent);
}

.dot-me {
    background: var(--accent2);
    box-shadow: 0 0 5px var(--accent2);
}

/* ── Statistiche ── */
.sgrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 12px;
}

.scard {
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 9px;
    text-align: center;
}

.scard-n {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--accent);
    font-family: 'Share Tech Mono', monospace;
}

.scard-l {
    font-size: .65rem;
    color: var(--dim);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 1px;
}

.crow {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 2px;
    border-bottom: 1px solid rgba(255, 255, 255, .04);
}

.crow-flag {
    font-size: .95rem;
}

.crow-name {
    font-size: .82rem;
    flex: 1;
}

.crow-bar {
    flex: 2;
    height: 3px;
    background: var(--border2);
    border-radius: 2px;
    overflow: hidden;
}

.crow-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width .4s;
}

.crow-n {
    font-size: .72rem;
    font-family: 'Share Tech Mono', monospace;
    color: var(--dim);
    min-width: 18px;
    text-align: right;
}

/* ── Tab panels ── */
.tab-panel {
    display: none;
}

.tab-panel.on {
    display: block;
}

/* ── Mappa ── */
.map-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #080e18;
}
.sidebar-backdrop {
    display: none;
    border: 0;
    background: rgba(0, 0, 0, .5);
}

#mapCanvas {
    width: 100%;
    height: 100%;
    cursor: grab;
    display: block;
}

#mapCanvas.dragging {
    cursor: grabbing;
}

/* ── Controlli zoom ── */
.map-controls {
    position: absolute;
    right: 14px;
    bottom: 74px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mc-btn {
    width: 34px;
    height: 34px;
    background: var(--panel);
    border: 1px solid var(--border2);
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    font-family: 'Share Tech Mono', monospace;
    font-weight: 700;
}

.mc-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Barra coordinate ── */
.coord-bar {
    position: absolute;
    bottom: 14px;
    left: 14px;
    font-family: 'Share Tech Mono', monospace;
    font-size: .72rem;
    color: var(--dim);
    background: rgba(13, 17, 24, .9);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: 4px;
}

/* ── Legenda ── */
.legend {
    position: absolute;
    bottom: 14px;
    right: 14px;
    background: rgba(13, 17, 24, .92);
    border: 1px solid var(--border);
    padding: 9px 13px;
    border-radius: 5px;
    font-size: .75rem;
}

.leg-row {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 4px;
}

.leg-row:last-child {
    margin-bottom: 0;
}

.leg-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

/* ── Tooltip ── */
#tooltip {
    position: absolute;
    z-index: 100;
    pointer-events: none;
    background: var(--panel);
    border: 1px solid var(--accent);
    padding: 10px 13px;
    border-radius: 6px;
    min-width: 170px;
    transform: translate(-50%, -115%);
    display: none;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .6);
}

#tooltip.vis {
    display: block;
}

.tt-name {
    font-weight: 700;
    font-size: .95rem;
    color: var(--accent);
    margin-bottom: 5px;
}

.tt-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 2px;
    font-size: .78rem;
}

.tt-row span:first-child {
    color: var(--dim);
}

.tt-row span:last-child {
    font-family: 'Share Tech Mono', monospace;
    color: var(--text);
    font-size: .73rem;
}

/* ── Toast notifica ── */
#toast {
    position: fixed;
    top: 64px;
    right: 14px;
    z-index: 300;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    padding: 9px 14px;
    border-radius: 4px;
    font-size: .83rem;
    min-width: 220px;
    transform: translateX(120%);
    transition: transform .3s ease;
    pointer-events: none;
}

#toast.show {
    transform: translateX(0);
}

.toast-t {
    font-weight: 600;
    color: var(--accent);
    font-size: .72rem;
    letter-spacing: 1px;
    margin-bottom: 2px;
    text-transform: uppercase;
}

/* ── Banner offline ── */
#offline-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 82, 82, .12);
    border-bottom: 1px solid rgba(255, 82, 82, .3);
    color: var(--red);
    font-size: .78rem;
    letter-spacing: 1px;
    text-align: center;
    padding: 5px;
    display: none;
}
/* ── Pannello filtro nazioni ─────────────────────────────────────── */
#nation-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px 14px;
}

.nation-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #0d1a26;
    border: 1px solid #1a3a5a;
    border-radius: 20px;
    color: #c9d1d9;
    font: 600 .8rem Consolas, monospace;
    padding: 5px 14px;
    cursor: pointer;
    transition: all .2s;
    user-select: none;
}

.nation-btn:hover {
    background: #162840;
    border-color: #2a6aaa;
    color: #fff;
}

.nation-btn.nation-off {
    opacity: .32;
    filter: grayscale(1);
}

.nation-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.nation-flag {
    font-size: 1.05rem;
    line-height: 1;
}

.nation-name {
    font-size: .78rem;
    letter-spacing: .03em;
}

@media (max-width: 1024px) {
    header {
        padding: 0 12px;
    }

    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .logo-text {
        font-size: .92rem;
        letter-spacing: 1.4px;
    }

    .logo-badge {
        display: none;
    }

    .hdr-right {
        gap: 8px;
    }

    .hdr-stat,
    .hdr-clock {
        display: none;
    }

    .layout {
        top: 52px;
    }

    .sidebar {
        position: fixed;
        top: 52px;
        left: 0;
        bottom: 0;
        width: min(84vw, 340px);
        z-index: 260;
        transform: translateX(-102%);
        transition: transform .22s ease;
        box-shadow: 10px 0 30px rgba(0, 0, 0, .35);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 52px 0 0 0;
        z-index: 250;
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .map-wrap {
        width: 100%;
    }

    .coord-bar {
        left: 10px;
        bottom: 10px;
        font-size: .67rem;
        padding: 4px 8px;
    }

    .legend {
        right: 10px;
        bottom: 10px;
        padding: 7px 10px;
        font-size: .7rem;
        max-width: 42vw;
    }

    .map-controls {
        right: 10px;
        bottom: 94px;
        gap: 6px;
    }

    .mc-btn {
        width: 40px;
        height: 40px;
    }

    #tooltip {
        min-width: 155px;
        max-width: 74vw;
        padding: 8px 10px;
    }
}

@media (max-width: 640px) {
    .live-pill {
        padding: 3px 8px;
        font-size: .66rem;
    }

    .logo {
        gap: 8px;
    }

    .logo-truck {
        font-size: 1.15rem;
    }

    .legend {
        display: none;
    }

    .coord-bar {
        right: 10px;
        left: auto;
        max-width: calc(100% - 20px);
        text-align: right;
    }

    #toast {
        top: 58px;
        right: 10px;
        left: 10px;
        min-width: 0;
    }
}