
/* ==========================================================================
   1. STILI BASE E STRUTTURA LAYOUT (BODY, WRAPPER, SIDEBAR)
   ========================================================================== */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin-bottom: 60px;
    min-height: 100vh;
    overflow-x: hidden;
    background-color: #f4f7f6;
}

#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

/* Sidebar */
#sidebar-wrapper {
    min-height: 100vh;
    width: 15rem;
    margin-left: 0;
    transition: margin .25s ease-out;
    background: #ffffff;
    border-right: 1px solid #dee2e6;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    z-index: 1000;
}

#wrapper.toggled #sidebar-wrapper {
    margin-left: -15rem;
}

#page-content-wrapper {
    width: 100%;
    flex-grow: 1;
}

.main-content-container {
    padding: 1.5rem !important;
}

/* Navbar */
.navbar {
    height: 50px;
    padding: 0.5rem 1rem !important;
    background-color: transparent;
    border-bottom: none !important;
}

/* ==========================================================================
   2. COMPONENTI UI (MENU, BOTTONI, INPUT)
   ========================================================================== */

/* Menu Sidebar */
.sidebar-heading {
    padding: 0.875rem 1.25rem;
    font-size: 1.2rem;
}

.list-group-item {
    background: transparent;
    border: none;
}

.list-group-item-action:hover {
    background-color: #0d6efd !important;
    color: #ffffff !important;
}

.list-group-item.active {
    background-color: #0d6efd !important;
    color: white !important;
    border-left: 4px solid #084298;
}

.bi-chevron-down {
    transition: transform 0.3s ease;
}

a[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Focus e Stati Input */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Utility Header e Login */
.scale-85 {
    transform: scale(0.85);
    transform-origin: right;
}

#logoutForm {
    display: inline;
}

/* Rende il gruppo bottoni azioni perfettamente squadrato */
.btn-group-dynamic > .btn {
    border-radius: 0 !important;
}
    /* Toglie il doppio bordo tra i bottoni quadrati */
    .btn-group-dynamic > .btn + .btn {
        margin-left: -1px !important;
    }

/* Uniforma l'altezza delle righe in tutte le tabelle del gestionale */
/*.table td, .table th {
    vertical-align: middle;*/ /* Centra il contenuto verticalmente */
    /*padding-top: 8px !important;
    padding-bottom: 8px !important;
    line-height: 1.5;*/ /* Altezza del testo costante */
/*}*/

/* Forza l'altezza del gruppo bottoni per non far "spanciare" la riga */
/*.btn-group-dynamic {
    height: 25px;*/ /* Regola questo valore in base alla tua preferenza */
    /*display: flex;
    align-items: center;
}*/

/* ==========================================================================
   3. TABELLE GESTIONALI (#infoTable e classi .table-sm)
   ========================================================================== */

/* Riduzione spessore e font dati */
.table-sm td, .table-sm th, #infoTable td, #infoTable th {
    padding-top: 2px !important; /* Ridotto da 4px a 2px per massima compattezza */
    padding-bottom: 2px !important; /* Ridotto da 4px a 2px */
    vertical-align: middle;
    font-size: 0.85rem; /* Leggermente ridotto per leggibilità gestionale */
}

/* Header tabelle */
.table thead th, #infoTable thead th p {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 0;
}

/* Interattività righe */
#infoTable tbody tr {
    transition: background-color 0.1s ease;
    cursor: pointer;
}

    #infoTable tbody tr:hover {
        background-color: rgba(13, 110, 253, 0.08) !important;
        color: #084298;
    }

    .table tbody tr.highlight td, #infoTable tbody tr.highlight {
        background-color: #0d6efd !important;
        color: white !important;
    }

/* --- REGOLA UNIVERSALE PER TUTTE LE TABELLE DELL'APP --- */

