.cursor-pointer {
    cursor: pointer;
}

/* ── DataTables: intestazioni ── */
table.table .thead-sm > tr > th,
table.table thead.thead-sm > tr > th,
.thead-sm > * > * {
    padding: 0.65rem 0.75rem !important;
    font-size: 0.72rem !important;
    letter-spacing: 0.04em !important;
    color: #495057 !important;
}
table.table thead.bg-light-subtle {
    border-bottom: 2px solid #dee2e6 !important;
}

/* ── DataTables: info count ── */
div.dataTables_wrapper div.dataTables_info,
.dataTables_info {
    padding: 0.75rem 1rem !important;
    font-size: 0.8rem !important;
}

/* ── DataTables: paginazione ── */
div.dataTables_wrapper div.dataTables_paginate,
.dataTables_paginate {
    padding: 0.5rem 1rem 1rem !important;
}

/* ── Card headers: fix flex per bottoni a destra ── */
.card-header[style*="display:flex"] {
    flex-wrap: nowrap;
}

/* ── Tom Select: fix globale ── */

/* Dropdown */
.ts-dropdown {
    background: var(--bs-body-bg, #fff) !important;
    border: 1px solid var(--bs-border-color, #dee2e6) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,.12) !important;
    z-index: 1060 !important;
}
.ts-dropdown .ts-dropdown-content {
    background: var(--bs-body-bg, #fff) !important;
}
.ts-dropdown .option {
    background: transparent !important;
    color: var(--bs-body-color, #212529) !important;
    padding: 0.5rem 0.75rem !important;
}
.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background: rgba(var(--bs-primary-rgb, 13,110,253), 0.08) !important;
    color: var(--bs-body-color, #212529) !important;
}
.ts-dropdown .no-results {
    padding: 0.5rem 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
}

/* Control input */
.ts-control {
    background: var(--bs-body-bg, #fff) !important;
    border-color: var(--bs-border-color, #dee2e6) !important;
}
.ts-control input {
    color: var(--bs-body-color, #212529) !important;
}

/* Allineamento: stessa altezza dei form-select-sm di Bootstrap */
.ts-wrapper.form-select-sm .ts-control,
.ts-wrapper .ts-control {
    min-height: calc(1.5em + 0.5rem + 2px) !important;
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
    border-radius: 0.375rem !important;
}
.ts-wrapper .ts-control > input {
    font-size: 0.875rem !important;
}

/* Bottone X (clear) - visibile solo su hover/focus, centrato */
.plugin-clear_button.has-items .clear-button {
    font-size: 1.15em !important;
    top: 50% !important;
    transform: translateY(-55%) !important;
}

/* Fix altezza wrapper per coerenza con form-select-sm */
.ts-wrapper.single .ts-control {
    padding-right: 2rem !important;
}
.ts-wrapper.single .ts-control::after {
    /* Freccia dropdown: stessa posizione di Bootstrap */
    right: 0.5rem;
}

/* ── Filtri /offerte: selezioni a pillola coerenti ──
   Stato (.ts-status-filter): badge colorati semanticamente come in tabella.
   Tipo/Anno/Cliente/Venditore (.ts-bar-filter): stessa forma pillola, colore
   neutro (secondary), perché qui il colore non codifica nulla.
   Struttura condivisa: .item è un contenitore trasparente, colore e forma
   vivono sul .badge annidato (così lo sfondo grigio di default di TomSelect
   non interferisce), la × è ereditata dal colore della pillola. */

/* Spazio riservato a destra per il caret: senza, quando le pillole riempiono
   il control ci finiscono sotto e il click sulla freccia (background chevron
   di .form-select) colpisce la × dell'ultima pillola cancellandola. Selettore
   su .ts-wrapper per pareggiare la specificità di `.ts-wrapper.form-select-sm
   .ts-control` più sopra, altrimenti il suo padding shorthand vince. */
.ts-wrapper.ts-status-filter .ts-control,
.ts-wrapper.ts-bar-filter .ts-control {
    padding-right: 2.25rem !important;
    /* Centra verticalmente le pillole: i multi-select le allineavano in alto,
       fuori asse rispetto ai single (Tipo/Venditore). */
    align-items: center !important;
}
/* L'input di ricerca dei multi ha un min-width di default (~7rem): in un
   control stretto va a capo creando una seconda riga, così la pillola resta
   in alto invece che centrata. Azzerato: sta in linea con le pillole. */
.ts-status-filter .ts-control > input,
.ts-bar-filter .ts-control > input {
    min-width: 0 !important;
    flex: 1 1 0 !important;
}
/* Il tema TomSelect bootstrap5 aggiunge un padding-top asimmetrico ai control
   multi.has-items (regola con !important, il wrapper eredita form-select-sm dal
   select): spinge le pillole fuori asse rispetto ai single. Lo riporto
   simmetrico al padding di base del control (0.25rem). La regola del tema ha
   4 classi + !important e il suo CSS è caricato DOPO custom.css: a pari
   specificità vincerebbe per ordine, quindi aggiungo form-select-sm per salire
   a 5 classi e batterla comunque. */
.ts-wrapper.form-select-sm.ts-status-filter.multi.has-items .ts-control,
.ts-wrapper.form-select-sm.ts-bar-filter.multi.has-items .ts-control {
    padding-top: 0.25rem !important;
}
.ts-status-filter .ts-control .item,
.ts-bar-filter .ts-control .item {
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 2px 6px 2px 0 !important;
    display: inline-flex !important;
    align-items: center;
}
/* Pillola neutra dei filtri non-Stato: slate (grigio-freddo), non il viola
   di `secondary` della skin. Colore esplicito perché il .badge senza utility
   di testo sarebbe bianco; override per il tema scuro. */
.ts-pill-neutral {
    background-color: #eef1f5;
    color: #475569;
}
[data-bs-theme="dark"] .ts-pill-neutral {
    background-color: rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
}
.ts-status-filter .ts-control .item .badge,
.ts-bar-filter .ts-control .item .badge {
    padding: 0.3em 0.65em;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}
.ts-status-filter .ts-control .item .remove,
.ts-bar-filter .ts-control .item .remove {
    border: 0 !important;
    padding: 0 0 0 0.25rem !important;
    margin-left: -0.35rem;
    color: inherit;
    opacity: 0.55;
    font-size: 1rem;
    line-height: 1;
    background: transparent !important;
}
.ts-status-filter .ts-control .item .remove:hover,
.ts-bar-filter .ts-control .item .remove:hover {
    opacity: 1;
    background: transparent !important;
}
/* Opzioni nel dropdown dello Stato: pallino del colore stato come legenda. */
.ts-status-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ts-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}

/* ── Sidebar: chiusura completa (hidden) ── */
html[data-sidenav-size="hidden"] .sidenav-menu {
    display: none !important;
}
html[data-sidenav-size="hidden"] .content-page {
    margin-left: 0 !important;
}
html[data-sidenav-size="hidden"] .topbar-custom {
    left: 0 !important;
}
/* Bottone riapertura sidebar: visibile solo quando sidebar è nascosta */
.btn-open-sidebar {
    display: none !important;
}
html[data-sidenav-size="hidden"] .btn-open-sidebar {
    display: inline-flex !important;
}

/* ── Sidebar dark: bottone chiudi menu ── */
html[data-sidenav-color="dark"] .menu-collapse-box {
    background: var(--ins-sidenav-bg, #1c1d28) !important;
    border-color: var(--ins-sidenav-border-color, #1c1d28) !important;
}
html[data-sidenav-color="dark"] .menu-collapse-box .button-toggle-sidebar {
    color: var(--ins-sidenav-item-color, #6c7889) !important;
    background: transparent !important;
    border: none !important;
}
html[data-sidenav-color="dark"] .menu-collapse-box .button-toggle-sidebar:hover {
    color: var(--ins-sidenav-item-hover-color, #bccee4) !important;
    background: var(--ins-sidenav-item-hover-bg, #20222e) !important;
}

/* ── Topbar: bottone hamburger posizione ── */
.btn-open-sidebar {
    margin-left: 8px;
    margin-right: 4px;
}

/* ── Flatpickr: fix giorno selezionato invisibile ── */
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus,
.flatpickr-day.startRange,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange,
.flatpickr-day.endRange:hover {
    background: #111827 !important;
    border-color: #111827 !important;
    color: #fff !important;
    font-weight: 600 !important;
    border-radius: 0.5rem !important;
}
.flatpickr-day.today:not(.selected) {
    border-color: #111827 !important;
    color: #111827 !important;
    background: transparent !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   Topbar: notifiche + lavori AI in corso (ai-topbar-notifications.js)
   ══════════════════════════════════════════════════════════════════════════ */
.fs-xxs { font-size: 0.68rem; line-height: 1.1; }

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Campanella — badge pulse quando ci sono job in corso */
@keyframes ai-bell-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}
.ai-bell-count-pulse {
    animation: ai-bell-pulse 1.8s infinite;
}

/* Dropdown */
.ai-notif-dropdown {
    width: 380px;
    max-width: 92vw;
}

.ai-notif-scroll {
    max-height: 440px;
    overflow-y: auto;
}

.ai-notif-section + .ai-notif-section {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-notif-section-title {
    padding: 10px 16px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7785;
    display: flex;
    align-items: center;
}

.ai-notif-empty {
    color: #8b95a5;
    text-align: center;
    padding: 22px 16px !important;
}

/* ── Card AI job (dentro dropdown) ── */
.ai-job-card.dropdown-item,
.ai-job-card {
    position: relative;
    padding: 10px 16px;
    text-decoration: none !important;
    transition: background 120ms ease;
    /* Override: .dropdown-item di Bootstrap ha white-space: nowrap e rompeva
       il layout facendo sfondare il titolo oltre il bordo della dropdown. */
    white-space: normal;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.ai-job-card:hover {
    background: rgba(13, 110, 253, 0.05);
}

/* Layout interno esplicito (non dipendiamo più da d-flex/flex-grow-1 di BS
   per evitare le stesse trappole di min-width auto che rompevano l'overflow). */
.ai-job-card-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    min-width: 0;
}
.ai-job-body {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.ai-job-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}
.ai-job-progress-meta {
    display: flex;
    justify-content: space-between;
    min-width: 0;
}

.ai-job-icon {
    width: 36px; height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center; justify-content: center;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(135deg, #6c5ce7 0%, #0d6efd 100%);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.35);
}
.ai-job-card--mapping .ai-job-icon {
    background: linear-gradient(135deg, #0dcaf0 0%, #6c5ce7 100%);
}

.ai-job-card.is-running .ai-job-icon {
    animation: ai-job-icon-pulse 2.2s ease-in-out infinite;
}
@keyframes ai-job-icon-pulse {
    0%, 100% { transform: scale(1);    filter: brightness(1); }
    50%      { transform: scale(1.06); filter: brightness(1.12); }
}

.ai-job-card.is-pending .ai-job-icon {
    background: linear-gradient(135deg, #adb5bd 0%, #6b7785 100%);
    box-shadow: none;
    opacity: .85;
}

.ai-job-title {
    font-size: 0.85rem;
    line-height: 1.25;
    color: #1f2937;
    flex: 1 1 auto;
    min-width: 0;
    /* line-clamp su 2 righe è più robusto di text-truncate a una riga in
       layout flex innestati: evita overflow orizzontale indipendentemente
       dal min-width dei container parent. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.ai-job-subtitle {
    margin-top: 2px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-job-status-badge {
    font-size: 0.6rem;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}

.ai-job-progress {
    height: 6px;
    border-radius: 999px;
    background: #eceff3;
    overflow: hidden;
    position: relative;
}
.ai-job-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6c5ce7, #0d6efd);
    transition: width 400ms cubic-bezier(.4, 0, .2, 1);
    position: relative;
    overflow: hidden;
}
.ai-job-card--mapping .ai-job-progress-fill {
    background: linear-gradient(90deg, #0dcaf0, #6c5ce7);
}
/* Shimmer sulla progress bar quando running */
.ai-job-card.is-running .ai-job-progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.45) 50%,
        rgba(255,255,255,0) 100%);
    animation: ai-progress-shimmer 1.6s linear infinite;
}
.ai-job-card.is-pending .ai-job-progress-fill {
    background: #cfd5dd;
    width: 100% !important;
    opacity: .5;
}
@keyframes ai-progress-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%);  }
}

.ai-job-pct {
    font-weight: 600;
    color: #4b5563;
}

/* ── Notifica item ── */
.ai-notif-item {
    position: relative;
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: background 120ms ease, opacity 180ms ease, transform 180ms ease;
}
.ai-notif-item:last-child { border-bottom: none; }
.ai-notif-item:hover { background: rgba(13, 110, 253, 0.04); }
.ai-notif-item.is-unread { background: rgba(13, 110, 253, 0.06); }
.ai-notif-item.is-unread:hover { background: rgba(13, 110, 253, 0.1); }

.ai-notif-item.is-unread::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: #0d6efd;
}

.ai-notif-item.is-dismissing {
    opacity: 0;
    transform: translateX(8px);
    pointer-events: none;
}

.ai-notif-link {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 6px 10px 16px;
    text-decoration: none !important;
    color: inherit;
}
.ai-notif-link:hover { color: inherit; text-decoration: none; }

.ai-notif-inner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.ai-notif-icon-wrap {
    width: 36px; height: 36px;
    display: inline-flex;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}

.ai-notif-text {
    min-width: 0;
    overflow: hidden;
}

.ai-notif-title {
    font-size: 0.82rem;
    line-height: 1.25;
    color: #1f2937;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.ai-notif-body {
    margin-top: 2px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.ai-notif-time {
    margin-top: 4px;
    display: block;
}

/* ── Pulsante "X" dismiss singolo ── */
.ai-notif-dismiss {
    flex-shrink: 0;
    width: 28px; height: 28px;
    margin: 10px 10px 0 4px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 150ms ease, background 150ms ease, color 150ms ease;
    display: inline-flex;
    align-items: center; justify-content: center;
    cursor: pointer;
}
.ai-notif-item:hover .ai-notif-dismiss,
.ai-notif-dismiss:focus-visible {
    opacity: 1;
}
.ai-notif-dismiss:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* ══════════════════════════════════════════════════════════════════════════
   Modal Mappa AI: progress bar in-modal (Fase 1 + Fase 2)
   ══════════════════════════════════════════════════════════════════════════ */
.ai-progress-bar {
    height: 8px;
    border-radius: 999px;
    background: #eceff3;
    overflow: hidden;
    position: relative;
}
.ai-progress-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6c5ce7 0%, #0d6efd 50%, #0dcaf0 100%);
    background-size: 200% 100%;
    animation: ai-progress-bar-shift 3s linear infinite;
    transition: width 500ms cubic-bezier(.4, 0, .2, 1);
    position: relative;
}
.ai-progress-bar-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.55) 50%,
        rgba(255,255,255,0) 100%);
    animation: ai-progress-shimmer 1.6s linear infinite;
}
.ai-progress-bar--mapping .ai-progress-bar-fill {
    background: linear-gradient(90deg, #0dcaf0 0%, #6c5ce7 50%, #d63384 100%);
    background-size: 200% 100%;
    animation: ai-progress-bar-shift 3s linear infinite;
}
@keyframes ai-progress-bar-shift {
    0%   { background-position:   0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Footer non "appiccicato" al contenuto: spazio tra il contenuto della
   pagina e il footer. Dimensione/aspetto del footer INVARIATI; non tocca
   il margin-top:auto del tema, quindi lo sticky in fondo resta intatto. */
.content-page > .container-fluid {
    padding-bottom: 1.75rem;
}

/* Footer in fondo anche su Chrome mobile/tablet: il tema usa 100vh, che su
   mobile Chrome include lo spazio dietro la barra indirizzi dinamica → la
   pagina "finisce più in basso" e il footer scende sotto il fold. 100dvh
   misura l'altezza realmente visibile. Applicato solo dove supportato,
   così desktop e Safari restano identici. */
@supports (min-height: 100dvh) {
    .content-page {
        min-height: calc(100dvh - calc(var(--ins-topbar-height) + 1px));
    }
}
