/* =================================================================== */
/* LAYOUT.CSS - Stili Strutturali e di Posizionamento                  */
/* =================================================================== */
/* Questo file definisce "lo scheletro" dell'applicazione.             */
/* Contiene gli stili per sidebar e topnav (sempre scuri e fissi).     */
/* Il contenuto principale e il dropdown delle notifiche sono tematici.*/
/* =================================================================== */

:root {
    /* Definizioni di base per transizioni e bordi */
    --bs-border-width: 1px;
    --bs-border-style: solid;
    --bs-border-radius: .375rem;
    --main-transition: margin-left 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    /* Colori di base applicati dai temi */
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: background-color 0.2s linear, color 0.2s linear;
}

/* --- Sidebar (Sempre Scura, non tematica) --- */
.sidebar {
    min-width: 250px;
    max-width: 250px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: margin-left 0.3s ease;
    z-index: 1001;
    background-color: #2c3e50; /* Fisso */
    color: #ecf0f1; /* Fisso */
}

.sidebar a {
    border-left: 5px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-weight: 400;
    padding: .625rem 1.625rem;
    position: relative;
    text-decoration: none;
    transition: background .1s ease-in-out, border-color .1s ease-in-out;
    color: rgba(233, 236, 239, .7); /* Fisso */
}

.sidebar a:hover {
    background-color: #34495e; /* Fisso */
}

.sidebar a.active {
    background-color: #34495e; /* Fisso */
    border-left-color: #3498db; /* Fisso */
    color: #ffffff; /* Fisso */
}

.sidebar a i, .sidebar a svg {
    margin-right: 15px;
    min-width: 18px;
    height: 18px;
    text-align: center;
    flex-shrink: 0;
    color: #7f8c8d; /* Fisso */
}

.sidebar a.active i, .sidebar a.active svg {
    color: #ffffff; /* Fisso */
}

.sidebar a span {
    flex-grow: 1;
}

.sidebar .nav-title {
    padding: 10px 15px;
    color: #95a5a6; /* Fisso */
    text-transform: uppercase;
    font-size: 0.9em;
    font-weight: bold;
}

.sidebar .nav-title-divider {
    background-color: #34495e; /* Fisso */
    height: 1px;
    margin: 10px 15px;
}

.sidebar .bottom-links {
    margin-top: auto;
}

.sidebar .logout-link {
    background-color: #3b4b5b; /* Fisso */
}
.sidebar .logout-link:hover {
    background-color: #2f3f4f; /* Fisso */
}

/* --- Logo (Sempre Chiaro, non tematico) --- */
.app-name {
    padding: 0;
    margin: 0;
    background-color: #e4e4e4; /* Fisso */
}
.app-name a {
    display: block;
    line-height: 0;
}
.app-name a:hover {
    background-color: #e4e4e4; /* Fisso */
}
.app-logo-img {
    width: 100%;
    height: auto;
    display: block;
}

/* --- Topnav (Sempre Scura) --- */
.topnav {
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    height: 50px;
    left: 250px;
    right: 0;
    z-index: 1000;
    transition: left 0.3s ease;
    background-color: #34495e; /* Fisso */
    color: #ecf0f1; /* Fisso */
}

.topnav #btn-toggle-sidebar {
    color: #ecf0f1; /* Fisso */
    border-color: #ecf0f1; /* Fisso */
    background-color: transparent;
    border-width: 1px;
    border-style: solid;
    padding: .25rem .5rem;
    border-radius: .25rem;
}

.topnav #btn-toggle-sidebar:hover {
    background-color: rgba(255,255,255,0.1); /* Fisso */
}

.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    color: #ecf0f1; /* Fisso */
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* --- Main Content --- */
#page-wrapper {
    width: 100%;
}

#main-content {
    padding: 20px;
    min-height: calc(100vh - 50px);
    margin-top: 50px;
    margin-left: 250px;
    transition: var(--main-transition);
}

/* --- Stati per Sidebar Chiusa --- */
.sidebar.sidebar-closed {
    margin-left: -250px;
}

#main-content.content-closed {
    margin-left: 0;
}

.topnav.topnav-closed {
    left: 0;
}

/* --- Footer --- */
.footer {
    font-size: .9em;
    height: 60px;
    padding: 20px 15px;
    /* Colori gestiti dal tema */
    background-color: var(--bs-tertiary-bg);
    border-top: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
}

/* --- Elementi Strutturali Generici --- */
.not-set {
    font-style: italic;
    color: var(--bs-secondary-color);
}

.grid-view th,
.grid-view td:last-child {
    white-space: nowrap;
}

.grid-view .filters input,
.grid-view .filters select {
    min-width: 50px;
}

.hint-block {
    display: block;
    margin-top: 5px;
    font-size: 0.9em;
    color: var(--bs-secondary-color);
}

.error-summary {
    padding: 10px 20px;
    margin: 0 0 15px 0;
    border-left: 3px solid; /* Colore gestito dal tema */
    border-radius: var(--bs-border-radius);
    /* Colori gestiti dal tema */
    background-color: var(--bs-danger-bg-subtle);
    border-left-color: var(--bs-danger-border-subtle);
    color: var(--bs-danger-text-emphasis);
}

.breadcrumb[id^=w]{
    background-color: transparent;
    padding-left: 0;
    margin-bottom: 1rem;
}

