/* Vista a card delle VPS (clienti con poche VPS). Si appoggia a netbird.css. */

.vps-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.vps-grid.single { grid-template-columns: minmax(0, 760px); justify-content: center; }

.vps-card {
    background: var(--nb-surface);
    border: 1px solid var(--nb-border);
    border-radius: .9rem;
    padding: 1.1rem 1.2rem 1rem;
    display: flex; flex-direction: column; gap: 1rem;
    opacity: 0; transform: translateY(6px);
    animation: vps-in .45s ease forwards;
}
@keyframes vps-in { to { opacity: 1; transform: none; } }

/* card «aggiungi»: cerchio grigio con il più, verso /nuova */
.vps-add {
    align-items: center; justify-content: center; gap: .8rem; min-height: 240px;
    background: transparent; border: 1.5px dashed var(--nb-border-2); text-decoration: none; color: var(--nb-muted);
    transition: border-color .2s, color .2s, background-color .2s;
}
.vps-add .plus {
    width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
    background: var(--nb-surface-2); border: 1px solid var(--nb-border-2);
    transition: background-color .2s, border-color .2s, transform .2s;
}
.vps-add .plus svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.vps-add .lbl { font-size: .85rem; font-weight: 500; }
.vps-add:hover, .vps-add:focus-visible { border-color: rgba(246, 131, 48, .6); color: var(--nb-text); background: rgba(246, 131, 48, .04); }
.vps-add:hover .plus, .vps-add:focus-visible .plus { background: rgba(246, 131, 48, .15); border-color: rgba(246, 131, 48, .55); color: var(--nb-orange); transform: scale(1.06); }

