/*
 * Memento UI - stili condivisi del portale centrale.
 * Caricato dopo style.css (template): qui vivono solo gli adattamenti
 * specifici dell'applicazione, organizzati per componente.
 * Non contiene logica: solo presentazione.
 */

:root {
    --mm-primary: #F26522;
    --mm-primary-dark: #C9501A;      /* testo arancione su fondo chiaro: contrasto >= 4.5:1 */
    --mm-primary-soft: rgba(242, 101, 34, .10);
    --mm-text: #1F2937;
    --mm-text-muted: #5B6573;
    --mm-border: #E5E7EB;
    --mm-radius: 8px;
    --mm-focus: 0 0 0 .2rem rgba(242, 101, 34, .35);
}

/* ------------------------------------------------------------------ *
 * Accessibilita': focus visibile per tastiera
 * ------------------------------------------------------------------ */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--mm-primary);
    outline-offset: 2px;
    box-shadow: none;
}

.text-muted {
    color: var(--mm-text-muted) !important;
}

/* ------------------------------------------------------------------ *
 * Header
 * ------------------------------------------------------------------ */
.header .header-brand-logo {
    height: 30px;
    width: auto;
    max-width: 100%;
    vertical-align: middle;
}

.header .btn-menubar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
}

.header .header-disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: auto;
}

/* ------------------------------------------------------------------ *
 * Sidebar: le icone del progetto sono font Tabler (<i class="ti">),
 * il template prevedeva SVG, quindi senza queste regole risultavano
 * minuscole e attaccate al testo.
 * ------------------------------------------------------------------ */
.sidebar .sidebar-menu > ul > li {
    margin-bottom: 6px;
}

.sidebar .sidebar-menu > ul > li.menu-title {
    margin-bottom: 8px;
}

.sidebar .sidebar-menu > ul > li > a > i.ti {
    flex: 0 0 20px;
    width: 20px;
    margin-right: 12px;
    font-size: 20px;
    line-height: 1;
    text-align: center;
    color: #637381;
}

.sidebar .sidebar-menu > ul > li > a > span:not(.menu-arrow) {
    flex: 1 1 auto;
}

.sidebar .sidebar-menu > ul > li > a:hover {
    background: rgba(0, 0, 0, .04);
    border-radius: 5px;
}

.sidebar .sidebar-menu > ul > li.active > a > i.ti,
.sidebar .sidebar-menu > ul > li > a.active > i.ti,
.sidebar .sidebar-menu > ul > li.submenu > a.subdrop > i.ti {
    color: var(--mm-primary);
}

.sidebar .sidebar-menu > ul > li.active > a,
.sidebar .sidebar-menu > ul > li > a.active {
    background: var(--mm-primary-soft);
    border-radius: 5px;
}

.sidebar .sidebar-menu > ul > li.active > a > span,
.sidebar .sidebar-menu > ul > li > a.active > span:not(.menu-arrow) {
    color: var(--mm-primary-dark);
    font-weight: 600;
}

.sidebar .sidebar-menu > ul > li.submenu > ul > li > a {
    padding: 8px 12px 8px 47px;
    color: #4B5563;
}

.sidebar .sidebar-menu > ul > li.submenu > ul > li > a.active {
    color: var(--mm-primary-dark);
    font-weight: 600;
}

.sidebar .sidebar-avatar {
    width: 60px;
    height: 60px;
    object-fit: cover;
    font-size: 1.5rem;
}

/* ------------------------------------------------------------------ *
 * Avatar e icone nelle card statistiche
 * ------------------------------------------------------------------ */
.avatar > i.ti {
    font-size: 1.25rem;
    line-height: 1;
}

.avatar.avatar-xl > i.ti {
    font-size: 1.75rem;
}

/* ------------------------------------------------------------------ *
 * Tabelle: scorrimento orizzontale dentro la card, mai sulla pagina
 * ------------------------------------------------------------------ */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.table > :not(caption) > * > * {
    vertical-align: middle;
}

/* ------------------------------------------------------------------ *
 * Pulsanti con sola icona: area di click minima
 * ------------------------------------------------------------------ */
.btn-icon,
.btn-sm.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
}

/* ------------------------------------------------------------------ *
 * Riduzione del movimento (preferenza di sistema)
 * ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ------------------------------------------------------------------ *
 * Profilo
 * ------------------------------------------------------------------ */
.profile-avatar-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    font-size: 3rem;
}

