#preloader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    z-index: 99999;
    transition: opacity .4s ease;
}

#preloader img {
    width: 140px;
}


/* --- Stili Colori e Bottoni --- */
.btn-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: #e2001a;
    --bs-btn-border-color: #e2001a;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #c20d19;
    --bs-btn-hover-border-color: #c20d19;
    --bs-btn-focus-shadow-rgb: 225, 83, 97;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #c20d19;
    --bs-btn-active-border-color: #c20d19;
    --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: #e2001a;
    --bs-btn-disabled-border-color: #e2001a;
}

.btn-success {
    --bs-btn-color: #fff;
    --bs-btn-bg: #57AB27;
    --bs-btn-border-color: #57AB27;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #289548;
    --bs-btn-hover-border-color: #289548;
    --bs-btn-focus-shadow-rgb: 87, 171, 39;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #289548;
    --bs-btn-active-border-color: #57AB27;
    --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: #57AB27;
    --bs-btn-disabled-border-color: #57AB27;
}

.btn-outline-success {
    --bs-btn-color: #57AB27;
    --bs-btn-border-color: #57AB27;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #57AB27;
    --bs-btn-hover-border-color: #57AB27;
    --bs-btn-focus-shadow-rgb: 87, 171, 39;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #57AB27;
    --bs-btn-active-border-color: #57AB27;
    --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
    --bs-btn-disabled-color: #57AB27;
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: #57AB27;
    --bs-gradient: none;
}

.bg-success {
    background-color: rgba(93, 175, 49, var(--bs-bg-opacity)) !important;
}

.bg-danger {
    background-color: rgba(226, 0, 26, var(--bs-bg-opacity)) !important;
}


.text-danger {
    color: #e2001a !important;
}

.text-bg-danger {
    color: #ffffff !important;
    background-color: #e2001a !important;
}

.text-instagram {
    color: #E4405F;
}

.text-success {
    color: rgba(93, 175, 49, var(--bs-text-opacity)) !important;
}

/* --- Pagination --- */
.pagination {
    --bs-pagination-focus-color: initial;
    --bs-pagination-focus-bg: var(--bs-secondary-bg);
    --bs-pagination-focus-box-shadow: none;
    --bs-pagination-active-color: #000000;
    --bs-pagination-active-bg: #fff;
    --bs-pagination-active-border-color: var(--bs-border-color);
}

.page-link,
.page-link:hover {
    color: #000;
}

/* --- Tooltip --- */
.custom-tooltip {
    --bs-tooltip-bg: var(--bd-violet-bg);
    --bs-tooltip-color: var(--bs-white);
}

/* --- Accordion --- */
.accordion {
    --bs-accordion-btn-icon-width: 1rem;
}

.accordion-button {
    background-color: var(--bs-secondary-bg);
}

.accordion-button:not(.collapsed) {
    background-color: var(--bs-secondary-bg);
    box-shadow: none;
    color: initial;
}

.accordion-body .accordion-button,
.accordion-body .accordion-button:not(.collapsed) {
    background-color: transparent;
}

.accordion-button,
.accordion-body a {
    font-size: 0.8rem;
}

.accordion-button:focus {
    box-shadow: none;
}

.small {
    font-size: 0.8rem;
}

.password-input-wrapper {
    position: relative;
}

.password-input-wrapper .form-control {
    padding-right: 2.75rem !important;
}

.password-visibility-toggle {
    position: absolute;
    top: 1px;
    right: 1px;
    bottom: 1px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color, #6c757d);
    border-radius: 0 var(--bs-border-radius, .375rem) var(--bs-border-radius, .375rem) 0;
}

.password-visibility-toggle:hover,
.password-visibility-toggle:focus {
    background: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-body-color, #212529);
}


/* --- Custom Width/Height --- */
.min-100 {
    min-width: 100px !important;
}

.max-60 {
    max-width: 60px !important;
}

.max-100 {
    max-width: 100px !important;
}

.max-150 {
    max-width: 150px !important;
}

@media (min-width: 1800px) {
    .lg-400 {
        min-width: 400px !important;
    }

    .w-lg-auto {
        width: auto !important;
    }
}

.w-10 {
    width: 10% !important;
}

.w-15 {
    width: 15% !important;
}



/* --- Custom Dropdown Submenu --- */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>.dropdown-menu {
    position: static !important;
    margin-left: 1rem;
    padding-left: 0.5rem;
    border: none;
    box-shadow: none;
}

.dropdown-submenu.show>.dropdown-menu {
    display: block;
}

.dropdown-menu a.d-block.p-2.ps-4.border-top.text-black.text-decoration-none {
    border: none !important;
    padding-top: 0 !important;
}

