/* ==========================================================================
   GIGA GESTIONALE - UNIFIED CORE STYLESHEET (giga.css)
   ========================================================================== */

/* --- 1. STRUTTURA LAYOUT & COMPONENTI STICKY --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.giga-sticky-actions {
    top: 1.5rem;
}

.giga-sidebar-sticky {
    top: 1rem;
}

.giga-sidebar-sticky-combined {
    top: 1.5rem;
}

.spalla-riepilogo-sticky {
    top: 24px;
}

/* --- 2. CONTROLLI DELLE FORM & TIPOGRAFIA --- */
form label {
    font-size: 0.8rem;
    color: #666;
}

form input,
form select {
    font-size: 0.9rem;
}

.form-control:focus {
    border-color: #ffc107;
    box-shadow: 0 0 0 0.25rem rgba(255, 193, 7, 0.25);
}

.custom-switch-warning:checked {
    background-color: #ffc107;
    border-color: #ffc107;
}

/* --- 3. STRUTTURA CORE DELLE TABELLE AUTOMATICHE (SENZA CLASSI IN PYTHON) --- */

/* Target universale per tutte le tabelle che iniziano con l'ID autogenerato */
table[id^="lista-"] {
    width: 100%;
    margin-bottom: 0;
    color: #212529;
    vertical-align: middle;
    border-collapse: collapse;
}

/* Spaziature e allineamenti delle celle */
table[id^="lista-"] th,
table[id^="lista-"] td {
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
}

/* Intestazioni delle tabelle (thead th): applicato direttamente sulle celle per sovrascrivere Bootstrap 5 */
table[id^="lista-"] thead tr,
table[id^="lista-"] thead th {
    background-color: #d1e7dd !important;
    /* Colore table-success di Bootstrap 5 */
    color: #0f5132 !important;
    /* Testo scuro coordinato */
}

table[id^="lista-"] thead th {
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Reset dei link per i titoli ordinabili (orderable) della thead */
table[id^="lista-"] thead th a {
    color: #0f5132 !important;
    text-decoration: none;
    display: block;
    width: 100%;
}

/* Gestione delle utility di posizionamento celle */
table[id^="lista-"] td.text-center,
table[id^="lista-"] th.text-center {
    text-align: center !important;
}

table[id^="lista-"] td.text-end,
table[id^="lista-"] th.text-end {
    text-align: right !important;
}

table[id^="lista-"] td .d-inline-flex {
    gap: 0.25rem;
}

/* Effetto Hover pulito sulle righe del corpo tabella */
table[id^="lista-"] tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.035) !important;
}

/* Gestione Ancore e Link testuali dentro il corpo (Es: link sul Numero o Cliente) */
table[id^="lista-"] tbody td a {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 600;
}

table[id^="lista-"] tbody td a:hover {
    text-decoration: underline;
}

/* Centra il messaggio vuoto standard di django-tables2 */
table[id^="lista-"] td[colspan] {
    text-align: center;
    vertical-align: middle !important;
    font-style: italic;
    color: #6c757d;
    padding: 1.5rem 0;
}

/* Reset generali per ancore speciali */
a.no-link-style,
a.no-link-style:visited,
a.no-link-style:hover,
a.no-link-style:active,
a.no-link-style:focus {
    color: inherit;
    text-decoration: none;
}

/* --- 4. COLONNE SPECIALIZZATE TABELLE (EMAIL, LOCALITÀ, STRUTTURE) --- */
table[id^="lista-"] td.email-stretch-cell {
    width: 15%;
    min-width: 180px;
    vertical-align: middle;
}

table[id^="lista-"] td.email-stretch-cell .text-nowrap {
    white-space: normal !important;
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
}

table[id^="lista-"] td.localita-cell {
    min-width: 150px;
    white-space: normal;
}

.giga-table-status-badge {
    display: inline-block;
    width: 90px;
    text-align: center;
}

.giga-table-agenzie,
.giga-table-compagnie {
    font-size: 0.9rem;
}

.giga-cell-email-container {
    min-width: 0;
}

/* --- 5. INTEGRAZIONE UTILITY SELECT2 & ADD-ANOTHER --- */

/* 1. Forza il container Select2 a occupare tutto lo spazio disponibile */
.select2-container {
    width: 100% !important;
    display: block;
}

/* 2. Select2 Standard (Allineato a form-control di Bootstrap 5) */
.select2-container--default .select2-selection--single {
    height: calc(1.5em + .75rem + 2px);
    padding: 0.375rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #fff;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 1.5;
    padding-left: 0;
    color: #212529;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
    top: 0;
    right: 0.75rem;
    display: flex;
    align-items: center;
}

