/* CRM Antes: stile comune a tutte le pagine (13/10/2026 sera, richieste di Alessio dopo la prova sulla copia).
   Registrato nel layout con 'depends' => AppAsset, cosi' finisce DOPO site.css, site-index.css, sidenav.css e
   Bootstrap (i CSS dei bundle vengono accodati alla fine): le regole qui vincono a parita' di specificita'. */

/* ---- Pagina: larghezza e margini ------------------------------------------------------------------
   Prima site-index.css metteva il contenitore a "fit-content" senza margini: le pagine toccavano il bordo
   sinistro e le tabelle larghe (PDA) uscivano dallo schermo. Ora: larghezza piena con margini, e le
   tabelle larghe scorrono di lato DENTRO il loro riquadro. */
html body main > .container {
    width: 100%;
    max-width: none !important;   /* 14/10: era 1540px, ma a 1920 px l'elenco contratti tagliava la colonna Agente (Alessio) */
    padding: 18px 24px 30px !important;
    margin: 0 auto 30px !important;
}
html body #container-create, html body #container-update, html body #container-view {
    max-width: 1100px !important;
}
/* la home resta nel flusso della pagina (prima position:absolute, causa delle pagine tagliate) ma tiene la filigrana
   dell'ariete (sfondo_antes.jpg) che Alessio vuole: sotto il contenuto, centrata, leggera (13/10 sera). */
