/* ==========================================================================
   1. NUOVI STILI: PAGE SWITCHER (NAVIGAZIONE ALTA) E AREA ATTIVA
   ========================================================================== */

/* Container per distanziare la label superiore */
.section-nav-container {
    padding-bottom: 10px;
}

/* Tabs superiori che simulano la navigazione tra Sfoglia e Ricerca */
.page-switcher-tabs {
    border-bottom: none !important;
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 0 !important; /* Si attacca al pannello beige sottostante */
}

.page-switcher-tabs .nav-item {
    margin-bottom: -1px; /* Permette alla tab attiva di fondersi con il bordo */
}

.page-switcher-tabs .nav-link {
    font-family: 'Roboto', sans-serif;
    border: 1px solid #ccc !important;
    border-bottom: none !important;
    background-color: #d8cfc4 !important; /* Colore oro/beige scuro per inattiva */
    color: #666 !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    padding: 10px 35px;
    border-radius: 4px 4px 0 0;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* TAB ATTIVA: Usa il colore #efe9e4 e si unisce visivamente al pannello */
.page-switcher-tabs .nav-link.active {
    background-color: var(--base-beige-chiaro) !important; /* #efe9e4 */
    color: var(--coloreTitolo) !important;
    border-color: #ccc !important;
    border-bottom: 1px solid var(--base-beige-chiaro) !important;
    cursor: default;
    z-index: 10;
}

/* AREA DI CONTENUTO: Tutta l'area sotto le tab superiori assume il colore beige */
.tab-content-area {
    background-color: var(--base-beige-chiaro); /* #efe9e4 */
    border: 1px solid #ccc;
    padding: 20px;
    border-radius: 4px;
    min-height: 100%;
}

/* ==========================================================================
   2. STILI ORIGINALI PRESERVATI - LABEL E TITOLI
   ========================================================================== */

.v-label-refined {
    text-transform: uppercase;
    font-size: 1rem;
    font-weight: bold;
    color: var(--coloreTitolo);
    letter-spacing: 2px;
    margin: 0 auto 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    max-width: 900px;
}

.v-label-refined i {
    font-size: 1.2rem;
}

.v-label-refined::before,
.v-label-refined::after {
    content: "";
    flex-grow: 1;
    height: 1px;
    background: var(--coloreTitolo);
    opacity: 0.25;
}

/* --- TASTO RICERCA AVANZATA (Soluzione 1) --- */
.btn-ricerca-avanzata {
    background: var(--base-scuro);
    color: #ffffff !important;
    border: none;
    padding: 6px 16px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    border-radius: 4px;
    text-decoration: none;
    z-index: 10;
    height: 2.2rem;
}

.btn-ricerca-avanzata:hover {
    background: var(--coloreTitolo);
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* =========================================================
   3. RESPONSIVE E LAYOUT
   ========================================================= */

body.layout-locked {
    height: auto !important;
    overflow-y: auto !important;
}

body.layout-locked .page,
body.layout-locked .contenuto-interno {
    height: auto !important;
    overflow: visible !important;
}

body.layout-locked .resizer-container.layout-one-way {
    height: auto !important;
    overflow: visible !important;
}

.contenuto-interno {
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    height: 100%; 
}

.resizer-container {
    display: flex;
    flex-direction: row; 
    height: 100%; 
    width: 100%;
    flex-grow: 1; 
    overflow: hidden; 
}

.resizer-panel {
    overflow-y: auto; 
    padding: 20px;
    height: 100%;
}

#left-panel {
    flex-shrink: 0; 
}

#right-panel {
    flex-grow: 1; 
    display: flex;
    flex-direction: column; 
}

.content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.resizer-handle {
    width: 8px; 
    min-width: 8px;
    cursor: ew-resize; 
    background-color: var(--coloreSfondoMenu);
    z-index: 10;
    flex-shrink: 0; 
}

.resizer-container.resizer-disabled-layout #left-panel {
    width: 40% !important; 
}