.table-action-btn.btn {
    padding: 0 !important;
    line-height: 1 !important;
    border: none !important;
    background: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Dimensioni Rettangolo Smussato */
    width: 32px !important;
    height: 26px !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    vertical-align: middle;
}

    /* Effetto Hover Comune: Sollevamento */
    .table-action-btn.btn:hover {
        transform: translateY(-2px) !important;
        background: none !important;
    }

    /* --- LOGICA COLORI UNIFICATA --- */

    /* 1. VISUALIZZA / INFO (Azzurro) */
    .table-action-btn.btn .bi-eye-fill,
    .table-action-btn.btn .bi-info-circle {
        color: #0dcaf0 !important;
    }

    .table-action-btn.btn:hover .bi-eye-fill,
    .table-action-btn.btn:hover .bi-info-circle {
        background-color: rgba(13, 202, 240, 0.2) !important;
        border-radius: 4px;
    }

    /* 2. MODIFICA (Giallo/Arancio) */
    .table-action-btn.btn .bi-pencil-square {
        color: #ffc107 !important;
    }

    .table-action-btn.btn:hover .bi-pencil-square {
        background-color: rgba(255, 193, 7, 0.2) !important;
        border-radius: 4px;
    }

    /* 3. CANCELLA (Rosso) */
    .table-action-btn.btn .bi-trash,
    .table-action-btn.btn .bi-trash-fill,
    .table-action-btn.btn .bi-trash3-fill {
        color: #dc3545 !important;
    }

    .table-action-btn.btn:hover .bi-trash,
    .table-action-btn.btn:hover .bi-trash-fill,
    .table-action-btn.btn:hover .bi-trash3-fill {
        background-color: rgba(220, 53, 69, 0.2) !important;
        border-radius: 4px;
    }

    /* 4. SELEZIONA / OK (Blu) */
    .table-action-btn.btn .bi-check2-square {
        color: #0d6efd !important;
    }

    .table-action-btn.btn:hover .bi-check2-square {
        background-color: rgba(13, 110, 253, 0.2) !important;
        border-radius: 4px;
    }

    /* --- COLORI BASE ICONE (senza hover) --- */
    /* (Invariati) */
    .table-action-btn.btn .bi-eye-fill {
        color: #0dcaf0 !important;
    }

    .table-action-btn.btn .bi-pencil-square {
        color: #ffc107 !important;
    }

    .table-action-btn.btn .bi-trash3-fill,
    .table-action-btn.btn .bi-trash-fill {
        color: #dc3545 !important;
    }

    .table-action-btn.btn .bi-check2-square {
        color: #0d6efd !important;
    }

/* ==========================================================================
   GESTIONE RIGA SELEZIONATA UNIVERSALE (.highlight)
   ========================================================================== */

/* 1. Forza tutte le icone a essere bianche su qualsiasi tabella con riga highlight */
.table tbody tr.highlight i,
.table tbody tr.highlight .btn i {
    color: #ffffff !important;
}

