/* Calcoli SevenCE: stili della pagina sopra il tema DxIntra.
   dxintra-theme.css e griglie-appiccicate.css sono copie degli asset: qui solo ciò che è di questa app. */

/* Colori degli stati dei job: più scuri in chiaro per restare leggibili come testo */
:root {
    --stato-corso: #2563eb;
    --stato-attesa: #b45309;
    --stato-ok: #15803d;
    --stato-errore: #dc2626;
}

.dark,
.dark-blue {
    --stato-corso: #60a5fa;
    --stato-attesa: #fbbf24;
    --stato-ok: #4ade80;
    --stato-errore: #f87171;
}

/* ----- Struttura: footer sempre in fondo alla finestra ----- */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

#main {
    flex: 1 0 auto;
}

/* I controlli dei form non ereditano il carattere: date e pulsanti uscirebbero con quello di sistema */
button,
input,
select,
textarea {
    font-family: inherit;
}

input[type="date"] {
    font-variant-numeric: tabular-nums;
}

.footer {
    margin-top: auto;
}

/* Gli alert contengono testo con elementi inline: a blocco, non flex come nel tema */
.alert {
    display: block;
    line-height: 1.5;
    margin-bottom: 0;
}

.header-home,
.header-home:hover {
    color: inherit;
    text-decoration: none;
}

.header-sottotitolo {
    margin: 0;
    font-size: 0.875rem;
    color: var(--color-muted-foreground);
}

/* ----- Impaginazione: modulo a sinistra, job a destra; sotto i 1200 px uno sotto l'altro ----- */
/* minmax(0, 1fr) anche su una colonna: con la colonna automatica la larghezza minima della
   tabella dei job allargherebbe tutta la pagina sui telefoni */
.layout-calcoli {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 1200px) {
    .layout-calcoli {
        grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
    }
}

.layout-calcoli .card {
    margin-bottom: 0;
}

.card-header .card-title {
    margin: 0;
}

.sezione {
    margin-bottom: 1.5rem;
}

.sezione-testa {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.625rem;
}

.sezione-testa .form-label {
    margin: 0;
}

.conteggio {
    font-size: 0.75rem;
    color: var(--color-muted-foreground);
    font-variant-numeric: tabular-nums;
}

/* ----- Interruttore "Tutti i market" ----- */
.interruttore {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

.interruttore input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 2.25rem;
    height: 1.25rem;
    border-radius: 9999px;
    border: 1px solid var(--color-border);
    background: var(--color-muted);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.interruttore input::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: calc(1.25rem - 4px);
    height: calc(1.25rem - 4px);
    border-radius: 50%;
    background: var(--color-card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.interruttore input:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.interruttore input:checked::after {
    transform: translateX(1rem);
    background: var(--color-primary-foreground);
}

.interruttore input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-ring);
}

.interruttore input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ----- Elenco dei market ----- */
.elenco-market {
    max-height: 21rem;
    overflow-y: auto;
    margin-top: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-background);
}

.elenco-market.disattivato {
    opacity: 0.45;
    pointer-events: none;
}

.voce-market {
    display: grid;
    grid-template-columns: auto 3rem minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 55%, transparent);
    cursor: pointer;
    transition: background-color 0.15s;
}

/* display: grid vincerebbe sull'attributo hidden usato dalla ricerca */
.voce-market[hidden] {
    display: none;
}

.voce-market:last-of-type {
    border-bottom: none;
}

.voce-market:hover {
    background: var(--color-accent);
}