/* ------------------------------------------------------------------ *
 * Scala tipografica: il template ridefinisce .fs-4/.fs-5/.fs-6 a
 * 4-6px (!important), rendendo illeggibili le icone delle card KPI.
 * Si ripristinano i valori standard di Bootstrap.
 * ------------------------------------------------------------------ */
.fs-4 { font-size: 1.5rem !important; }
.fs-5 { font-size: 1.25rem !important; }
.fs-6 { font-size: 1rem !important; }

/* ------------------------------------------------------------------ *
 * Alert: contrasto testo (WCAG AA)
 * ------------------------------------------------------------------ */
.alert-warning { color: #7A4B00; }
.alert-success { color: #146C43; }
.alert-danger  { color: #A12622; }
.alert-info    { color: #0A5A75; }

/* ------------------------------------------------------------------ *
 * Badge di stato: forma unica e colori semantici con contrasto >= 4.5:1
 *   verde = attivo/ok, grigio = inattivo/neutro, giallo = attenzione,
 *   rosso = errore/scaduto, blu = informazione, arancio Memento = primario
 * Valgono sia per le varianti Bootstrap (bg-*) sia per quelle del
 * template (badge-*), cosi' lo stesso stato ha sempre lo stesso aspetto.
 * ------------------------------------------------------------------ */
.badge {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.2;
    padding: .35em .65em;
    border-radius: 6px;
    white-space: nowrap;
}
.badge.badge-xs { font-size: .7rem; padding: .3em .55em; }

.badge.bg-success,   .badge.badge-success   { background-color: #157347 !important; color: #fff !important; }
.badge.bg-secondary, .badge.badge-secondary { background-color: #5B6573 !important; color: #fff !important; }
.badge.bg-danger,    .badge.badge-danger    { background-color: #C62828 !important; color: #fff !important; }
.badge.bg-primary,   .badge.badge-primary   { background-color: var(--mm-primary-dark) !important; color: #fff !important; }
.badge.bg-info,      .badge.badge-info      { background-color: #0B65C2 !important; color: #fff !important; }
.badge.bg-warning,   .badge.badge-warning   { background-color: #FFC107 !important; color: #1F2937 !important; }
.badge.bg-light,     .badge.bg-white        { background-color: #F3F4F6 !important; color: #1F2937 !important; border: 1px solid var(--mm-border); }

/* ------------------------------------------------------------------ *
 * Pulsanti e campi: dimensioni e raggio coerenti
 * ------------------------------------------------------------------ */
.btn { border-radius: 6px; }
.btn-primary:hover, .btn-primary:focus { background-color: var(--mm-primary-dark); border-color: var(--mm-primary-dark); }
.form-control, .form-select { border-radius: 6px; }
.form-label { font-weight: 500; color: var(--mm-text); }

/* ------------------------------------------------------------------ *
 * Filtri: su schermi piccoli i campi occupano tutta la riga (Bootstrap
 * li lascia spesso a larghezza intera ma con spaziature irregolari);
 * i pulsanti di azione del filtro si dispongono in riga.
 * ------------------------------------------------------------------ */
@media (max-width: 767.98px) {
    form.filters-form .row > [class*="col-"],
    form[method="GET"] .row.g-3 > [class*="col-"] {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
    form.filters-form .btn,
    form[method="GET"] .row .btn { min-height: 40px; }
}

/* ------------------------------------------------------------------ *
 * Tabelle: intestazioni leggibili, azioni che non vanno a capo
 * ------------------------------------------------------------------ */
.table thead th { font-weight: 600; color: var(--mm-text); white-space: nowrap; }
.table td .btn + .btn, .table td form + form, .table td a + form { margin-left: 4px; }
.table td.text-end, .table td .d-flex.gap-1 { white-space: nowrap; }

/* ------------------------------------------------------------------ *
 * Modali: titolo e chiusura allineati
 * ------------------------------------------------------------------ */
.modal-header .modal-title { font-size: 1.125rem; font-weight: 600; }
.modal-footer { gap: .5rem; }

/* Filtri avanzati: su desktop restano sempre visibili e si dispongono
   nella stessa griglia; sotto 992px sono richiudibili ("Altri filtri"). */
@media (min-width: 992px) {
    .filters-advanced.collapse:not(.show),
    .filters-advanced.collapse.show,
    .filters-advanced.collapsing { display: contents; height: auto; }
    /* con display:contents i figli non sono piu' figli diretti di .row:
       si replicano le regole di griglia che Bootstrap applica a .row > * */
    .filters-advanced > * {
        flex-shrink: 0;
        max-width: 100%;
        padding-right: calc(var(--bs-gutter-x) * .5);
        padding-left: calc(var(--bs-gutter-x) * .5);
        margin-top: var(--bs-gutter-y);
    }
}
@media (max-width: 991.98px) {
    .filters-advanced { width: 100%; flex: 0 0 100%; }
    .filters-advanced > [class*="col-"] { margin-top: 0; }
}

/* Campi: altezza uniforme tra input e select (prima 38px vs 42px) */
.form-control:not(textarea):not(.form-control-sm):not(.form-control-lg):not([type="color"]):not([type="range"]),
.form-select:not(.form-select-sm):not(.form-select-lg) {
    min-height: 42px;
}

/* Barra azioni "Dipendenti": il menu Azioni occupa la riga su smartphone */
@media (max-width: 575.98px) {
    .central-employees-toolbar .dropdown,
    .central-employees-toolbar .dropdown > .btn { width: 100%; }
}

/* ------------------------------------------------------------------ *
 * Tabelle larghe: la colonna "Azioni" (ultima, allineata a destra) resta
 * visibile mentre la tabella scorre in orizzontale dentro la card.
 * ------------------------------------------------------------------ */
.table-responsive .table:has(> thead > tr > th:last-child.text-end) > thead > tr > th:last-child,
.table-responsive .table:has(> thead > tr > th:last-child.text-end) > tbody > tr > td:last-child,
.dataTables_wrapper .table:has(> thead > tr > th:last-child.text-end) > thead > tr > th:last-child,
.dataTables_wrapper .table:has(> thead > tr > th:last-child.text-end) > tbody > tr > td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    box-shadow: -6px 0 6px -6px rgba(0, 0, 0, .18);
}
.table-responsive .table:has(> thead > tr > th:last-child.text-end) > tbody > tr > td:last-child,
.dataTables_wrapper .table:has(> thead > tr > th:last-child.text-end) > tbody > tr > td:last-child { background-color: #fff; }
.table-responsive .table:has(> thead > tr > th:last-child.text-end) > thead > tr > th:last-child,
.dataTables_wrapper .table:has(> thead > tr > th:last-child.text-end) > thead > tr > th:last-child { background-color: #E9ECEF; }
.table-responsive .table-hover:has(> thead > tr > th:last-child.text-end) > tbody > tr:hover > td:last-child,
.dataTables_wrapper .table-hover:has(> thead > tr > th:last-child.text-end) > tbody > tr:hover > td:last-child { background-color: #F6F7F9; }

/* Celle con testo lungo (es. note di rilascio): altezza limitata, scorrimento interno */
.cell-clamp { max-height: 6.5em; overflow-y: auto; white-space: normal; min-width: 240px; }

/* ------------------------------------------------------------------ *
 * Paginazione compatta (pagina Dipendenti e template condiviso
 * resources/views/vendor/pagination/tailwind.blade.php): frecce e
 * numeri della stessa altezza, icone centrate.
 * ------------------------------------------------------------------ */
.pagination.pagination-sm .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 31px;
}
.pagination.pagination-sm .page-item.disabled .page-link { opacity: .55; }

/* ------------------------------------------------------------------ *
 * Dashboard Admin: riquadri "Aziende" e "Situazione incassi" con la
 * relativa finestra di dettaglio. Tutte le classi hanno il prefisso
 * mm-dash- per non alterare le altre pagine.
 * ------------------------------------------------------------------ */
/* I due riquadri condividono le righe (intestazione, descrizione, valori): nessuna altezza fissa. */
.mm-dash-riepilogo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.mm-dash-corpo { display: grid; grid-template-rows: auto auto 1fr; }
.mm-dash-intestazione { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; justify-content: space-between; gap: .5rem; }
.mm-dash-descrizione { margin: .5rem 0 1rem; font-size: .8125rem; line-height: 1.45; color: var(--mm-text-muted); }
.mm-dash-testata { display: flex; align-items: center; gap: .75rem; min-height: 40px; }
/* Il tema rende maiuscola ogni iniziale dei titoli delle card. */
.mm-dash-testata .card-title { text-transform: none; }
.mm-dash-filtri { display: flex; gap: .5rem; }
.mm-dash-filtri .form-select { width: auto; min-height: 40px; }
/* Due valori sullo sfondo della scheda, separati da linee sottili: il colore di stato resta solo su numeri e icone. */
.mm-dash-valori { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; border-top: 1px solid var(--mm-border); }
.mm-dash-valore {
    display: flex; flex-direction: column; align-items: flex-start; gap: .35rem;
    min-width: 0; padding: 1rem 1.25rem .25rem 0; text-align: left; cursor: pointer;
    background: transparent; border: 0;
}
.mm-dash-valore + .mm-dash-valore { padding: 1rem 0 .25rem 1.25rem; border-left: 1px solid var(--mm-border); }
.mm-dash-valore:hover .mm-dash-azione { color: var(--mm-text); text-decoration: underline; }
.mm-dash-valore:focus-visible { outline: 2px solid var(--primary, #F26522); outline-offset: 2px; }
.mm-dash-etichetta { font-weight: 600; color: var(--mm-text); }
.mm-dash-numero { font-size: 2.25rem; font-weight: 700; line-height: 2.6rem; color: var(--mm-text); font-variant-numeric: tabular-nums; max-width: 100%; overflow-wrap: anywhere; }
.mm-dash-importo { font-size: clamp(1.5rem, 1.1rem + .7vw, 1.9rem); white-space: nowrap; }
.mm-dash-positivo .mm-dash-numero, .mm-dash-positivo .mm-dash-etichetta i { color: #146C43; }
.mm-dash-negativo .mm-dash-numero, .mm-dash-negativo .mm-dash-etichetta i { color: #8E3B36; }
.mm-dash-attesa   .mm-dash-numero, .mm-dash-attesa   .mm-dash-etichetta i { color: #8A5200; }
.mm-dash-nota { font-size: .8rem; color: var(--mm-text); }
.mm-dash-azione { font-size: .8rem; color: var(--mm-text-muted); margin-top: auto; }
[data-aggiornamento="1"] .mm-dash-importo { opacity: .45; }

.mm-dash-tabella-contenitore { overflow-x: auto; }
.mm-dash-tabella { width: 100%; margin: 0; font-size: .875rem; }
.mm-dash-tabella th, .mm-dash-tabella td { padding: .55rem .65rem; border-bottom: 1px solid var(--mm-border); vertical-align: top; }
.mm-dash-tabella th { background: #F3F4F6; font-weight: 600; color: var(--mm-text); }
.mm-dash-tabella .mm-dash-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mm-dash-totale { font-size: 1.05rem; }
.mm-dash-totale strong { margin-left: .35rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mm-dash-comandi { display: flex; flex-wrap: wrap; gap: .5rem; }
.mm-dash-comandi .btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

/* Affiancati solo quando titolo e selettori stanno su una riga; sotto, ogni riquadro occupa tutta la larghezza. */
@media (min-width: 1280px) {
    .mm-dash-riepilogo { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, auto); row-gap: 0; }
    .mm-dash-riepilogo .mm-dash-riquadro, .mm-dash-riquadro .mm-dash-corpo { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; }
}

/* Sotto i 768px ogni riga del prospetto diventa una scheda con etichetta e valore affiancati. */
@media (max-width: 767.98px) {
    .mm-dash-tabella thead { display: none; }
    .mm-dash-tabella, .mm-dash-tabella tbody, .mm-dash-tabella tr { display: block; width: 100%; }
    .mm-dash-tabella tr { border: 1px solid var(--mm-border); border-radius: var(--mm-radius); margin-bottom: .75rem; padding: .25rem .75rem; }
    .mm-dash-tabella td, .mm-dash-tabella td.mm-dash-num { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; }
    .mm-dash-tabella td::before { content: attr(data-etichetta); font-weight: 600; text-align: left; color: var(--mm-text-muted); flex: 0 0 42%; }
    #mmProspetto .modal-footer { flex-direction: column; align-items: stretch; }
    .mm-dash-comandi .btn { flex: 1 1 8rem; }
}
@media (max-width: 575.98px) {
    .mm-dash-filtri { width: 100%; }
    .mm-dash-filtri .form-select { flex: 1 1 0; width: 100%; }
    .mm-dash-valori { grid-template-columns: 1fr; }
    .mm-dash-valore, .mm-dash-valore + .mm-dash-valore { padding: .9rem 0 .6rem; }
    .mm-dash-valore + .mm-dash-valore { border-left: 0; border-top: 1px solid var(--mm-border); }
}
