/* Caricamento dei pannelli (src/viewer/loading.js) e skeleton (src/viewer/skeleton.js, anche plugin card-placeholder) */
#dashboard { position: relative; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- skeleton ------------------------------------------------------------------------------------------------ */
.sk { --sk-base: color-mix(in srgb, var(--text-muted) 16%, transparent); --sk-hi: color-mix(in srgb, var(--text-muted) 6%, transparent);
  position: relative; display: flex; flex-direction: column; gap: 8px; width: 100%; height: 100%; padding: 12px; box-sizing: border-box; overflow: hidden; }
.sk i, .sk b { display: block; flex: 0 0 auto; border-radius: 6px; background: var(--sk-base); }
.sk .sk-line { height: 10px; }
.sk .sk-thin { height: 7px; opacity: .8; }
.sk .sk-head { height: 14px; width: 100%; }
.sk .sk-block { flex: 1 1 auto; min-height: 40px; position: relative; }
.sk .sk-kpi { flex: 0 1 56%; max-height: 90px; width: 55%; margin: auto 0 4px; border-radius: 10px; }
.sk-bars { flex: 1 1 auto; display: flex; align-items: flex-end; gap: 7%; padding: 0 4px; min-height: 40px; }
.sk-bars i { flex: 1 1 0; border-radius: 4px 4px 0 0; }
.sk-svg { flex: 1 1 auto; width: 100%; min-height: 40px; }
.sk-svg polyline { fill: none; stroke: var(--sk-base); stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.sk-pie-wrap { flex: 1 1 auto; display: flex; align-items: center; gap: 12%; }
.sk .sk-circle { flex: 0 0 auto; width: min(46%, 140px); aspect-ratio: 1; border-radius: 50%; }
.sk-legend { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; }
.sk-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.sk-row i { height: 9px; }
.sk-item { display: flex; gap: 10px; align-items: center; }
.sk-item > div { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; }
.sk .sk-dot { width: 22px; height: 22px; border-radius: 50%; }
.sk .sk-media { border-radius: 8px; display: grid; place-items: center; }
.sk .sk-play { width: 0; height: 0; border-radius: 0; background: none; border-left: 18px solid var(--sk-hi); border-top: 11px solid transparent; border-bottom: 11px solid transparent; }
.sk .sk-map { border-radius: 8px; }
.sk .sk-pin { position: absolute; width: 12px; height: 12px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--sk-hi); }
.sk-page { flex: 1 1 auto; align-self: center; width: min(78%, 320px); display: flex; flex-direction: column; gap: 7px; padding: 14px; border-radius: 4px; box-shadow: 0 0 0 1px var(--sk-base); }
.sk-field { display: flex; flex-direction: column; gap: 5px; }
.sk .sk-input { height: 26px; border-radius: 7px; }
.sk-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; pointer-events: none; }
.sk-label { padding: 2px 10px; border-radius: 999px; background: var(--surface); color: var(--text-muted); font: 600 12px system-ui, sans-serif; box-shadow: 0 0 0 1px var(--border); }
.sk.is-error i, .sk.is-error b { opacity: .45; }
/* animazioni: shimmer (riflesso che scorre) o pulse */
.sk-anim-shimmer::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 55%, transparent), transparent); animation: sk-shimmer 1.4s ease-in-out infinite; }
.sk-anim-pulse i, .sk-anim-pulse b, .sk-anim-pulse .sk-svg { animation: sk-pulse 1.4s ease-in-out infinite; }
@keyframes sk-shimmer { to { transform: translateX(100%); } }
@keyframes sk-pulse { 50% { opacity: .45; } }
.sk-spinner { width: 26px; height: 26px; border: 3px solid color-mix(in srgb, var(--text-muted) 25%, transparent); border-top-color: var(--accent, #2563eb); border-radius: 50%; animation: sk-spin .8s linear infinite; }
.sk-spinner.is-lg { width: 38px; height: 38px; border-width: 4px; }
@keyframes sk-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .sk-anim-shimmer::after, .sk-anim-pulse i, .sk-anim-pulse b, .sk-anim-pulse .sk-svg { animation: none; }
  .sk-spinner { animation-duration: 2.4s; }
}

/* ---- skeleton sopra la card ---------------------------------------------------------------------------------- */
.card > .card-skel { position: absolute; left: 0; right: 0; bottom: 0; top: var(--card-head-h, 34px); z-index: 20; display: flex; flex-direction: column; background: var(--surface); transition: opacity .2s ease; }
.card > .card-skel.is-out { opacity: 0; pointer-events: none; }
.card-skel > .sk { flex: 1 1 auto; min-height: 0; }
.card-skel-msg { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2, var(--surface)); box-shadow: 0 0 0 1px var(--border); color: var(--text); font: 12px system-ui, sans-serif; }
.card-skel-msg[hidden] { display: none; }
.card.is-load-error .card-skel-msg { color: #b91c1c; box-shadow: 0 0 0 1px #fca5a5; }
:root[data-theme="dark"] .card.is-load-error .card-skel-msg { color: #fca5a5; }
.card-skel-btn, .panel-loading-btn { padding: 3px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: 600 12px system-ui, sans-serif; cursor: pointer; }
.card-skel-btn:hover, .panel-loading-btn:hover { border-color: var(--accent, #2563eb); }

/* ---- indicatore a livello di pannello ------------------------------------------------------------------------ */
#dashboard.is-panel-loading > .dashboard-grid { visibility: hidden; }
.panel-loading { position: absolute; inset: 0; z-index: 30; display: grid; place-items: start center; padding: min(12vh, 120px) 16px 16px; transition: opacity .2s ease; }
.panel-loading.is-out { opacity: 0; }
.panel-loading.is-fetch { background: transparent; }
.panel-loading-box { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(100%, 420px); padding: 22px 24px; border-radius: 14px; background: var(--surface); box-shadow: 0 0 0 1px var(--border), 0 10px 30px rgb(0 0 0 / .08); color: var(--text); font: 13px/1.4 system-ui, sans-serif; text-align: center; }
.panel-loading-sub { color: var(--text-muted); font-size: 12px; }
.panel-loading-bar { width: 100%; height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--text-muted) 16%, transparent); overflow: hidden; }
.panel-loading-bar i { display: block; height: 100%; background: var(--accent, #2563eb); border-radius: 999px; transition: width .25s ease; }
.panel-loading-list { list-style: none; margin: 0; padding: 0; width: 100%; max-height: 140px; overflow: auto; text-align: left; color: var(--text-muted); font-size: 12px; }
.panel-loading-list li.is-slow { color: #b45309; }
.panel-loading-slow { color: #b45309; font-size: 12px; }
.panel-loading-err { color: #b91c1c; font-size: 12px; }
:root[data-theme="dark"] .panel-loading-list li.is-slow, :root[data-theme="dark"] .panel-loading-slow { color: #fbbf24; }
:root[data-theme="dark"] .panel-loading-err { color: #fca5a5; }