.resizer-container.resizer-disabled-layout #right-panel {
    width: 60% !important; 
}

.resizer-container.resizer-disabled-layout .resizer-handle {
    display: none; 
    cursor: default !important; 
}

/* ==========================================================================
   4. HEADER E TOOLBAR (Card bianche su fondo beige)
   ========================================================================== */

.header-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff !important; /* Forza il bianco su fondo beige */
    padding: 15px 20px;
    border-radius: 6px;
    border: 1px solid var(--bordoChiaroTrasparente);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    max-width: 900px;
    margin: 0 auto 25px;
}

.header-compact .segnatura-box {
    flex-shrink: 0;
    padding-right: 20px;
    border-right: 2px solid var(--coloreTitolo); 
    margin-right: 20px;
    text-align: center;
}

.header-compact .label-seg, 
.header-compact .label-intestazione {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--coloreTestoPrimario);
    margin-bottom: 2px;
    letter-spacing: 1px;
    font-weight: bold;
}

.header-compact .valore-seg {
    font-family: 'Roboto', sans-serif;
    font-size: 1.9rem;
    font-weight: bold;
    color: var(--coloreTitolo);
    line-height: 1;
    white-space: nowrap; 
}

.header-compact .dettagli-box {
    flex-grow: 0;
    text-align: center; 
}

.header-compact .valore-fondo {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--coloreTitolo);
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.header-compact .valore-titolo {
    font-family: 'Roboto', sans-serif;                     
    font-size: 1.4rem; 
    color: var(--coloreSfondoScuro);
    line-height: 1.2;
    margin: 0; 
    font-weight: normal;
}

.toolbar-btn {
    border: 1px solid var(--coloreTitolo);
    color: var(--coloreTitolo);
    background: white;
    padding: 8px 16px;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--coloreTitolo);
    color: white;
}

.btn-group .toolbar-btn:first-child { 
    border-radius: 4px 0 0 4px; 
}
.btn-group .toolbar-btn:last-child { 
    border-radius: 0 4px 4px 0; 
}

.toolbar-input-group {
    border-bottom: 2px solid var(--coloreTitolo);
}

.toolbar-input {
    border: none;
    background: transparent;
    font-weight: 500;
    background-color: var(--sfondoInput); 
    color: var(--coloreSfondoScuro);
    padding-left: 10px;
}

.toolbar-input:focus {
    outline: none;
    box-shadow: none;
    background: white;
}

.btn-go {
    color: var(--coloreSfondoScuro);
    font-weight: bold;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: transparent;
    border: none;
}

.btn-go:hover {
    color: var(--coloreTitolo);
}

.btn-lista-custom {
    border: 1px solid var(--coloreTitolo);
    color: var(--coloreTitolo);
    background: white;
    padding: 8px 16px;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.btn-lista-custom:hover {
    background: var(--coloreTitolo);
    color: white !important;
}

.btn-lista-custom .transition-icon {
    transition: transform 0.3s ease;
}

.btn-lista-custom:not(.collapsed) .transition-icon {
    transform: rotate(90deg);
}

.segnatura-highlight {
    font-family: 'Roboto', sans-serif;                     
    color: var(--coloreSfondoScuro);        
    margin-left: 8px;                       
    letter-spacing: 0.5px;                  
}

.toolbar-search {
    width: 220px;
}

.lista-segnature-container {
    background-color: var(--base-bianco-vetro);
    border: 1px solid var(--coloreTitolo);
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}

/* ==========================================================================
   5. TABS E CONTENUTI DETTAGLI
   ========================================================================== */

.nav-tabs {
    border-bottom: none !important; /* Rimosso per integrazione area beige */
    gap: 5px; 
}

.nav-tabs .tab-link-custom {
    font-family: 'Roboto', sans-serif;                     
    color: var(--coloreTestoPrimario);
    background-color: var(--sfondoTabNonAttiva);
    border: none !important;
    border-radius: 4px 4px 0 0; 
    padding: 12px 25px;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    margin-bottom: -1px; 
}

.nav-tabs .tab-link-custom:hover {
   text-decoration: underline;
   text-decoration-color: var(---coloreTiles);
   text-decoration-thickness: 2px;
   text-underline-offset: 4px;
}

.nav-tabs .tab-link-custom.active {
    color: var(--coloreTitolo);
    font-weight: bold;
    background-color: #ffffff !important; /* Forza bianco per contrasto */
    cursor: default;
    pointer-events: none;
    border: 1px solid #ccc !important;
    border-bottom-color: #ffffff !important; 
    z-index: 2; 
}

/* --- LOGICA ACCORDION INTERNI (Richiesta dall'utente) --- */
.accordion-button:not(.collapsed) {
    background-color: var(--base-bianco) !important; 
    color: var(--coloreTitolo) !important;           
    box-shadow: none !important;                     
}

.accordion-button:focus {
    z-index: 3;
    outline: 0;
    box-shadow: none;
}

#msTabsContent {
    background-color: #ffffff; /* Pannello dati sempre bianco */
    border: 1px solid #ccc !important; 
    padding: 25px;
    border-radius: 0 0 4px 4px; 
}