.site-index { position: relative !important; z-index: 0; min-height: 0 !important; margin: 0 !important; }
.site-index::before {
    display: block !important; content: ""; position: fixed !important; z-index: -1; pointer-events: none; opacity: .22 !important;
    top: auto !important; left: auto !important; right: 28px !important; bottom: 28px !important; width: 320px !important; height: 320px !important;
    background: url('/img/ariete-filigrana.png') no-repeat center / contain;   /* ariete con sfondo trasparente (da sfondo_antes.jpg) */
}
body.vista-telefono .site-index::before { width: 180px !important; height: 180px !important; right: 14px !important; bottom: 86px !important; opacity: .16 !important; }
/* ariete anche nella barra in alto, accanto al pulsante del menu (non c'era piu' un logo visibile sulle altre pagine) */
#w3-navbar .crm-logo { display: inline-flex; align-items: center; gap: 8px; color: #fff; font-weight: 600; font-size: 16px; text-decoration: none; padding: 0 6px 0 2px; white-space: nowrap; }
#w3-navbar .crm-logo img { width: 30px; height: 30px; border-radius: 7px; }
#w3-navbar .crm-logo:hover { color: #fff; opacity: .9; }
#w3-navbar #sidebar-button { display: flex; align-items: center; }
@media (max-width: 575px) { #w3-navbar .crm-logo span { display: none; } }
/* le tabelle kartik scorrono nel loro contenitore (non nella card, altrimenti il menu Esporta resta tagliato: Codex) */
.grid-view:not(:has(.kv-grid-container)) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.kv-grid-container { overflow-x: auto; }

/* ---- Tabelle e pannelli delle liste (kartik) -------------------------------------------------------
   Intestazioni blu accese e cornice grigia -> riquadro bianco con bordo leggero, come il resto del CRM. */
.table th, .table td { vertical-align: middle; }
.grid-view table thead th, .kv-grid-table thead th {
    font-size: 12.5px !important;
    font-weight: 600;
    color: #495057;
    background: #f6f8fa !important;
}
.grid-view .card.border-primary {
    border: 1px solid #e3e6ea !important;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(31, 41, 55, .06);
}
.grid-view .card-header.bg-primary { border-radius: 10px 10px 0 0; }
.grid-view .card-header.bg-primary {
    background: #fff !important;
    border-bottom: 1px solid #e3e6ea;
    padding: 12px 18px;
}
.grid-view .card-header.bg-primary, .grid-view .card-header.bg-primary * { color: #343a40 !important; }
.grid-view .card-header .card-title, .grid-view .card-header .panel-title, .grid-view .card-header h3 {
    font-size: 16px; font-weight: 600; margin: 0;
}
.grid-view .card-footer { background: #fff; border-top: 1px solid #e3e6ea; }
.grid-view .kv-panel-before { border-bottom: 1px solid #eef0f2 !important; padding: 10px 18px !important; }
.btn { border-radius: 8px; }
.grid-view th a, .kv-grid-table th a { color: #343a40; }   /* intestazioni ordinabili: non sembrano link blu */
/* elenco PDA su PC: testo un po' piu' grande e gestore/codice fiscale su una riga (prima 11px, "ENI PLENITU/DE") */
.pda-index .grid-view table { font-size: 12.5px !important; }
.pda-index .grid-view td:nth-child(5), .pda-index .grid-view td:nth-child(8) { white-space: nowrap !important; }

/* elenchi su PC (13/10 sera, segnalazione di Alessio su Operatori): carattere 13.5px invece di 16 (10 colonne non ci stavano),
   e la colonna delle icone (modifica / elimina / vedi) su UNA riga: a 40px di larghezza le 4 icone andavano a capo e
   ogni riga diventava alta 122px. */
.grid-view table, .kv-grid-table { font-size: 13.5px; }
.grid-view table td:last-child, .kv-grid-table td:last-child { white-space: nowrap; }
.grid-view table td:last-child > a, .kv-grid-table td:last-child > a { display: inline-block; padding: 4px 5px; font-size: 15px; color: #495057; }
.grid-view table td:last-child > a:hover, .kv-grid-table td:last-child > a:hover { color: #007bff; }
.grid-view table td:last-child > a + a { margin-left: 2px; }
/* 14/10/2026 (Alessio): risoluzione di riferimento 1920 px (i PC del data entry sono 1920x1080 al 100%).
   Sotto, carattere e spazi delle tabelle scalano cosi' che si vedano le stesse colonne; sopra non cambia niente. */
@media (max-width: 1700px) {
    .grid-view table, .kv-grid-table { font-size: 12.5px; }
    .grid-view table td, .grid-view table th, .kv-grid-table td, .kv-grid-table th { padding: 6px 7px !important; }
    .grid-view table thead th, .kv-grid-table thead th { font-size: 11.5px !important; }
    html body main > .container { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 1450px) {
    .grid-view table, .kv-grid-table { font-size: 11.5px; }
    .grid-view table td, .grid-view table th, .kv-grid-table td, .kv-grid-table th { padding: 5px 5px !important; }
    .grid-view table thead th, .kv-grid-table thead th { font-size: 11px !important; }
    .grid-view .form-control, .kv-grid-table .form-control { font-size: 11.5px; height: 30px; padding: 2px 5px; }
    html body main > .container { padding-left: 10px; padding-right: 10px; }
}
/* righe che aprono il dettaglio al click (data-href, vedi crm.js) */
.grid-view tr.riga-apri { cursor: pointer; }
.grid-view tr.riga-apri:hover > td { background: #eef5ff !important; }
/* PDA: la colonna File non va a capo ("2 0"); l'icona "vedi" con la firma sotto resta compatta */
.pda-index .grid-view td:nth-last-child(2) { white-space: nowrap !important; }
.pda-index .grid-view td:last-child > a { padding: 2px 4px; }

/* ---- Report ---------------------------------------------------------------------------------------- */
.contratti-form > .grid-view { background: transparent !important; padding: 0 !important; margin-bottom: 22px !important; }
.contratti-form h2 { font-size: 22px; margin: 18px 0 10px; }
.report-filter-card { border: 1px solid #e3e6ea !important; border-radius: 10px !important; box-shadow: 0 2px 8px rgba(31, 41, 55, .06) !important; }
.card.report-filter-card > .card-header { padding: 12px 18px; background: #fff; border-bottom: 1px solid #e3e6ea; }
.report-filter-card .card-header h4 { font-size: 16px; }
.report-periodo-scelte { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.report-periodo-scelta {
    border: 1px solid #ced4da; background: #fff; color: #343a40; border-radius: 999px;
    padding: 8px 16px; font-weight: 500; cursor: pointer; line-height: 1.2;
}
.report-periodo-scelta:hover { border-color: #343a40; }
.report-periodo-scelta.attiva { background: #343a40; color: #fff; border-color: #343a40; }
.report-periodo-scelta i, .report-periodo-scelta svg { margin-right: 6px; }
.report-periodo-pannello { display: none; }
.report-periodo-pannello.attivo { display: block; }
.report-periodo-campi { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-start; }
.report-periodo-campi .form-group { margin-bottom: 0; min-width: 210px; }
.report-periodo-campi label { color: #495057; font-weight: 600; margin-bottom: 4px; }
.report-periodo-aiuto { color: #6c757d; font-size: 13px; margin: 8px 0 0; }
.report-filter-actions { margin-top: 16px; }
.report-filter-actions .btn-success { border-radius: 999px; padding: 9px 22px; font-weight: 600; }
.report-filter-actions .btn-outline-secondary { border-radius: 999px; border-color: #ced4da !important; }
.report-contatori .cruscotto { margin-bottom: 18px; }

/* kartik sotto i 480 px impila ogni cella su una riga (kv-table-wrap): illeggibile. Tabella normale che scorre di lato. */
@media screen and (max-width: 480px) {
    .kv-table-wrap td, .kv-table-wrap th { display: table-cell !important; width: auto !important; font-size: inherit !important; }
    .kv-table-wrap tr > td:first-child { border-top: 0 !important; margin-top: 0 !important; font-size: inherit !important; }
}

/* ---- Menu laterale: sopra il contenuto sugli schermi stretti (non lo spinge piu' di lato) ----------- */
#mySidebar { z-index: 1040; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
@media (max-width: 991px) {
    html body #main { margin-left: 0 !important; }
    /* 14/10/2026 (Alessio dal telefono): sotto i 992 px AdminLTE spinge il menu fuori schermo (margin-left:-250px) e il
       pannello aperto restava vuoto; e la barra in alto nascondeva Home / Versione telefono / Logout senza un pulsante */
    #mySidebar .main-sidebar { margin-left: 0 !important; transform: none !important; width: 100% !important; box-shadow: none !important; }
    #navbar .navbar-collapse { display: flex !important; flex-basis: auto; }
    #navbar .navbar-nav { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; }
    #navbar .navbar-nav .nav-link, #navbar .navbar-nav .btn-link { padding: 6px 8px; font-size: 14px; white-space: nowrap; }
    html body #sidebar-button { margin-left: 0 !important; }
    html body #mySidebar { width: 280px !important; max-width: 85vw; }
    html body #w3-navbar { position: relative; z-index: 1041; }   /* il pulsante del menu resta sopra il pannello */
}

/* ---- Versione per il telefono (body.vista-telefono: /site/telefono la accende, /site/pc la spegne) ---- */
body.vista-telefono #w3-navbar, body.vista-telefono #mySidebar { display: none !important; }
body.vista-telefono main > .container,
body.vista-telefono #container-create, body.vista-telefono #container-update, body.vista-telefono #container-view {
    max-width: 640px !important;
    padding: 66px 12px 90px !important;
    margin: 0 auto !important;
}
body.vista-telefono h1 { font-size: 22px; margin-bottom: 12px; overflow-wrap: anywhere; }
body.vista-telefono .box { padding: 14px; }
body.vista-telefono .form-control, body.vista-telefono select.form-control { font-size: 16px; min-height: 44px; }
body.vista-telefono .btn { min-height: 42px; }
body.vista-telefono .cruscotto-riquadri { grid-template-columns: 1fr 1fr; gap: 10px; }   /* 14/10: sei riquadri, tre righe da due */
body.vista-telefono .cruscotto-num { font-size: 30px; }
body.vista-telefono .cruscotto-scorciatoie { grid-template-columns: 1fr 1fr; }
body.vista-telefono .cruscotto-scorciatoia.primaria { grid-column: 1 / -1; }
body.vista-telefono .doc-gestori { grid-template-columns: 1fr 1fr; gap: 10px; }
body.vista-telefono .pda-index form { flex-wrap: wrap; }
body.vista-telefono .pda-index form input.form-control { width: 100% !important; flex: 1 1 160px; }
body.vista-telefono .pda-index .btn-danger { display: none; }
body.vista-telefono .pda-solo-telefono { display: inline-block; }
body.tel-menu-aperto { overflow: hidden; }

.tel-testata {
    position: fixed; top: 0; left: 0; right: 0; height: 54px; z-index: 1030;
    display: flex; align-items: center; gap: 8px; padding: 0 8px 0 4px;
    background: #343a40; color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.tel-testata button { background: none; border: 0; color: #fff; font-size: 22px; width: 44px; height: 44px; padding: 0; }
.tel-testata .tel-logo { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: #fff; font-weight: 600; font-size: 17px; text-decoration: none; }
.tel-testata .tel-logo img { width: 30px; height: 30px; border-radius: 7px; }
.tel-testata .tel-pc { margin-left: auto; display: flex; align-items: center; gap: 5px; color: #fff; font-size: 13px; text-decoration: none; border: 1px solid rgba(255,255,255,.45); border-radius: 8px; padding: 5px 9px; white-space: nowrap; }
.tel-testata .tel-pc:hover { background: rgba(255,255,255,.12); color: #fff; }
.tel-testata .tel-utente { margin-left: 10px; font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42%; }

.tel-barra {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030;
    display: flex; height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid #e3e6ea;
}
.tel-barra a, .tel-barra button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: #6c757d; font-size: 11px; font-weight: 500; text-decoration: none; background: none; border: 0; padding: 0;
}
.tel-barra i, .tel-barra svg { font-size: 20px; height: 22px; }
.tel-barra .attivo { color: #343a40; font-weight: 600; }
.tel-barra .tel-nuova { color: #319e5b; }
.tel-barra .tel-nuova i, .tel-barra .tel-nuova svg { font-size: 26px; height: 26px; }

.tel-menu { position: fixed; inset: 0; z-index: 1050; background: rgba(31, 41, 55, .55); display: none; }
.tel-menu.aperto { display: block; }
.tel-menu-pannello {
    position: absolute; top: 0; left: 0; bottom: 0; width: 300px; max-width: 86vw;
    background: #fff; overflow-y: auto; padding: 8px 0 24px; box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
}
.tel-menu-testa {
    display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 6px 18px;
    font-weight: 600; font-size: 16px; color: #343a40; border-bottom: 1px solid #eef0f2; margin-bottom: 6px;
}
.tel-menu-testa button { background: none; border: 0; font-size: 22px; color: #6c757d; width: 44px; height: 44px; }
.tel-menu-gruppo { padding: 14px 18px 4px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #8a94a0; font-weight: 600; }
.tel-menu-voce {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 18px;
    color: #343a40; font-size: 16px; text-decoration: none; background: none; border: 0; text-align: left;
}
.tel-menu-voce:hover, .tel-menu-voce:focus { color: #343a40; text-decoration: none; background: #f6f8fa; }
.tel-menu-voce.attiva { background: #f1f3f5; font-weight: 600; }
.tel-menu-voce i, .tel-menu-voce svg { flex: 0 0 22px; width: 22px; text-align: center; color: #3b82c4; font-size: 17px; }
/* 14/10/2026: su iPhone le voci risultavano con il testo a destra e le icone sparse: testo in un contenitore esplicito */
.tel-menu-voce .tel-menu-testo { flex: 1 1 auto; text-align: left; justify-self: start; margin: 0; }
.tel-menu-voce { justify-content: flex-start !important; direction: ltr; }
.tel-menu form { margin: 0; }

/* PDA a schede (telefono) */
.pda-schede { display: flex; flex-direction: column; gap: 10px; }
.pda-scheda {
    display: block; padding: 12px 14px; background: #fff; border: 1px solid #e3e6ea; border-radius: 10px;
    box-shadow: 0 2px 8px rgba(31, 41, 55, .06); color: #343a40;
}
.pda-scheda:hover, .pda-scheda:focus { color: #343a40; text-decoration: none; box-shadow: 0 6px 16px rgba(31, 41, 55, .12); }
.pda-scheda-testa { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.pda-scheda-nome { font-weight: 600; font-size: 16px; line-height: 1.25; }
.pda-scheda-stato { flex: none; color: #fff; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.pda-scheda-riga { color: #6c757d; font-size: 13.5px; margin-top: 2px; }
.pda-scheda-riga i, .pda-scheda-riga svg { width: 16px; text-align: center; margin-right: 2px; }
.pda-scheda-nota { margin-top: 6px; padding: 8px 10px; background: #f6f8fa; border-radius: 8px; font-size: 13.5px; }
.pda-scheda-piede { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; color: #8a94a0; font-size: 12.5px; }
.pda-scheda-piede .pda-scheda-apri { margin-left: auto; color: #3b82c4; font-weight: 600; }
.pda-scheda-vuota { padding: 24px; text-align: center; color: #6c757d; background: #fff; border-radius: 10px; }
.pda-pagine { margin: 16px 0 0; justify-content: center; }

/* ---- Modulo PDA: per ogni foto/allegato il tipo (tendina) e un nome facoltativo (14/10/2026, Alessio) ------- */
.pda-allegato-riga { border: 1px solid #e3e6ea; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: #fafbfc; }
.pda-allegato-testa { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pda-allegato-nome { word-break: break-word; font-size: 13px; color: #495057; }
.pda-allegato-campi { display: flex; gap: 8px; margin-top: 6px; }
.pda-allegato-campi .form-control { min-height: 40px; }
@media (max-width: 480px) { .pda-allegato-campi { flex-direction: column; } }

/* 15/10/2026: stile unico delle tabelle dell'area amministrativa (Alessio) */
.crm-tabella { font-size: 13.5px; }
.crm-tabella thead th { background: #f1f3f5; color: #343a40; font-weight: 600; white-space: nowrap; position: sticky; top: 0; z-index: 1; border-bottom: 2px solid #dee2e6; }
.crm-tabella td, .crm-tabella th { vertical-align: middle; padding: .35rem .5rem; }
.crm-tabella .filters td { background: #fafbfc; }
.crm-tabella .filters input, .crm-tabella .filters select { font-size: 12.5px; padding: .15rem .3rem; height: auto; }
.crm-tabella tr.riga-disattivata td { color: #868e96; }
.crm-tabella tr.riga-disattivata td:first-child a { color: #868e96; text-decoration: line-through; }
.crm-tabella td.text-right, .crm-tabella th.text-right { text-align: right; }
.crm-tabella .btn-sm { padding: .15rem .45rem; font-size: 12.5px; }
.card-header h1 { font-size: 1.5rem; }

/* 15/10/2026: Documentazione in una pagina sola */
.doc-filtri { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.doc-filtri .doc-filtro { border: 1px solid #ced4da; background: #fff; color: #495057; border-radius: 999px; padding: .25rem .8rem; }
.doc-filtri .doc-filtro.attivo { background: #343a40; border-color: #343a40; color: #fff; }
.doc-filtri-sep { width: 1px; height: 22px; background: #dee2e6; margin: 0 6px; }
.doc-schede { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.doc-scheda { background: #fff; border: 1px solid #e3e6ea; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; transition: box-shadow .15s, transform .15s; }
.doc-scheda:hover { box-shadow: 0 6px 16px rgba(31,41,55,.12); transform: translateY(-2px); }
.doc-scheda-testa { display: flex; align-items: center; gap: 10px; color: #343a40; text-decoration: none; }
.doc-scheda-testa:hover { color: #1f6feb; text-decoration: none; }
.doc-scheda-logo { width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; flex: 0 0 54px; }
.doc-scheda-logo img { max-width: 54px; max-height: 54px; object-fit: contain; }
.doc-scheda-iniziali { width: 48px; height: 48px; border-radius: 12px; color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; letter-spacing: .5px; }
.doc-scheda-nome { font-weight: 600; font-size: 15px; line-height: 1.2; flex: 1; }
.doc-scheda-tag { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.doc-scheda-tag .badge { font-weight: 500; }
.doc-scheda-azioni { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-scheda-azioni .btn { border-radius: 999px; padding: .15rem .6rem; font-size: 12.5px; }
.doc-scheda-rif { font-size: 12.5px; color: #6c757d; border-top: 1px dashed #e9ecef; padding-top: 6px; }
.doc-scheda-rif a { color: #495057; }
.doc-laterale .list-group-item a { color: #343a40; font-weight: 500; display: block; }
.doc-laterale .list-group-item a:hover { color: #1f6feb; text-decoration: none; }
body.vista-telefono .doc-schede { grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 575px) { .doc-schede { grid-template-columns: 1fr 1fr; gap: 10px; } .doc-scheda { padding: 10px; } .doc-scheda-testa { flex-direction: column; text-align: center; } .doc-scheda-tag { flex-direction: row; } }
.crm-tabella-stretta { width: auto; min-width: 70%; }
.crm-tabella-stretta td, .crm-tabella-stretta th { white-space: nowrap; }
.crm-tabella-stretta td:nth-child(1) { white-space: normal; min-width: 220px; }