/* 3. Campi Master / Large (Allineato a form-control-lg / form-select-lg) */
.master-field+.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--single.form-control-lg {
    height: calc(1.5em + 1rem + 2px);
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    border-radius: 0.5rem;
}

/* 4. Supporto nativo per django-addanother (Pulsante + affiancato) */
.related-widget-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
}

.related-widget-wrapper .select2-container {
    flex: 1 1 auto;
    /* Occupa tutto lo spazio tranne il bottone + */
    width: 1% !important;
    /* Previene l'overflow nei flexbox */
}

.related-widget-wrapper a.related-widget-wrapper-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
}

/* Campi Master Anagrafica Polizze (Altezza speciale 52px) */
.master-field+.select2-container .select2-selection,
#id_cliente+.select2-container .select2-selection,
#id_compagnia+.select2-container .select2-selection,
#id_agenzia+.select2-container .select2-selection,
#id_produttore+.select2-container .select2-selection,
#id_beneficiario+.select2-container .select2-selection {
    height: 52px !important;
    display: flex !important;
    align-items: center !important;
    border-radius: 8px !important;
}

/* --- 6. SEZIONI, CARD & EFFETTI VISIVI --- */
.giga-login-card {
    max-width: 420px;
    width: 100%;
}

.card-nota-custom {
    background-color: #fffdf0;
    border-left: 3px solid #ffc107 !important;
}

.hover-shadow {
    transition: all 0.3s ease;
}

.hover-shadow:hover {
    transform: translateY(-5px);
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15) !important;
}

.toast-container-giga {
    z-index: 1090;
}

/* --- 7. FUNZIONI FILTRI CONTROLLI --- */
.giga-filter-radio-container {
    min-height: 38px;
}

.giga-filter-radio-item {
    white-space: nowrap;
}

.giga-range-input-group input {
    display: block;
    width: 100%;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    appearance: none;
    border-radius: 0.25rem;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.btn-check:checked+.custom-segment-btn {
    background-color: #4c7356 !important;
    border-color: #4c7356 !important;
    color: #fff !important;
}

/* --- 8. TIPOGRAFIA & LISTE INFO --- */
.giga-master-descrizione {
    font-size: 1.25rem;
    font-weight: 500;
}

.giga-subtab-header-title {
    letter-spacing: 1px;
}

.giga-cronologia-subtext {
    font-size: 0.75rem;
}

.giga-dashboard-cliente-truncate {
    max-width: 140px;
}

.testo-descrizione-fattura,
.nota-polizza-pre {
    white-space: pre-line;
}

.nota-polizza-pre {
    line-height: 1.2;
}

.allegato-nome-max {
    max-width: 70%;
}

.info-list dt,
.info-list dd {
    padding: 0.25rem 0;
    margin: 0;
    border-bottom: 1px solid #e9ecef;
}

.info-list dt {
    font-weight: 600;
    color: #495057;
}

.info-list dd {
    color: #212529;
}

/* --- 9. MICRO METADATI, ETICHETTE E BADGES --- */
.giga-meta-desc-label {
    font-size: 0.75rem !important;
}

.giga-meta-label {
    font-size: 0.7rem !important;
}

.giga-economica-label {
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.giga-btn-add-micro,
.giga-btn-add-doc {
    font-size: 0.7rem;
}

.ms-5-custom {
    margin-left: 2.5rem;
}

.giga-badge-appendice-header {
    font-size: 0.9rem;
}

.giga-badge-dare-container {
    font-size: 0.75rem;
}

.giga-badge-profile-status,
.giga-badge-profile-sidebar,
.giga-badge-profile-mini,
.giga-meta-label-mini,
.giga-badge-dare-label {
    font-size: 0.65rem !important;
}

/* --- 10. GRIGLIA CERTIFICAZIONI ISO --- */
.cert-grid-wrapper {
    width: 135px;
    margin: 0 auto;
}

.cert-badge-real {
    height: 22px;
    margin: 1px;
    font-size: 0.55rem;
    line-height: 1;
    overflow: hidden;
}

.cert-badge-placeholder {
    height: 22px;
    margin: 1px;
    border-style: dashed !important;
}

.small-micro-text {
    font-size: 0.5rem;
}

.row-cols-3>.col:nth-child(n+7) {
    display: none !important;
}

/* --- 11. OVERRIDE SICUREZZA BADGES BOOTSTRAP LATO GESTIONALE --- */
.bg-danger {
    background-color: #dc3545 !important;
    color: #fff !important;
}

.bg-success {
    background-color: #198754 !important;
    color: #fff !important;
}

.bg-warning {
    background-color: #ffc107 !important;
    color: #212529 !important;
}

.bg-danger strong,
.bg-success strong {
    color: #fff !important;
}

.bg-warning strong {
    color: #212529 !important;
}