.th-section-header {
    font-weight: bold;
    font-size: 1rem; 
    text-transform: uppercase;
    text-align: center;
    padding: 0.5rem !important; 
}

.tr-section { font-size: 1rem; }
.th-desc-value { font-size: 1rem; }
.th-desc-label { width: 1%; white-space: nowrap; vertical-align: top; }
.th-uc-id { width: 1%; white-space: nowrap; text-align: center; }
.th-uc-carte { width: 15%; }
.cursor-help { cursor: help; }
.text-secondary-custom { color: var(--coloreTestoSecondario) !important; }
.text-muted { --bs-secondary-color: var(--coloreTestoSecondario); }
.table-bordered thead tr{ border-top: 0 !important; }
.table-head-clean thead th { border-width: 0; }
.text-carte { color: var(--coloreCarte); font-weight: bold; white-space: nowrap; }
.table>:not(caption)>*>* { --bs-table-color-state: var(--coloreSfondoScuro); }

/* RIMOZIONE STRIPED: Tutte le righe bianche */
.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-striped-bg: transparent !important;
    background-color: #ffffff !important;
    --bs-table-striped-color: var(--coloreSfondoScuro);
}

/* ==========================================================================
   6. BADGE E COMPONENTI METADATI (TUTTE LE DEFINIZIONI)
   ========================================================================== */

.badge-circle {
    width: 30px;        
    height: 30px;       
    border-radius: 50%; 
    padding: 0;         
    display: inline-flex; 
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;  
    font-family: 'Roboto', sans-serif !important; 
    font-weight: bold;
    flex-shrink: 0; 
    background-color: transparent !important; 
    border: 1px solid var(--coloreTestoPrimario); 
    color: var(--coloreTestoPrimario) !important; 
}

.nav-tabs .tab-link-custom.active .badge-circle {
    border-color: var(--coloreTitolo);
    color: var(--coloreTitolo) !important;
}

