/*
 * La simulazione dell'interfaccia di XenReplica (pagina /solutions/xenreplica/demo, dentro un iframe
 * della landing). Colori, misure e componenti sono quelli di src/XenReplica.Service/wwwroot/app.css
 * del repository XenReplica, riscritti senza Bootstrap: chi guarda deve vedere il prodotto, non
 * un'interpretazione. Se l'interfaccia vera cambia, va riallineato anche questo file.
 */

:root {
    --xr-graphite: #1b2530;
    --xr-graphite-light: #3e5468;
    --xr-blue: #3a84c9;
    --xr-blue-deep: #25527d;
    --xr-blue-tint: #93bbe1;
    --xr-blue-pale: #ccdff1;
    --xr-sky: #edf3f9;
    --xr-frame: #d3dce5;
    --xr-accent: #3270ab;
    --xr-sidebar-text: #c3d0dc;
    --xr-text: var(--xr-graphite);
    --xr-surface: #f2f5f9;
    --xr-border: #d9e1e9;
    --xr-row-hover: #f5f8fc;
    --xr-ok: #1e7e34;
    --xr-warn: #b76e00;
    --xr-error: #b42318;
    --xr-muted: #5e7185;
}

* { box-sizing: border-box; }

#xr-app { height: 100%; }

html, body {
    height: 100%;
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    background: var(--xr-surface);
    color: var(--xr-text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--xr-accent); }
a:hover { color: var(--xr-blue-deep); }
button { font: inherit; }
h1, h2 { margin: 0; }
:focus-visible { outline: 2px solid var(--xr-blue); outline-offset: 2px; }

/* ---------------------------------------------------------------- struttura */
.xr-shell { display: flex; height: 100%; }

.xr-sidebar {
    width: 236px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--xr-graphite) 0%, var(--xr-graphite) 55%, #1c3044 100%);
    color: var(--xr-sidebar-text);
    display: flex;
    flex-direction: column;
}

.xr-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.15rem 1.1rem 1.1rem;
    color: #fff;
    font-weight: 600;
    font-size: 1.4rem;
    letter-spacing: -.01em;
    border-bottom: 1px solid rgba(147, 187, 225, .14);
}

.xr-brand img { flex-shrink: 0; width: 46px; height: 46px; border-radius: 11px; }
.xr-brand-name span { color: var(--xr-blue-tint); }

.xr-nav { display: flex; flex-direction: column; padding: .85rem .6rem; gap: .15rem; }

.xr-nav-link {
    display: block;
    padding: .55rem .85rem;
    border: 0;
    border-radius: .4rem;
    background: none;
    color: var(--xr-sidebar-text);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.xr-nav-link:hover { background: rgba(147, 187, 225, .1); color: #fff; }
.xr-nav-link.active { background: var(--xr-accent); color: #fff; box-shadow: inset 3px 0 0 var(--xr-blue-tint); }

.xr-nav-section {
    margin: 1.1rem .85rem .3rem;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #8193a5;
}

.xr-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.xr-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .9rem;
    padding: .6rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--xr-border);
    min-height: 3.2rem;
}

.xr-user { font-weight: 500; }
.xr-role { padding: .1rem .5rem; border: 1px solid var(--xr-border); border-radius: .35rem; background: #f8fafc; font-size: .78rem; font-weight: 600; }

.xr-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.xr-content { flex: 1; padding: 1.5rem; }
.xr-footer { padding: .6rem 1.5rem; font-size: .8rem; color: var(--xr-muted); border-top: 1px solid var(--xr-border); }

/* ---------------------------------------------------------------- componenti */
.xr-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.xr-page-header h1 { font-size: 1.6rem; font-weight: 600; }
.xr-page-header h1 .xr-status { margin-left: .5rem; font-size: .8rem; vertical-align: middle; }
.xr-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.xr-card {
    background: #fff;
    border: 1px solid var(--xr-border);
    border-radius: .6rem;
    padding: 1.1rem 1.25rem;
}

.xr-card + .xr-card { margin-top: 1rem; }
.xr-card h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: .75rem; }
.xr-subtitle { font-weight: 600; margin-bottom: .45rem; }
.xr-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.xr-grid-2 > .xr-card { margin: 0; }
.xr-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }

.xr-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.xr-kpi .xr-card { margin: 0; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.xr-kpi .xr-card:hover { border-color: var(--xr-blue-tint); box-shadow: 0 2px 10px rgba(37, 82, 125, .12); }
.xr-kpi-value { font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.xr-kpi-value.xr-running { color: var(--xr-accent); }
.xr-kpi-label { color: var(--xr-muted); font-size: .85rem; }

.xr-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .8rem;
    border: 1px solid #aebbc8;
    border-radius: .4rem;
    background: #fff;
    color: var(--xr-graphite-light);
    font-size: .95rem;
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
}

.xr-btn:hover { background: var(--xr-graphite-light); border-color: var(--xr-graphite-light); color: #fff; }
.xr-btn-primary { background: var(--xr-accent); border-color: var(--xr-accent); color: #fff; }
.xr-btn-primary:hover { background: var(--xr-blue-deep); border-color: var(--xr-blue-deep); }
.xr-btn-outline-primary { border-color: var(--xr-accent); color: var(--xr-accent); }
.xr-btn-outline-primary:hover { background: var(--xr-accent); border-color: var(--xr-accent); }
.xr-btn-outline-danger { border-color: var(--xr-error); color: var(--xr-error); }
.xr-btn-outline-danger:hover { background: var(--xr-error); border-color: var(--xr-error); }
.xr-btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.xr-btn[disabled] { opacity: .55; cursor: default; pointer-events: none; }

.xr-table-wrap { position: relative; background: #fff; border: 1px solid var(--xr-border); border-radius: .6rem; overflow-x: auto; }
.xr-table { width: 100%; border-collapse: collapse; background: #fff; }
.xr-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--xr-muted); font-weight: 600; white-space: nowrap; text-align: left; }
.xr-table td, .xr-table th { padding: .5rem .65rem; vertical-align: middle; border-bottom: 1px solid var(--xr-border); }
.xr-table tbody tr:last-child td { border-bottom: 0; }
.xr-table tbody tr:hover { background: var(--xr-row-hover); }
.xr-table-wrap .xr-table td { white-space: nowrap; }
.xr-table td.xr-wrap { white-space: normal; min-width: 10rem; }
.xr-table td.xr-wrap-sm { white-space: normal; min-width: 7rem; }
.xr-num { text-align: right; }
.xr-table th.xr-num { text-align: right; }

.xr-muted { color: var(--xr-muted); }
.xr-small { font-size: .85rem; }
.xr-mono { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: .85em; }
.xr-link { color: var(--xr-accent); text-decoration: underline; cursor: pointer; background: none; border: 0; padding: 0; font: inherit; text-align: left; }
.xr-link:hover { color: var(--xr-blue-deep); }

.xr-tag { display: inline-block; margin-left: .35rem; padding: .05rem .45rem; border-radius: 999px; font-size: .72rem; font-weight: 500; vertical-align: .1em; white-space: nowrap; background: var(--xr-sky); color: var(--xr-blue-deep); box-shadow: inset 0 0 0 1px var(--xr-blue-pale); }

.xr-status {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .12rem .55rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
}

.xr-status::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.xr-status-ok { background: #e3f4e7; color: var(--xr-ok); }
.xr-status-warn { background: #fdf1dc; color: var(--xr-warn); }
.xr-status-error { background: #fde7e5; color: var(--xr-error); }
.xr-status-running { background: var(--xr-sky); color: var(--xr-blue-deep); box-shadow: inset 0 0 0 1px var(--xr-blue-pale); }
.xr-status-idle { background: #eaeff4; color: var(--xr-muted); }

.xr-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem; margin-bottom: 1rem; }

.xr-input, .xr-select {
    padding: .45rem .7rem;
    border: 1px solid #ced8e2;
    border-radius: .4rem;
    background: #fff;
    color: var(--xr-text);
    font: inherit;
}

.xr-input { flex: 1 1 220px; min-width: 180px; max-width: 340px; }
.xr-select { flex: 0 1 200px; }
.xr-input:focus, .xr-select:focus { border-color: var(--xr-blue-tint); outline: 0; box-shadow: 0 0 0 .25rem rgba(58, 132, 201, .25); }
.xr-check { display: inline-flex; align-items: center; gap: .45rem; }
.xr-check input { width: 1rem; height: 1rem; accent-color: var(--xr-accent); }

/* Avanzamento */
.xr-progress-cell { display: flex; align-items: center; gap: .6rem; min-width: 7.5rem; }
.xr-progress { flex: 1; height: .55rem; border-radius: 999px; background: #e3e9ef; overflow: hidden; }
.xr-progress-bar { height: 100%; border-radius: 999px; background: var(--xr-accent); transition: width .45s linear; }
.xr-progress-bar.xr-ok { background: #198754; }
.xr-progress-bar.xr-warn { background: #e0a100; }
.xr-progress-bar.xr-idle { background: #8193a5; }
.xr-progress-bar.xr-running {
    background-image: linear-gradient(45deg, rgba(255, 255, 255, .18) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .18) 50%, rgba(255, 255, 255, .18) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
    animation: xr-stripes 1s linear infinite;
}
.xr-progress-text { font-size: .78rem; color: var(--xr-muted); white-space: nowrap; }
.xr-progress-lg .xr-progress { height: .75rem; }

@keyframes xr-stripes { from { background-position: 1rem 0; } to { background-position: 0 0; } }

/* Dettagli */
.xr-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 2.5rem; margin: 0; }
.xr-dl dt { color: var(--xr-muted); font-weight: 400; }
.xr-dl dd { margin: 0; }

.xr-log { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: .8rem; height: 210px; overflow-y: auto; background: #121b24; color: #d5dee7; border-radius: .5rem; padding: .75rem 1rem; }
.xr-log-line { white-space: pre-wrap; }
.xr-log-line.xr-new { animation: xr-fade .5s ease-out; }
@keyframes xr-fade { from { opacity: 0; transform: translateY(3px); } }

.xr-back { display: inline-block; margin-bottom: .15rem; font-size: .85rem; text-decoration: none; }

/* Grafico della velocità: SVG per area e linea, HTML per griglia ed etichette (come ThroughputChart). */
.xr-chart {
    --xr-chart-height: 220px;
    --xr-chart-axis: 4.6rem;
    display: grid;
    grid-template-columns: var(--xr-chart-axis) minmax(0, 1fr);
    grid-template-rows: var(--xr-chart-height) auto;
    column-gap: .6rem;
}

.xr-chart-compact { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--xr-chart-height); }
.xr-chart-y { position: relative; font-size: .72rem; color: var(--xr-muted); }
.xr-chart-y span { position: absolute; right: 0; transform: translateY(50%); white-space: nowrap; line-height: 1; }
.xr-chart-plot { position: relative; border-bottom: 1px solid var(--xr-frame); }
.xr-chart-grid { position: absolute; left: 0; right: 0; border-top: 1px solid #e3e9ef; }
.xr-chart-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.xr-chart-area { stroke: none; }
.xr-chart-line { fill: none; stroke: var(--xr-accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.xr-chart-limit { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--xr-warn); }
.xr-chart-limit span { position: absolute; right: 0; bottom: .2rem; font-size: .72rem; font-weight: 500; color: var(--xr-warn); background: rgba(255, 255, 255, .85); padding: 0 .25rem; border-radius: .2rem; }
.xr-chart-marker { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--xr-blue-tint); }
.xr-chart-marker span { position: absolute; top: 0; left: .3rem; font-size: .72rem; color: var(--xr-blue-deep); white-space: nowrap; background: rgba(255, 255, 255, .85); padding: 0 .2rem; border-radius: .2rem; }
.xr-chart-marker-end span { left: auto; right: .3rem; }
.xr-chart-x { grid-column: 2; position: relative; height: 1.4rem; font-size: .72rem; color: var(--xr-muted); }
.xr-chart-x span { position: absolute; top: .3rem; transform: translateX(-50%); white-space: nowrap; }
.xr-chart-x span:first-child { transform: none; }
.xr-chart-x span:last-child { transform: translateX(-100%); }
.xr-chart-live { position: absolute; width: .6rem; height: .6rem; margin: 0 0 -.3rem -.3rem; border-radius: 50%; background: var(--xr-accent); animation: xr-pulse 1.6s ease-out infinite; }
@keyframes xr-pulse { from { box-shadow: 0 0 0 0 rgba(50, 112, 171, .45); } to { box-shadow: 0 0 0 .6rem rgba(50, 112, 171, 0); } }

.xr-speed-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.1rem; }
.xr-speed-stat { background: var(--xr-surface); border: 1px solid var(--xr-border); border-radius: .5rem; padding: .6rem .8rem; }
.xr-speed-stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--xr-muted); font-weight: 600; }
.xr-speed-stat-value { font-size: 1.35rem; font-weight: 600; line-height: 1.25; }
.xr-speed-stat-sub { font-size: .8rem; color: var(--xr-muted); }
.xr-speed-stat-live { border-color: var(--xr-blue-pale); background: var(--xr-sky); }
.xr-speed-stat-live .xr-speed-stat-value { color: var(--xr-blue-deep); }

/* Panoramica: colonne delle ultime esecuzioni e repliche in corso */
.xr-bars-wrap { position: relative; height: 150px; }
.xr-bars { position: absolute; inset: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; column-gap: 4px; }
.xr-bar { height: 100%; display: flex; align-items: flex-end; border: 0; padding: 0; background: none; cursor: pointer; }
.xr-bar span { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--xr-accent); transition: height .4s ease-out, background .15s; }
.xr-bar:hover span { background: var(--xr-blue-deep); }
.xr-bar-warn span { background: var(--xr-warn); }
.xr-bar-muted span { background: #aebbc8; }
.xr-chart-legend { grid-column: 2; display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .35rem; font-size: .8rem; color: var(--xr-muted); }
.xr-chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.xr-chart-legend span::before { content: ""; width: .65rem; height: .65rem; border-radius: 2px; background: var(--xr-accent); }
.xr-chart-legend .xr-legend-warn::before { background: var(--xr-warn); }
.xr-chart-legend .xr-legend-muted::before { background: #aebbc8; }

.xr-live-run + .xr-live-run { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--xr-border); }
.xr-live-run-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.xr-live-run-body { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 1rem; align-items: center; margin-top: .35rem; }
.xr-live-value { font-size: 1.5rem; font-weight: 600; line-height: 1.2; color: var(--xr-blue-deep); }

/* Finestra «Informazioni» e messaggi */
.xr-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(27, 37, 48, .5); }
.xr-modal { width: 100%; max-width: 440px; border-radius: .7rem; background: #fff; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.xr-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--xr-border); }
.xr-modal-header h2 { font-size: 1.15rem; font-weight: 600; }
.xr-modal-body { padding: 1.1rem 1.25rem; }
.xr-modal-footer { display: flex; justify-content: flex-end; padding: .9rem 1.25rem; border-top: 1px solid var(--xr-border); }
.xr-about { display: flex; gap: 1rem; align-items: center; margin-bottom: .8rem; }
.xr-about img { width: 64px; height: 64px; border-radius: 15px; }
.xr-message { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: 1rem; padding: .7rem .9rem; border: 1px solid var(--xr-blue-pale); border-radius: .5rem; background: var(--xr-sky); color: var(--xr-blue-deep); }
.xr-message-ok { border-color: #b7e0c1; background: #e3f4e7; color: var(--xr-ok); }

/* La fascia della simulazione: dice che cosa si sta guardando. Non fa parte del prodotto. */
.xr-sim {
    position: fixed;
    right: .9rem;
    bottom: .9rem;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: .5rem;
    max-width: calc(100% - 1.8rem);
    padding: .4rem .8rem;
    border-radius: 999px;
    background: rgba(27, 37, 48, .9);
    color: #fff;
    font-size: .8rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
    pointer-events: none;
}

.xr-sim::before { content: ""; flex-shrink: 0; width: .5rem; height: .5rem; border-radius: 50%; background: #f5c26b; }

/* ---------------------------------------------------------------- schermi stretti */
/* Nella landing l'iframe e' largo quanto la pagina, non quanto lo schermo di un amministratore: sotto
   i 1360 px il carattere scende di poco, come un browser con lo zoom al 90 %, e le tabelle ci stanno
   senza scorrere. */
@media (max-width: 1360px) {
    html, body { font-size: 13.5px; }
    .xr-table td, .xr-table th { padding: .45rem .5rem; }
}

@media (max-width: 900px) {
    .xr-sidebar { width: 196px; }
    .xr-brand { font-size: 1.2rem; padding: .9rem; }
    .xr-brand img { width: 38px; height: 38px; }
    .xr-grid-2, .xr-split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 680px) {
    html, body { font-size: 14px; }
    .xr-shell { flex-direction: column; }
    .xr-sidebar { width: 100%; }
    .xr-brand { padding: .6rem .9rem; font-size: 1.1rem; border-bottom: 0; }
    .xr-brand img { width: 32px; height: 32px; border-radius: 8px; }
    .xr-nav { flex-direction: row; overflow-x: auto; padding: 0 .5rem .5rem; scrollbar-width: none; }
    .xr-nav-link { white-space: nowrap; padding: .4rem .7rem; }
    .xr-nav-section, .xr-nav-admin, .xr-topbar { display: none; }
    .xr-content { padding: 1rem; }
    .xr-page-header h1 { font-size: 1.3rem; }
    .xr-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .xr-kpi-value { font-size: 1.5rem; }
    .xr-live-run-body { grid-template-columns: minmax(0, 1fr); gap: .4rem; }
    .xr-chart { --xr-chart-axis: 3.8rem; --xr-chart-height: 170px; column-gap: .4rem; }
    .xr-dl { gap: .25rem 1rem; }
    .xr-sim { left: .6rem; right: .6rem; bottom: .6rem; justify-content: center; padding: .3rem .7rem; font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
    .xr-progress-bar, .xr-bar span { transition: none; }
    .xr-progress-bar.xr-running, .xr-chart-live, .xr-log-line.xr-new { animation: none; }
}