.navbar-shrink,
.navbar-shrink img {
    transition: all 0.3s ease;
}

.navbar-shrink {
    position: fixed;
    top: 0;
    width: 100%;
}

.navbar-shrink {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.navbar-shrink .navbar-brand .img-fluid {
    max-height: 55px;
}

.navbar-brand .img-fluid {
    max-height: 75px;
    transition: all 0.3s ease;
}

@media (max-width: 576px) {

    /* schermi piccoli */
    .navbar-brand .img-fluid {
        max-height: 65px;
        transition: all 0.3s ease;
    }
}

/* --- Personalizzazioni Modale Ricerca --- */
.modal form fieldset.border.rounded.p-3.small {
    border: none !important;
    padding: 0 !important;
}

.modal form fieldset legend {
    display: none;
}

.modal .modal-d-flex {
    display: flex !important;
}

.modal .modal-d-none {
    display: none !important;
}

/* --- Preventivatore --- */
.step-content {
    display: none;
}

.step-content.active {
    display: block;
}

.draggable-card {
    cursor: move;
    /* O 'grab' */
}

/* --- Checkout --- */
.start-25 {
    left: 25% !important;
}

.start-75 {
    left: 75% !important;
}

@media (min-width: 1200px) {
    #dropdownArticoliList {
        width: 440px;
        max-height: 440px;
    }
}

@media (max-width: 576px) {
    #dropdownArticoliList {
        width: 100%;
        max-height: auto;
    }
}

/*Progressbar*/
.progress {
    height: 25px;
}

/* Line Heigh Responsive per tabella Confronto Articoli */
.lh-responsive {
    line-height: 1.2;
    /* mobile default */
}

@media (min-width: 768px) {

    /* md e superiori */
    .lh-responsive {
        line-height: 1.4;
        /* desktop */
    }
}


/*E-SHOP MONITOR*/

/* VERDE - cliente assegnato all'agente loggato */
.monitor-main-table tr.Verde,
.monitor-main-table tr.Verde td {
    background-color: #c8ffd1 !important;
    color: #044a0a !important;
}

/* GIALLO - potenzialmente assegnabile */
.monitor-main-table tr.Giallo,
.monitor-main-table tr.Giallo td {
    background-color: #fffacb !important;
    color: #444 !important;
}

/* Custom Top Sellers Pill (Uniforme ai badge prodotti) */
.btn-top-sellers {
    background-color: #ffc107 !important; /* Giallo badge standard */
    color: white !important;
    border: none !important;
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1); /* Aiuta la leggibilità del bianco sul giallo */
}

.btn-top-sellers:hover {
    background-color: #ffca28 !important;
    transform: translateY(-1px);
}

.btn-check:checked + .btn-top-sellers {
    background-color: #ffb300 !important; /* Un po' più scuro quando attivo */
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1) !important;
    filter: brightness(0.95);
}

/* ROSSO - non assegnabile */
.monitor-main-table tr.Rosso,
.monitor-main-table tr.Rosso td {
    background-color: #ffb3b3 !important;
    color: #700000 !important;
}

/* Dimensione tabella */
.monitor-main-table table {
    font-size: 0.8em;
}

/* Freccia animata */
.arrow-icon {
    display: inline-block !important;
    transition: transform 0.25s ease;
    font-size: 1rem;
}

/* Righe cliccabili */
.cursor-pointer {
    cursor: pointer;
}

/* Classe per rimuovere i tasti up/down dai tipi di campo number */
.no-spinner::-webkit-outer-spin-button,
.no-spinner::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.no-spinner {
    -moz-appearance: textfield;
    /* Firefox */
}

/*Per Gestione Listino box Azione Massiva*/
.mode-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Effetto Hover sulle Card Prodotti */
.product-card {
    transition: transform 0.3s ease;
}

.product-card:hover {
    transform: translateY(-5px);
}

.review-summary-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: .45rem;
    width: 100%;
    font-size: .78rem;
    line-height: 1.15;
}

.review-summary-card .review-rating-line {
    display: flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
}

.review-summary-card .review-stars {
    flex: 0 0 auto;
    white-space: nowrap;
    letter-spacing: 0;
}

.review-summary-card .review-count {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.review-summary-card .review-action {
    justify-self: start;
    border-radius: 999px;
    font-size: .72rem;
    line-height: 1;
    padding: .22rem .45rem;
    white-space: nowrap;
}

/* --- Global Search Overlay (Solo scrollbar) --- */
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}