.voce-market:has(input:checked) {
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.voce-market input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.cod-market {
    font-size: 0.875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.luogo-market {
    min-width: 0;
    line-height: 1.3;
}

.localita-market {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
}

.indirizzo-market {
    display: block;
    font-size: 0.75rem;
    color: var(--color-muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nessun-risultato {
    padding: 1rem;
    font-size: 0.8rem;
    text-align: center;
    color: var(--color-muted-foreground);
}

.azioni-elenco {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.375rem;
}

/* ----- Periodo ----- */
.campi-periodo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.campi-periodo .form-label {
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    color: var(--color-muted-foreground);
}

.scorciatoie-periodo {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.scorciatoie-periodo .btn.attiva {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-primary-foreground);
}

/* ----- Riepilogo e invio ----- */
.riepilogo {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--color-muted);
}

.riepilogo-dettaglio {
    font-size: 0.8rem;
    color: var(--color-muted-foreground);
}

.riepilogo-totale {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.avviso-elabora {
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--stato-attesa);
}

.esito-elabora {
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* ----- Pannello dei job ----- */
.barra-job-riga {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.titolo-sezione {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.contatori-job {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.contatore {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.625rem;
    border: 1px solid var(--color-border);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: var(--color-muted-foreground);
}

.contatore strong {
    color: var(--color-foreground);
}

.nota-job {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
    color: var(--color-muted-foreground);
}

.nota-job .non-riuscito {
    color: var(--stato-attesa);
}

/* Stato del job: pallino colorato più etichetta, su fondo tenue dello stesso colore */
.stato {
    --c: var(--color-muted-foreground);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.125rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--c);
    background: color-mix(in srgb, var(--c) 14%, transparent);
}

.stato::before {
    content: '';
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
}

.stato-corso { --c: var(--stato-corso); }
.stato-attesa { --c: var(--stato-attesa); }
.stato-ok { --c: var(--stato-ok); }
.stato-errore { --c: var(--stato-errore); }

.stato-corso::before {
    animation: pulsa 1.4s ease-in-out infinite;
}

@keyframes pulsa {
    50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
    .stato-corso::before { animation: none; }
}

.punto {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--c, var(--color-muted-foreground));
}

.tabella-job td {
    vertical-align: middle;
}

/* Tabella più larga del riquadro (telefoni): il riquadro diventa contenitore di scroll e la quota
   calcolata per la pagina spingerebbe l'intestazione in mezzo alle righe. Lì si rinuncia all'aggancio. */
.table-wrap.deve-scorrere .table thead th {
    top: 0;
}

.tabella-job .col-stato,
.tabella-job .col-ora {
    white-space: nowrap;
}

.tabella-job .col-ora {
    font-variant-numeric: tabular-nums;
}

.tabella-job .col-market {
    min-width: 7rem;
}

.tabella-job .col-avanzamento {
    min-width: 9rem;
}

.chip-market {
    display: inline-block;
    margin: 0.0625rem 0.125rem 0.0625rem 0;
    padding: 0 0.4rem;
    border-radius: 0.3rem;
    background: var(--color-secondary);
    color: var(--color-secondary-foreground);
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.periodo-job {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.periodo-job .freccia {
    color: var(--color-muted-foreground);
}

.progress-job {
    height: 0.375rem;
}

.progress-bar.completo {
    background-color: var(--stato-ok);
}

.progress-bar.parziale {
    background-color: var(--stato-attesa);
}

/* Motivi dei giorni non elaborati, sotto la barra o il messaggio d'errore */
.motivi-job {
    margin: 0.25rem 0 0;
    padding-left: 1rem;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--color-muted-foreground);
    overflow-wrap: anywhere;
}

.motivi-job .altri {
    list-style: none;
    margin-left: -1rem;
}

.dettaglio-job {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--color-muted-foreground);
    font-variant-numeric: tabular-nums;
}

.errore-job {
    font-size: 0.8rem;
    color: var(--stato-errore);
    overflow-wrap: anywhere;
}

/* Job lanciati da questa scheda: fondo tenue e filetto del colore primario */
.tabella-job tbody tr.riga-mia > td {
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.tabella-job tbody tr.riga-mia > td:first-child {
    box-shadow: inset 3px 0 0 var(--color-primary);
}

.riga-vuota td {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--color-muted-foreground);
}