[id^="estimatecode"].popover-x {
    display:none;
}

/* Icone di Ordinamento Gridview (usa colore del testo del tema) */
a.asc:after, a.desc:after {
    content: '';
    left: 3px;
    display: inline-block;
    width: 0;
    height: 0;
    border: solid 5px transparent;
    margin: 4px 4px 2px 4px;
    background: transparent;
}
a.asc:after {
    border-bottom-color: currentColor;
    border-top-width: 0;
}
a.desc:after {
    border-top-color: currentColor;
    border-bottom-width: 0;
}

/* --- Loading Button --- */
.loading-button {
    position: relative;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    overflow: hidden;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s;
    /* Colori gestiti dal tema */
    background-color: var(--bs-primary);
    color: var(--bs-light);
}
.loading-button:disabled {
    cursor: not-allowed;
    background-color: var(--bs-secondary);
}
.loading-button.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid; /* Colore gestito dal tema */
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    /* Colori gestiti dal tema */
    border-color: var(--bs-spinner-border-color);
    border-top-color: transparent;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Notifiche (Dropdown tematico, Topnav fissa) --- */
.topnav-right .nav-item.dropdown {
    position: relative;
}
#notification-bell {
    position: relative;
    color: #ecf0f1; /* Fisso, per l'icona nella topnav scura */
    font-size: 1.1rem;
}
.topnav-right .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    z-index: 1000;
    margin-top: 10px; /* Spazio dalla topnav */
    display: none;
    border-radius: var(--bs-border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15); /* Stile professionale */
    /* Colori gestiti dal tema tramite variabili */
    background-color: var(--bs-dropdown-bg);
    border: var(--bs-border-width) var(--bs-border-style) var(--bs-dropdown-border-color);
    color: var(--bs-dropdown-color);
}
.topnav-right .dropdown.show .dropdown-menu {
    display: block;
}
#notification-count {
    position: absolute;
    top: -2px;
    right: -5px;
    font-size: 0.65rem;
    padding: .2em .45em;
    line-height: 1;
    border-radius: 50%;
    background-color: var(--bs-danger); /* THEME: Usata variabile per il colore danger */
    color: white; /* Fisso bianco per contrasto */
    border: 1px solid #34495e; /* Bordo colore topnav fissa */
}
.dropdown-menu-lg {
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}
.notification-item {
    display: flex;
    align-items: flex-start;
    padding: .75rem 1rem;
    text-decoration: none;
    white-space: normal;
    /* Colori gestiti dal tema */
    color: var(--bs-dropdown-color);
}
.notification-item:hover {
    /* Colore gestito dal tema */
    background-color: var(--bs-dropdown-hover-bg);
}
.notification-item p.text-sm {
    margin-bottom: 0;
    font-size: 0.85rem;
}
.dropdown-item-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}
.dropdown-item-title .delete-notification-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    transition: color 0.2s;
    /* Colore gestito dal tema */
    color: var(--bs-secondary-color);
}
.dropdown-item-title .delete-notification-btn:hover {
    /* Colore gestito dal tema */
    color: var(--bs-dropdown-color);
}
.dropdown-menu .dropdown-divider {
    height: 1px;
    margin: .5rem 0;
    overflow: hidden;
    background-color: var(--bs-dropdown-divider-color);
}
.dropdown-menu .dropdown-footer,
.dropdown-menu .dropdown-header {
    padding: .5rem 1rem;
    font-weight: bold;
    /* Il background è ereditato da .dropdown-menu per un look uniforme.
       Il bordo inferiore è stato rimosso per integrare l'header con la lista. */
    color: var(--bs-dropdown-color);
}
/* Stile specifico per il pulsante nell'header delle notifiche */
.dropdown-header .btn {
    font-size: 0.75rem; /* Rende il testo del pulsante più piccolo */
}


/* --- Base per Card e Tabelle (Con Colori da Tema) --- */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-clip: border-box;
    border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    margin-bottom: 1.5rem;
    /* Colori gestiti dal tema */
    background-color: var(--bs-card-bg);
}
.card-header {
    padding: .75rem 1.25rem;
    margin-bottom: 0;
    border-bottom: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
    /* Colori gestiti dal tema */
    background-color: var(--bs-card-header-bg);
}

.card-body {
    flex: 1 1 auto;
    padding: 1.25rem;
}
.card-footer {
    padding: .75rem 1.25rem;
    border-top: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
    /* Colori gestiti dal tema */
    background-color: var(--bs-card-footer-bg);
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    vertical-align: top;
    /* Colori gestiti dal tema */
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}
.table > :not(caption) > * > * {
    padding: .75rem .75rem;
    background-color: var(--bs-table-bg);
    border-bottom-width: var(--bs-border-width);
}
.table > thead {
    vertical-align: bottom;
}
.table > thead > tr > th {
    /* Colori gestiti dal tema */
    color: var(--bs-table-header-color);
    background-color: var(--bs-table-header-bg);
}

/* Stile per le date evidenziate nel DatePicker della modale SAL */
.datepicker table tr td.highlighted {
    background-color: var(--bs-success-bg-subtle); /* THEME: Usata variabile per sfondo success */
    color: var(--bs-success-text-emphasis); /* THEME: Usata variabile per testo success */
    border-radius: 50%;
    font-weight: bold;
}