/* ============================================
   STRUTTURA — Light Theme
   ============================================ */

:root {
    --bg-base:     #d4d4d8;
    --bg-surface:  #e4e4e7;
    --bg-elevated: #d1d1d6;
    --border:      #b8b8be;
    --border-dark: #a1a1aa;
    --text:        #18181b;
    --text-muted:  #52525b;
    --accent:      #2563eb;
    --accent-h:    #1d4ed8;
    --danger:      #dc2626;
    --success:     #16a34a;
    --r:           6px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 13px;
    background: var(--bg-base);
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text);
    line-height: 1.5;
    margin: 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #909099; }

/* ── Buttons ─────────────────────────────────── */

button, .btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 11px;
    height: 28px;
    line-height: 1;
    border-radius: var(--r);
    border: 1px solid var(--border-dark);
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
    margin: 0;
    text-decoration: none;
}

button:hover, .btn:hover {
    background: #c8c8cd;
    border-color: #909099;
    color: var(--text);
}

/* Toolbar: tutti i bottoni uniformi neutri */
.action-toolbar .btn-primary,
.action-toolbar .btn-success,
.action-toolbar .btn-secondary,
.action-toolbar .btn-outline-secondary,
.action-toolbar .btn-danger,
.action-toolbar .btn-info,
.action-toolbar .btn-outline-primary {
    background: var(--bg-elevated);
    border-color: var(--border-dark);
    color: var(--text-muted);
}

.action-toolbar .btn-primary:hover,
.action-toolbar .btn-success:hover,
.action-toolbar .btn-secondary:hover,
.action-toolbar .btn-danger:hover,
.action-toolbar .btn-info:hover {
    background: #c8c8cd;
    border-color: #909099;
    color: var(--text);
}

/* Nella tabella: rispetta i colori semantici */
.table .btn-danger {
    background: transparent;
    border-color: rgba(220,38,38,0.4);
    color: var(--danger);
}
.table .btn-danger:hover {
    background: rgba(220,38,38,0.08);
    border-color: var(--danger);
    color: var(--danger);
}

.table .btn-primary {
    background: transparent;
    border-color: rgba(37,99,235,0.4);
    color: var(--accent);
}
.table .btn-primary:hover {
    background: rgba(37,99,235,0.08);
    border-color: var(--accent);
    color: var(--accent-h);
}

.table .btn-success {
    background: transparent;
    border-color: rgba(22,163,74,0.4);
    color: var(--success);
}
.table .btn-success:hover {
    background: rgba(22,163,74,0.08);
    border-color: var(--success);
}

.table .btn-info {
    background: transparent;
    border-color: rgba(37,99,235,0.3);
    color: var(--accent);
}
.table .btn-info:hover {
    background: rgba(37,99,235,0.08);
    border-color: var(--accent);
}

.btn-warning {
    background: #ffc107;
    border-color: #d39e00;
    color: #212529;
}
.btn-warning:hover {
    background: #e0a800;
    border-color: #c69500;
    color: #212529;
}

.btn-sm {
    font-size: 11px;
    padding: 3px 8px;
    height: 24px;
}

/* Eccezioni: dentro le modali i bottoni hanno significato semantico */
.modal-footer .btn-primary,
.modal .btn-primary:not(.dismiss) {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.modal-footer .btn-primary:hover,
.modal .btn-primary:not(.dismiss):hover {
    background: var(--accent-h);
    border-color: var(--accent-h);
    color: #fff;
}

.modal-footer .btn-danger,
.modal .btn-danger:not(.dismiss) {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.modal-footer .btn-danger:hover,
.modal .btn-danger:not(.dismiss):hover {
    background: rgba(220,38,38,0.06);
}

.modal-footer .btn-secondary,
.modal .btn-secondary {
    background: var(--bg-surface);
    border-color: var(--border-dark);
    color: var(--text-muted);
}

.modal .btn-outline-primary {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
}
.modal .btn-outline-primary:hover {
    background: rgba(37,99,235,0.06);
    color: var(--accent-h);
}

/* Close button Bootstrap */
.close {
    color: var(--text-muted);
    opacity: 1;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1;
    height: auto;
    width: auto;
}
.close:hover { color: var(--text); background: transparent; }

/* ── Action Toolbar ─────────────────────────── */

.action-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.action-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.action-separator {
    display: inline-block;
    width: 1px;
    height: 18px;
    background: var(--border-dark);
    margin: 0 4px;
    flex-shrink: 0;
}

/* ── Filter Row ─────────────────────────────── */

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 1rem;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.filter-row .form-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: default;
}

.filter-row select.form-control,
.filter-row select.form-select {
    width: auto !important;
    min-width: 90px;
    height: 24px !important;
    padding: 1px 6px !important;
    font-size: 11px !important;
}

/* ── Aggiornamenti Panel ────────────────────── */

.aggiornamenti {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    color: var(--text);
}

.aggiornamenti .row { margin: 0; }

.titoloAggiornamentiGrande {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    display: block;
    margin-bottom: 0.5rem;
}

.bottoniAggiornamenti {
    display: flex;
    gap: 4px;
    padding-bottom: 0.5rem;
}

.listaAggiornamentiSpaziata { padding-bottom: 5px; }
.spazioTitoloAggiornamenti { padding-bottom: 6px; }

.rigaSeparatore {
    border-bottom: 1px solid var(--border);
    margin: 3px 0;
}

/* ── Main Content ───────────────────────────── */

.container-fluid { padding: 0; }
.strutturaCore { padding: 0 1rem 1.5rem; }

/* ── Table ──────────────────────────────────── */

.table {
    font-size: 12px;
    color: var(--text);
    margin-top: 0 !important;
    background: var(--bg-surface);
}

/* Override table-dark: in light mode la tabella è chiara */
.table.table-dark {
    background: var(--bg-surface) !important;
    color: var(--text) !important;
}

.table.table-dark th,
.table.table-dark td {
    border-color: var(--border) !important;
    color: var(--text) !important;
}

.table.table-dark thead th {
    background: var(--bg-elevated) !important;
    color: var(--text-muted) !important;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-dark) !important;
    white-space: nowrap;
}