.badge-tipo-default { background-color: var(--coloreSfondoScuro) !important; color: #fff !important; }
.badge-tipo-l { background-color: var(--coloreTitolo) !important; color: #fff !important; }
.badge-tipo-m { background-color: var(--coloreCarte) !important; color: #fff !important; }

.badge-luogo-citato, .badge-luogo-destinazione, .badge-luogo-provenienza {
    padding: 2px 12px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; border-radius: 12px; display: inline-block; line-height: 1.5; color: var(--coloreTestoPrimario); 
}
.badge-luogo-citato { background-color: var(--base-bianco-vetro); border: none; }
.badge-luogo-destinazione { background-color: var(--coloreSfondoScuro); color: var(--coloreTestoMenu); border: none; }
.badge-luogo-provenienza { background-color: var(--sfondoTabNonAttiva); border: none; }

.badge-nome-autore, .badge-nome-citato, .badge-nome-compilatore, .badge-nome-destinatario, .badge-nome-mittente, .badge-nome-raccoglitore {
    padding: 2px 12px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; border-radius: 12px; display: inline-block; line-height: 1.5; color: var(--coloreTestoPrimario); 
}
.badge-nome-autore { background-color: var(--base-oro-vetro); border: none; }
.badge-nome-citato{ background-color: var(--base-bianco-vetro); border: none; }
.badge-nome-compilatore { background-color: var(--base-ruggine-scuro); color: var(--coloreTestoMenu); border: none; }
.badge-nome-destinatario { background-color: var(--coloreSfondoScuro); color: var(--coloreTestoMenu); border: none; }
.badge-nome-mittente { background-color: var(--sfondoTabNonAttiva); border: none; }
.badge-nome-raccoglitore { background-color: var(--coloreTestoSecondario); color: var(--coloreTestoMenu); border: none; }

.badge-titolo-uniforme, .badge-titolo-attestato, .badge-titolo-elaborato {
    padding: 2px 12px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; border-radius: 12px; display: inline-block; line-height: 1.5; color: var(--coloreTestoPrimario); 
}
.badge-titolo-uniforme { background-color: var(--base-oro-vetro); border: none; }
.badge-titolo-attestato { background-color: var(--base-bianco-vetro); border: none; }
.badge-titolo-elaborato { background-color: var(--base-ruggine-scuro); color: var(--coloreTestoMenu); border: none; }

.badge-conservativo {
    padding: 2px 12px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; border-radius: 12px; display: inline-block; line-height: 1.5; color: var(--coloreTestoPrimario) !important; 
}
.badge-restaurato { background-color: var(--base-oro-vetro); border: none; }
.badge-non-restaurato { background-color: var(--base-bianco-vetro); border: none; }

/* =========================================================
   7. MIRADOR E COMPONENTI AVANZATI
   ========================================================= */

#viewer-container {
    position: relative !important; flex-grow: 1; width: 100% !important; height: 100% !important; 
    min-height: 400px; overflow: hidden;
}
#viewer-container .mirador-viewer { background: transparent; }
#viewer-container .mirador-viewer .mosaic-tile { box-shadow: none; }
#viewer-container .mirador-viewer .mosaic-window-body{ background: transparent; }
#viewer-container .mirador-viewer .mosaic-window-body .MuiPaper-root{ background: transparent; }
#viewer-container .mirador-viewer .mosaic-preview { display: none; }
#viewer-container header { display: none !important; }

#paginazione-mirador { max-width: 650px; width: 100% }
#paginazione-count { min-width: 120px; }
#paginazione-mirador .nav-label { font-size: 0.85rem; color: var(--coloreTestoSecondario); line-height: 1.2; }

#btn-open-mirador {
    padding: 4px 8px !important; border: 1px solid var(--coloreButtonMirador) !important;
    background-color: #ffffff !important; border-radius: 5px; transition: all 0.3s ease;
}
.mirador-logo-icon {
    width: 22px; height: 22px; background-color: var(--coloreButtonMirador);
    -webkit-mask-image: url('../../images/mirador-logo.png');
    mask-image: url('../../images/mirador-logo.png');
    -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center;
    flex-shrink: 0; margin-bottom: 2px; transition: background-color 0.2s ease;
}
.mirador-logo-text {
    font-family: 'Yanone Kaffeesatz', sans-serif; font-weight: 400; font-size: 1.1rem;
    color: var(--coloreButtonMirador); text-transform: lowercase; letter-spacing: 0.05em; transition: color 0.2s ease;
}
#btn-open-mirador:hover { background-color: var(--coloreButtonMirador) !important; box-shadow: 0 2px 5px rgba(0,0,0,0.2); text-decoration: none; cursor: pointer; }
#btn-open-mirador:hover .mirador-logo-icon { background-color: #ffffff; }
#btn-open-mirador:hover .mirador-logo-text { color: #ffffff; }

#paginazione-mirador .btn-nav-outline, .btn-nav-filled {
    width: 40px; height: 40px; border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; padding: 0;
}
#paginazione-mirador .btn-nav-outline { border: 1px solid var(--coloreTitolo); color: var(--coloreTitolo); }
.btn-nav-filled { border: 1px solid var(--coloreTitolo); color: var(--coloreTitolo); background: #fff; padding: 8px 16px; font-size: 1.1rem; transition: all 0.2s; }
.btn-nav-filled:hover:not(:disabled) { background: var(--coloreTitolo); color: white; }
.btn-nav-outline:disabled, .btn-nav-filled:disabled { opacity: 0.5; cursor: default; pointer-events: none; }

#viewer-container div[class*="mirador-canvas-nav"] { visibility: hidden !important; height: 0 !important; width: 0 !important; overflow: hidden !important; padding: 0 !important; margin: 0 !important; position: absolute; }

/* =========================================================
   8. MEDIA QUERIES E GESTIONE MOBILE
   ========================================================= */

#left-panel.layout-compatto .col:has(.toolbar-input-group) { display: none !important; }
#left-panel.layout-compatto .col-auto { width: 100%; }
#left-panel.layout-compatto .btn-lista-custom { width: 100%; justify-content: space-between; border: 1px solid var(--coloreTitolo); color: var(--coloreTitolo); background: white; }
#left-panel.layout-compatto .btn-lista-custom:hover { background-color: var(--coloreTitolo); color: white !important; cursor: pointer; }
#left-panel.layout-compatto .header-compact .segnatura-box { display: none !important; }

.separator-custom { border-color: var(--coloreTitolo); opacity: 0.3; }

.resizer-container.layout-one-way { flex-direction: column !important; overflow-y: auto !important; height: auto !important; }
.resizer-container.layout-one-way #left-panel, .resizer-container.layout-one-way #right-panel { width: 100% !important; height: auto !important; flex: none !important; overflow: visible; }
.resizer-container.layout-one-way #right-panel { min-height: 500px; border-top: 2px solid var(--coloreTitolo); }
.resizer-container.layout-one-way .resizer-handle { display: none !important; }

/* STILE TABELLE PER MOBILE */
.resizer-container.layout-one-way table, .resizer-container.layout-one-way tbody, .resizer-container.layout-one-way tr, .resizer-container.layout-one-way th, .resizer-container.layout-one-way td { display: block; width: 100%; }
.resizer-container.layout-one-way thead { display: none; }
.resizer-container.layout-one-way tr { margin-bottom: 15px; border: 1px solid var(--bordoChiaroTrasparente); border-radius: 4px; background-color: rgba(255, 255, 255, 0.5); padding: 10px; }
.resizer-container.layout-one-way th { color: var(--coloreTitolo); font-size: 0.85rem; text-transform: uppercase; border: none !important; padding: 0 0 5px 0; font-weight: bold; }
.resizer-container.layout-one-way td { border: none !important; padding: 0; font-size: 1rem; color: var(--coloreTestoPrimario); white-space: normal; word-break: break-word; }
.resizer-container.layout-one-way .resizer-panel { padding: 10px !important; }

.d-flex.flex-wrap.gap-2 { gap: 0.5rem !important; }
.antiche-seg-item { padding: 2px 10px; border-radius: 4px; font-size: 1rem; color: var(--coloreTestoPrimario); white-space: nowrap; display: flex; align-items: center; }
.antiche-seg-item i { color: var(--coloreSfondoMenu); }

.btn-restore-layout-custom {
    background-color: var(--coloreSfondoMenu) !important; color: var(--base-beige-chiaro) !important;
    border: none !important; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    box-shadow: 0 4px 12px var(--base-oro-vetro); transition: all 0.3s ease;
}
.btn-restore-layout-custom:hover { filter: brightness(1.1); transform: translateY(-2px); color: var(--base-bianco) !important; box-shadow: 0 6px 15px var(--base-oro-vetro); }
.btn-restore-layout-custom i { color: inherit; }