/* 2. Visibilità bottoni su riga blu (valido per infoTable, infoTableRuoli, ecc.) */
.table tbody tr.highlight .btn-outline-primary,
.table tbody tr.highlight .table-action-btn.btn {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

    /* 3. Effetto hover sui bottoni della riga selezionata */
    .table tbody tr.highlight .btn-outline-primary:hover,
    .table tbody tr.highlight .table-action-btn.btn:hover {
        background-color: rgba(255, 255, 255, 0.3) !important;
        border-color: #ffffff !important;
        transform: translateY(-2px);
    }

/* 4. Drop-shadow icona selezione al passaggio mouse */
.table tbody tr:hover .bi-check2-square {
    filter: drop-shadow(0 0 2px rgba(13, 110, 253, 0.5));
}

/* TOAST Container dei Toast */
.toast-container {
    z-index: 2000 !important; /* Forza la priorità su modali e sidebar */
    padding: 1.5rem; /* Spaziatura uniforme dal bordo */
}

/* Stile base del Toast */
.toast {
    background-color: rgba(25, 135, 84, 0.9) !important; /* Verde leggermente trasparente */
    backdrop-filter: blur(4px); /* Effetto vetro sfocato */
    box-shadow: 0 8px 16px rgba(0,0,0,0.2) !important;
}

    .toast.bg-danger {
        background-color: rgba(220, 53, 69, 0.9) !important;
    }

    .toast.bg-warning {
        background-color: rgba(255, 193, 7, 0.9) !important;
        color: #000 !important;
    }

/* Allineamento icone nel corpo del toast */
.toast-body i {
    font-size: 1.25rem;
    flex-shrink: 0; /* Impedisce all'icona di rimpicciolirsi se il testo è lungo */
}
/* ==========================================================================
   4. TEXTAREA E FORM SPECIFICI
   ========================================================================== */
.h-textarea-micro {
    height: 60px !important;
    min-height: 60px !important;
    font-size: 0.85rem;
}

.h-textarea-small {
    height: 150px !important;
}

.h-textarea-medium {
    height: 300px !important;
}

.h-textarea-large {
    height: 400px !important;
}

.textarea-autosize, .textarea-autosize-custom, .textarea-details {
    min-height: 24px !important;
    height: auto !important;
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    resize: none;
    overflow: hidden;
}

.textarea-autosize-custom, .textarea-details {
    font-weight: bold;
}

.textarea-details {
    color: #212529;
}

.no-resize {
    resize: none;
}

#Dati_Operazione, #Relazione_Perizia {
    height: 400px;
}

#Nota_Condizioni, #Note_Sinistro {
    height: 200px;
}

#Testo_Richiesta_IA {
    height: 150px;
}

#Testo_Risposta_IA {
    height: 300px;
}

.card-body label {
    color: #495057;
    font-size: 0.75rem;
}

/* ==========================================================================
   5. GESTIONE DOCUMENTI (PDF, IA, PREVIEW) E LOADING
   ========================================================================== */
#loading {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100099;
    width: 100%;
    height: 100%;
    opacity: 0.7;
    background-color: #fff;
    text-align: center;
    display: none;
}

#loadingimage {
    z-index: 100100;
    position: absolute;
    top: 20%;
    left: 47%;
}

.document-preview-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: #f8f9fa;
}

.heightLittle {
    height: 150px;
}

.heightMedium {
    height: 400px;
}

.heightBig {
    height: 600px !important;
}

.height-ia-card {
    height: 250px !important;
}

.pdf-container-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

.pdf-iframe-style {
    border: none;
    width: 100%;
    height: 100%;
    display: block;
}

.image-placeholder-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.img-preview-style {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #f8f9fa;
}

.placeholder-logo-style {
    max-height: 80px;
    opacity: 0.3;
}

/* Fix per interattività Iframe PDF nelle Modali e far sì che l'iframe sfrutti i 600px della heightBig*/
/* Assicura che l'iframe riempia il contenitore senza scrollbar doppie */
/* Forza il viewer a occupare tutto lo spazio disponibile nell'iframe */
.modal-pdf-viewer {
    width: 100% !important;
    height: 100% !important;
    display: block;
    position: relative;
    pointer-events: auto !important;
    z-index: 9999 !important;
    border: none;
}

/* Stati Loader e Visibilità */
.loader-doc-overlay-custom, .loader-overlay, .custom-table-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.custom-table-loader {
    backdrop-filter: blur(2px);
    z-index: 1000;
}

.loader-hidden, .pdf-container-layer.d-none {
    display: none !important;
}

/* Bottoni eliminazione slot */
.delete-button-wrapper {
    position: absolute;
    top: -12px;
    right: -10px;
    z-index: 20;
}

.btn-elimina-slot {
    background-color: #fff !important;
    color: #dc3545 !important;
    border: 2px solid #dc3545 !important;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    transition: all 0.2s ease-in-out;
}

    .btn-elimina-slot:hover {
        transform: scale(1.15);
        background-color: #dc3545 !important;
        color: #fff !important;
    }

/* Debug Label */
.guid-debug-label {
    font-size: 10px;
    word-break: break-all;
    color: #6c757d;
    font-family: monospace;
    display: block;
    margin-top: 4px;
}