.table.table-dark.table-striped tbody tr:nth-child(odd) {
    background: var(--bg-elevated) !important;
}

.table.table-dark tbody tr:hover td {
    background: #c8c8cd !important;
}

.table.table-dark tbody td {
    padding: 7px 10px;
    vertical-align: middle;
}

thead { text-align: left; }
td    { text-align: left; }

/* Bootstrap Table UI */
.fixed-table-toolbar .search input {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-dark) !important;
    color: var(--text) !important;
    border-radius: var(--r) !important;
    font-size: 12px;
}

.fixed-table-pagination .page-item .page-link {
    background: var(--bg-surface) !important;
    border-color: var(--border) !important;
    color: var(--text-muted) !important;
    font-size: 12px;
}

.fixed-table-pagination .page-item.active .page-link {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}

.fixed-table-container { border: none !important; }
.fixed-table-body { border: 1px solid var(--border); border-top: none; }

.pagination-detail {
    color: var(--text-muted);
    font-size: 11px;
}

/* ── Modals ─────────────────────────────────── */

/* L'overlay custom (div dentro il modale) — deve stare SOTTO il dialog */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 0;
}

.modal-dialog {
    position: relative;
    z-index: 1;
    overflow-y: initial !important;
}

.modal-content {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-dark) !important;
    border-radius: 10px !important;
    color: var(--text) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.modal-header {
    padding: 1.5rem 2rem 1.25rem;
    border-bottom: 1px solid var(--border);
    align-items: center;
    background: var(--bg-surface) !important;
}

.modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.modal-body {
    padding: 2rem;
    background: var(--bg-surface) !important;
    color: var(--text) !important;
}

.modal-body .form-group,
.modal-body .mb-3 {
    margin-bottom: 1.25rem !important;
}

.modal-body .row {
    row-gap: 0.5rem;
}

.modal-body-grande {
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 2rem;
    background: var(--bg-surface) !important;
}

/* già definito sopra con z-index */


/* Form controls */
.form-control, .form-select {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-dark) !important;
    color: var(--text) !important;
    border-radius: var(--r) !important;
    font-size: 12px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12) !important;
    outline: none;
    color: var(--text) !important;
}

.form-control[type="checkbox"] {
    width: 16px;
    height: 16px;
    padding: 0;
    cursor: pointer;
}

.form-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 3px;
    display: block;
}

label { color: var(--text-muted); font-size: 12px; }

/* Nav tabs in modal */
.nav-tabs { border: none; gap: 2px; }

.nav-tabs .nav-link {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: var(--r);
    border: 1px solid transparent !important;
    color: var(--text-muted);
    background: transparent;
}

.nav-tabs .nav-link.active {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border-dark) !important;
}

.nav-tabs .nav-link:hover:not(.active) {
    background: var(--bg-elevated);
    color: var(--text);
}

/* ── Alert ──────────────────────────────────── */

.alert-dialog { display: flex; justify-content: flex-end; }

.alert-dialog-position {
    z-index: 1051;
    position: fixed;
    right: 1.5rem;
    top: 10px;
    pointer-events: none;
}

.alert {
    background: var(--bg-surface);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    color: var(--text);
    padding: 0.65rem 1rem;
    font-size: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    top: 3rem;
    pointer-events: auto;
}

.alert-danger {
    background: var(--danger);
    color: white;
}

/* ── Loading Screen ─────────────────────────── */

.loading-screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1080;
    background: rgba(200, 200, 205, 0.8);
}

.loading-screen h4 {
    color: var(--text);
    margin-top: 1rem;
    font-size: 13px;
    font-weight: 400;
}

/* ── Mail Section ───────────────────────────── */