/* --- Effettivo Hover per Card (es. Azienda) --- */
.transition-hover {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.transition-hover:hover {
    transform: translateY(-5px);
}

/* --- Effetto Scroll Reveal sui Titoli (es. Azienda) --- */
.scroll-reveal-title {
    /* Doppio gradiente: sopra rosso, sotto grigio. Testo trasparente per evitare layer scuri */
    background-image:
        linear-gradient(90deg, #e2001a, #e2001a),
        linear-gradient(90deg, #212529, #b0b0b0);
    background-repeat: no-repeat;
    background-size: 0% 100%, 100% 100%;
    color: transparent;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
    background-position: left;
    transition: background-size 0.1s ease-out;
    display: inline-block;
}

@media (prefers-reduced-motion: reduce) {
    .scroll-reveal-title {
        color: #e2001a;
        background-image: none;
        background-size: auto;
        -webkit-text-fill-color: #e2001a;
    }
}

#searchOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 1040;
    transform: translateY(-100%);
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#searchOverlay.is-active {
    transform: translateY(0);
    visibility: visible;
}

#searchOverlay .search-header {
    background: white;
    z-index: 10;
    flex-shrink: 0;
}


.is-focused #overlaySearchInput {
    border-bottom-color: #e2001a !important;
    /* Mantiene il rosso Trend */
    transform: none;
    padding-left: 0 !important;
}

/* Animazione di apparizione del campo quando si entra nell'overlay */
#searchOverlay .search-header {
    animation: slideDownHeader 0.4s ease-out;
}

@keyframes slideDownHeader {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

#overlaySearchInput::placeholder {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Placeholder behavior handled by browser default */
@media (min-width: 1400px) {
    .row-cols-xxl-8>* {
        flex: 0 0 auto;
        width: 12.5% !important;
    }
}

.recent-search-tag {
    border: 1px solid #dee2e6;
    border-radius: 50px;
    padding: 2px 12px;
    font-size: 0.85rem;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    display: inline-flex;
    align-items: center;
}

.recent-search-tag:hover {
    background: #f8f9fa;
    border-color: #ced4da;
    color: #dc3545;
}

.recent-search-tag .btn-remove-tag {
    margin-left: 8px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.recent-search-tag {
    border: 1px solid #adb5bd !important;
    color: #495057 !important;
}

.recent-search-tag:hover {
    border-color: #6c757d !important;
    color: #212529 !important;
}

.truncate-3-lines {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Sticky Search Filters --- */
.search-sidebar-sticky {
    position: -webkit-sticky;
    position: sticky;
    top: 100px !important;
    z-index: 10;
    align-self: flex-start;
    /* Impedisce alla colonna di allungarsi, permettendo allo sticky di funzionare */
    height: fit-content !important;
    padding-bottom: 2rem;
}

#searchOverlay .search-sidebar-sticky {
    top: 20px !important;
}

.search-horizontal-bar.sticky-top {
    top: 75px;
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1020; /* Leggermente superiore per stare sopra il resto */
    margin-bottom: 1.5rem !important;
    padding-top: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Assicuriamoci che i dropdown della ricerca (ordinamento e filtri) siano sempre sopra tutto */
.search-results-col .dropdown-menu,
.search-horizontal-bar .dropdown-menu {
    z-index: 2000 !important;
}

#searchOverlay .search-sidebar-sticky {
    top: 140px !important;
    /* Aumentato per non sovrapporsi all'header e alle "Ultime ricerche" */
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    /* Ripristiniamo lo scroll interno se i filtri sono troppi, ora che abbiamo spazio */
    padding-top: 10px;
    scrollbar-width: thin;
}

/* Back to Top */
#backToTop {
    z-index: 1050;
    /* Superiore all'overlay */
    transition: transform 0.2s ease, opacity 0.2s ease;
    bottom: 180px !important; /* Alzato per non sovrapporsi alla chat di ProvideSupport */
}

#backToTop:hover {
    transform: scale(1.1);
}

.search-mobile-apply-container {
    border: none !important;
    outline: none !important;
    background: inherit !important;
    box-shadow: none !important;
}

/* --- Autocomplete Suggestions --- */
.autocomplete-container {
    position: relative;
}

.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    z-index: 1050;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 0 0 8px 8px;
}