/* intestazione */
.vps-head { display: flex; align-items: center; gap: .85rem; }
.vps-os {
    width: 42px; height: 42px; flex: 0 0 42px; border-radius: .6rem;
    display: grid; place-items: center;
    background: var(--nb-surface-2); border: 1px solid var(--nb-border-2); color: var(--nb-muted);
}
.vps-os svg { width: 22px; height: 22px; }
.vps-title { min-width: 0; flex: 1; }
.vps-name { font-size: 1.05rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vps-meta { color: var(--nb-muted); font-size: .8rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.vps-meta .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.vps-state { display: inline-flex; align-items: center; gap: .45rem; font-size: .75rem; font-weight: 500;
    padding: .3em .75em; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.vps-state .dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; position: relative; }
.vps-state.running { color: #4ade80; background: rgba(74, 222, 128, .1); border-color: rgba(74, 222, 128, .28); }
.vps-state.running .dot::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor;
    animation: vps-pulse 2.4s ease-out infinite;
}
.vps-state.stopped { color: var(--nb-muted); background: var(--nb-control); border-color: var(--nb-border-2); }
.vps-state.paused  { color: #fbbf24; background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .28); }
@keyframes vps-pulse { 0% { transform: scale(1); opacity: .7; } 70%, 100% { transform: scale(3); opacity: 0; } }

/* indicatori circolari + grafici */
.vps-metrics { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; }
.vps-rings { display: flex; gap: .9rem; }
.vps-ring { position: relative; width: 92px; height: 92px; }
.vps-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.vps-ring .track { stroke: var(--nb-surface-2); }
.vps-ring .bar { stroke: var(--nb-orange); stroke-linecap: round; transition: stroke-dashoffset .9s cubic-bezier(.3,.7,.3,1), stroke .4s; }
.vps-ring .bar.warn { stroke: #fbbf24; }
.vps-ring .bar.hot  { stroke: #f87171; }
.vps-ring .val { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.vps-ring .pct { font-size: 1.15rem; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
.vps-ring .lbl { font-size: .68rem; color: var(--nb-muted); text-transform: uppercase; letter-spacing: .05em; }
.vps-ring .sub { font-size: .68rem; color: var(--nb-muted); margin-top: .1rem; white-space: nowrap; }

.vps-charts { display: flex; flex-direction: column; gap: .55rem; min-width: 0; }
.vps-chart { position: relative; }
.vps-chart .cap { display: flex; justify-content: space-between; font-size: .72rem; color: var(--nb-muted); margin-bottom: .15rem; }
.vps-chart .cap b { color: var(--nb-text); font-weight: 500; font-variant-numeric: tabular-nums; }
.vps-chart svg { width: 100%; height: 46px; display: block; overflow: visible; }
.vps-chart .line { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.vps-chart .area { opacity: .16; }
.vps-chart .cpu { stroke: var(--nb-orange); fill: var(--nb-orange); }
.vps-chart .rx  { stroke: #7dd3fc; fill: #7dd3fc; }
.vps-chart .tx  { stroke: #c4b5fd; fill: #c4b5fd; }
.vps-chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: vps-draw 1.2s ease forwards; }
@keyframes vps-draw { to { stroke-dashoffset: 0; } }
.vps-chart .empty { position: absolute; left: 0; right: 0; bottom: 0; height: 46px; display: grid; place-items: center;
    font-size: .72rem; color: var(--nb-muted); border: 1px dashed var(--nb-border-2); border-radius: .4rem; }
.vps-chart .empty[hidden] { display: none; }
.vps-chart .scale { opacity: .8; }
.vps-chart .cursor { stroke: var(--nb-border-2); stroke-width: 1; display: none; }
.vps-chart .tip {
    position: absolute; top: -.3rem; transform: translate(-50%, -100%); pointer-events: none; display: none;
    background: var(--nb-surface-2); border: 1px solid var(--nb-border-2); border-radius: .4rem;
    padding: .15rem .45rem; font-size: .7rem; white-space: nowrap; color: var(--nb-text);
}
.vps-chart:hover .cursor, .vps-chart:hover .tip { display: block; }
.legend-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; margin: 0 .25rem 0 .5rem; }

/* mappa di rete */
.vps-map { background: var(--nb-bg); border: 1px solid var(--nb-border); border-radius: .7rem; padding: .6rem .8rem .7rem; }
.vps-map .cap { font-size: .72rem; color: var(--nb-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; }
.vps-map svg { width: 100%; height: 64px; display: block; }
.vps-map .node-bg { fill: var(--nb-surface-2); stroke: var(--nb-border-2); }
.vps-map .node-ic { fill: none; stroke: var(--nb-text); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.vps-map .node-lb { fill: var(--nb-muted); font-size: 10px; text-anchor: middle; }
.vps-map .wire { stroke: var(--nb-border-2); stroke-width: 1.5; stroke-dasharray: 4 5; }
.vps-map:hover .wire.flow { stroke: rgba(246, 131, 48, .7); animation: vps-flow 1s linear infinite; }
@keyframes vps-flow { to { stroke-dashoffset: -18; } }
.vps-map .shield { fill: rgba(74, 222, 128, .12); stroke: #4ade80; }
.vps-map .shield.open { fill: rgba(251, 191, 36, .12); stroke: #fbbf24; }
.vps-map .shield.off  { fill: rgba(248, 113, 113, .1); stroke: #f87171; }
.vps-ports { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.vps-port { font-size: .72rem; padding: .2em .6em; border-radius: 999px; border: 1px solid var(--nb-border-2);
    background: var(--nb-control); color: var(--nb-text); white-space: nowrap; }
.vps-port.any { border-color: rgba(251, 191, 36, .35); }
.vps-port.any::before { content: "●"; color: #fbbf24; margin-right: .35em; font-size: .6rem; vertical-align: .1em; }
.vps-port.lim::before { content: "●"; color: #4ade80; margin-right: .35em; font-size: .6rem; vertical-align: .1em; }
.vps-port.staff { color: var(--nb-muted); border-style: dashed; }
.vps-port small { color: var(--nb-muted); margin-left: .3em; }
.vps-map .rest { font-size: .72rem; color: var(--nb-muted); margin-top: .4rem; }
.vps-map .rest:empty { display: none; }

/* azioni */
.vps-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.vps-actions .btn-primary { min-width: 9rem; }
.vps-actions .spacer { flex: 1; }

@media (max-width: 575px) {
    .vps-metrics { grid-template-columns: 1fr; }
    .vps-rings { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
    .vps-card, .vps-chart .draw { animation: none; opacity: 1; transform: none; stroke-dashoffset: 0; }
    .vps-state.running .dot::after, .vps-map:hover .wire.flow { animation: none; }
}
.vps-add .sub { font-size: .8rem; color: var(--nb-muted); }
.vps-add .btn { min-width: 11rem; pointer-events: none; }