.mail-template {
    margin-bottom: 0.875rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.mail-template button { width: auto; }
.send-mail-form button { width: auto; }

.form-mail-colums {
    display: grid;
    grid-template-columns: 4rem 1fr;
    gap: 0.4rem;
    align-items: center;
}

.form-flex-mail {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.form-mail {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-mail input { width: 28rem; max-width: 100%; }

.form-textarea { margin-top: 0.75rem; border: none; outline: none; }
.form-textarea textarea { padding: 0.75rem; }
.form-textarea textarea:focus { outline: 0; }

textarea { resize: none; width: 100%; }

.breakdown-section {
    border-bottom: 1px solid var(--border);
    margin: 0.75rem 0;
}

.container-list {
    overflow-y: scroll;
    max-height: 12rem;
    background: var(--bg-elevated);
    border-radius: var(--r);
    border: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) transparent;
}

.list-mails {
    list-style-type: none;
    margin: 0;
    padding: 0.5rem 0.875rem;
}

.list-mails li {
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.list-mails li:last-child { border-bottom: none; }

.list-mails li button {
    background: none;
    color: inherit;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    display: flex;
    height: auto;
}

.form-footer {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-top: 0.75rem;
}

.navbar-dettaglio-mail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.navbar-dettaglio-mail button { width: auto; }

.window-info-mail textarea {
    background: var(--bg-surface) !important;
    color: var(--text);
    padding: 0.75rem;
}

.orders-manage { padding: 0.75rem 0; }
.select-order select { width: 28rem; max-width: 100%; }
.list-free-vm { margin-top: 0.75rem; }
.list-free-vm select { width: 28rem; max-width: 100%; }
.dataSelezione { margin-bottom: 0.75rem; }
.centrato { display: flex; justify-content: center; align-items: center; }

/* ── Select2 ────────────────────────────────── */

.d-flex > .select2-container { flex: 1; min-width: 0; }

.select2-container--default .select2-selection--single {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-dark) !important;
    border-radius: var(--r) !important;
    height: 31px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text) !important;
    line-height: 29px;
    font-size: 12px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    top: 3px;
}

.select2-dropdown {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-dark) !important;
    border-radius: var(--r) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    background: var(--bg-elevated) !important;
    border-color: var(--border-dark) !important;
    color: var(--text) !important;
    border-radius: var(--r) !important;
}

.select2-container--default .select2-results__option {
    color: var(--text);
    font-size: 12px;
    padding: 5px 8px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--accent) !important;
    color: #fff;
}

/* ── Datepicker ─────────────────────────────── */

.datepicker.dropdown-menu {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-dark) !important;
    border-radius: var(--r) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.datepicker table tr td,
.datepicker table tr th {
    color: var(--text);
    border-radius: var(--r);
}

.datepicker table tr td.active,
.datepicker table tr td.active:hover {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}

/* ── Utilities ──────────────────────────────── */

.scrittaBianca { color: var(--text); }
.grosso { font-weight: 600; }
.dismiss { cursor: pointer; color: var(--text-muted); }
.dismiss:hover { color: var(--text); }

.bg-error   { background: rgba(220,38,38,0.08)  !important; color: var(--danger)  !important; }
.bg-success { background: rgba(22,163,74,0.08)  !important; color: var(--success) !important; }

.sezioneAggiungiProdottoVm { display: none; }
.dettaglioAggiornamentiHeader { display: none; }
.dettaglio-mail { display: none; }
#allegati-check { display: none; }

.container-btn-custom { display: flex; gap: 0.75rem; }

.long-words {
    line-height: 1.8rem;
    overflow-y: hidden;
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;
    max-width: 55rem;
}

.long-words-title {
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;
}

.custom-width-row { width: 8rem; }

.span-custom-allegati-row {
    display: inline-block;
    background: var(--accent);
    border-radius: var(--r);
    margin-right: 0.4rem;
    padding: 3px 8px;
    font-size: 11px;
    color: #fff;
}

#modalConteggi select,
#modalConteggi .form-control {
    width: 100%;
    max-width: 100%;
}
#modalConteggi .modal-dialog{
    max-width: 27%;
}
#modalConteggi .modal-content{
    width: auto;
}

#filtri-table.tabella-template {
    table-layout: fixed;
    width: 129%;
}

#filtri-table.tabella-template td {
    white-space: normal;
    word-break: break-word;
}

/* ── Tab Struttura: modale allargata + card ───── */
#modalModifyFilters .modal-dialog.modal-struttura-wide {
    max-width: 960px;
}

#filtri-struttura-toolbar { display: flex; }

.filtri-struttura-search-input {
    max-width: 260px;
}

.filtro-card {
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--bg-base);
    padding: 12px 14px;
    margin-bottom: 12px;
}

.filtro-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.filtro-card-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    word-break: break-word;
}

.filtro-card-actions { white-space: nowrap; }

.filtro-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 14px;
}

.filtro-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.filtro-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 2px;
}

.filtro-field-value {
    font-size: 13px;
    color: var(--text);
    word-break: break-word;
    min-height: 18px;
}

@media (max-width: 768px) {
    .filtro-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