.autocomplete-suggestions div {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.autocomplete-suggestions div:hover {
    background-color: #f8f9fa;
    color: #e2001a;
}

.autocomplete-suggestions div:last-child {
    border-bottom: none;
}

/* Table responsive scrollable layout for Gestione Ordini */
.table-responsive-ordini {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1200px) {
    .table-responsive-ordini table {
        width: 1200px !important;
    }
}

/* Evita che i totali vadano a capo nella colonna Totale */
.table-responsive-ordini td.order-total {
    white-space: nowrap !important;
}
/* Dashboard totale ordini in alto */
.dashboard-totali {
    font-size: 0.95rem;
    font-weight: 500;
}
.dashboard-totali span {
    font-weight: 700;
}

/* --- Ottimizzazione per Monitor Verticali (es. 1080x1920 portrait) --- */
@media (orientation: portrait) and (min-width: 900px) {
    /* Rimuove lo scroll orizzontale e forza la tabella a larghezza intera */
    .table-responsive-ordini {
        overflow-x: hidden !important;
    }
    .table-responsive-ordini table {
        width: 100% !important;
        min-width: 100% !important;
    }

    /* Ridistribuzione larghezze delle colonne comuni e specifiche */
    .col-th-ordine { width: 6% !important; }
    .col-th-cliente { width: 20% !important; }
    .col-th-tipo { width: 5% !important; }
    .col-th-data { width: 10% !important; }
    .col-th-totale { width: 8% !important; }
    .col-th-azioni { width: 7% !important; }

    /* Ridistribuzione colonne variabili per allineamento perfetto 100% */
    #cardControlloCredito .col-th-operatore { width: 14% !important; }
    #cardControlloCredito .col-th-motivo { width: 30% !important; }

    #cardDaLavorare .col-th-motivo { width: 44% !important; }

    #cardInLavorazione .col-th-operatore,
    #cardPreparato .col-th-operatore {
        width: 22% !important;
    }
    #cardInLavorazione .col-th-magazziniere,
    #cardPreparato .col-th-magazziniere {
        width: 22% !important;
    }

    #cardSpedito .col-th-operatore {
        width: 25% !important;
    }
    #cardSpedito .col-th-magazziniere {
        width: 26% !important;
    }

    #cardSospeso .col-th-operatore { width: 44% !important; }

    /* Testi e celle (aumentati per migliorare la leggibilità in portrait) */
    .table-responsive-ordini table th,
    .table-responsive-ordini table td {
        padding: 7px 5px !important;
        font-size: 13px !important;
    }

    /* Dettagli secondari (agente, tempo trascorso) */
    .table-responsive-ordini td .text-secondary,
    .table-responsive-ordini td .elapsed-time-tracker {
        font-size: 12px !important;
    }

    /* Icone logistiche e icone in griglia */
    .table-responsive-ordini td i.bi {
        font-size: 16px !important;
    }

    /* Pulsante Sollecita (campanella) */
    .table-responsive-ordini td .btn-action-sollecita {
        font-size: 11px !important;
        padding: 4px 7px !important;
        line-height: 1.2 !important;
    }

    /* Nasconde le azioni desktop sulla risoluzione portrait */
    .desktop-only-actions {
        display: none !important;
    }

    /* Forza il modale dettagli ad occupare il 95% della larghezza in verticale */
    .modal-xxl {
        max-width: 95% !important;
    }

    /* Nasconde la scritta "MODIFICATO" del badge e regola il padding in portrait */
    .badge-text-modified {
        display: none !important;
    }
    .badge-modified-pulse {
        padding: 4px 6px !important;
    }
}

/* Evita a capo per pulsanti d'azione desktop */
.desktop-only-actions {
    white-space: nowrap;
}

/* --- Classe per rendere il modale ancora più grande di modal-xl su monitor larghi --- */
@media (min-width: 1400px) {
    .modal-xxl {
        max-width: 95% !important;
    }
}

/* --- Stili per gli Ordini Modificati --- */
.order-modified-row {
    border-left: 4px solid #fd7e14 !important;
}

.badge-modified-pulse {
    background-color: #fd7e14 !important;
    color: #ffffff !important;
    font-weight: bold;
    animation: pulse-orange 2s infinite;
}

.badge-text-modified {
    display: inline-block;
}

[aria-expanded="true"] .collapse-arrow-fido {
    transform: rotate(180deg);
}

/* Padding per i contenitori alert solo se non vuoti (risolve doppia riga continua) */
div[id^="alertContainer"]:not(:empty) {
    padding: 8px 16px 0 16px !important;
}

@keyframes pulse-orange {
    0% {
        box-shadow: 0 0 0 0 rgba(253, 126, 20, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(253, 126, 20, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(253, 126, 20, 0);
    }
}

.badge-sm {
    font-size: 0.65em !important;
    padding: 0.25em 0.5em !important;
}

/* Fix scorrimento menu prodotti su mobile */
@media (max-width: 991.98px) {
    .navbar-collapse {
        max-height: calc(100vh - 85px);
        overflow-y: auto !important;
    }
}
