/* ============================================================
   styles.css – Foglio di stile principale
   Architettura: Reset → Variabili → Base → Header → Layout →
                 Filtri → Tabella → Modal → Form → Utilità
   ============================================================ */

/* ============================================================
   1. VARIABILI CSS (Design Tokens)
   ============================================================ */
:root {
    /* Palette principale – blu profondo industriale */
    --clr-primary: #1a2e4a;
    --clr-primary-light: #2a4a72;
    --clr-primary-dark: #0f1c2e;

    /* Accent – arancione caldo */
    --clr-accent: #e8753a;
    --clr-accent-hover: #d4632a;

    /* Neutri */
    --clr-bg: #f0f2f5;
    --clr-surface: #ffffff;
    --clr-surface-alt: #f7f8fa;
    --clr-border: #dce1e7;
    --clr-border-focus: #2a4a72;
    --clr-text: #1e2a38;
    --clr-text-muted: #6b7a8d;
    --clr-text-light: #9aa5b4;

    /* Stato: aperto (arancione - in elaborazione) */
    --clr-stato-aperto-bg: #fff4e6;
    --clr-stato-aperto-txt: #b85c00;
    --clr-stato-aperto-dot: #ff9500;

    /* Stato: consegnato (verde - completato) */
    --clr-stato-consegnato-bg: #e6f7ec;
    --clr-stato-consegnato-txt: #1b7a3f;
    --clr-stato-consegnato-dot: #2dbe5e;

    /* Stato: annullato (rosso - cancellato) */
    --clr-stato-annullato-bg: #fbeaea;
    --clr-stato-annullato-txt: #a33030;
    --clr-stato-annullato-dot: #d44848;

    /* Errore / Danger */
    --clr-danger: #d44848;
    --clr-danger-hover: #b83a3a;
    --clr-danger-light: #fbeaea;

    /* Tipografia */
    --font-base: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Consolas', 'Courier New', monospace;

    /* Spacing scale */
    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 16px;
    --sp-lg: 24px;
    --sp-xl: 32px;
    --sp-2xl: 48px;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Ombre */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .10);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .14);

    /* Transition default */
    --transition: 180ms ease;

    /* Header altezza */
    --header-h: 62px;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

[hidden] {
    display: none !important;
}

body {
    font-family: var(--font-base);
    font-size: 14px;
    line-height: 1.5;
    color: var(--clr-text);
    background-color: var(--clr-bg);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

img,
svg {
    display: block;
    max-width: 100%;
}

/* ============================================================
   3. HEADER
   ============================================================ */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--clr-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.header-inner {
    max-width: 1320px;
    margin: 0 auto;
    height: 100%;
    padding: 0 var(--sp-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- Logo --- */
.logo-link {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.logo-image {
    height: 40px;
    width: auto;
    max-width: 120px;
}

/* --- Menu Nav --- */
.nav-list {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, .62);
    font-size: 13.5px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.nav-item--active .nav-link {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.nav-item--active .nav-link:hover {
    background: rgba(255, 255, 255, .18);
}

.nav-item--disabled .nav-link {
    opacity: .38;
    pointer-events: none;
}

.nav-item:not(.nav-item--active):not(.nav-item--disabled) .nav-link:hover {
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .85);
}

.nav-icon {
    font-size: 15px;
    line-height: 1;
}

/* ============================================================
   4. MAIN LAYOUT
   ============================================================ */
.app-main {
    padding: var(--sp-xl) var(--sp-lg);
    min-height: calc(100vh - var(--header-h));
}

.content-wrapper {
    max-width: 1320px;
    margin: 0 auto;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-md);
    margin-bottom: var(--sp-lg);
    flex-wrap: wrap;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--clr-primary);
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--clr-text-muted);
    margin-top: 2px;
}

/* ============================================================
   5. PULSANTI
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    transition: background var(--transition), box-shadow var(--transition), transform 80ms ease;
    user-select: none;
}

.btn:active {
    transform: scale(.97);
}

/* Primary */
.btn--primary {
    background: var(--clr-accent);
    color: #fff;
    box-shadow: 0 2px 6px rgba(232, 117, 58, .35);
}

.btn--primary:hover {
    background: var(--clr-accent-hover);
    box-shadow: 0 3px 10px rgba(232, 117, 58, .42);
}

/* Ghost */
.btn--ghost {
    background: transparent;
    color: var(--clr-text-muted);
    border: 1.5px solid var(--clr-border);
}

.btn--ghost:hover {
    border-color: var(--clr-border-focus);
    color: var(--clr-text);
    background: var(--clr-surface-alt);
}

/* Danger */
.btn--danger {
    background: var(--clr-danger);
    color: #fff;
}

.btn--danger:hover {
    background: var(--clr-danger-hover);
}

/* New order button sizing */
.btn--new-order {
    padding: 10px 22px;
    font-size: 15px;
}

.btn--new-order .btn-icon {
    font-size: 19px;
    line-height: 1;
    margin-top: -1px;
}

/* ============================================================
   6. FILTRI & RICERCA
   ============================================================ */
.filters-bar {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-md) var(--sp-lg);
    margin-bottom: var(--sp-md);
    box-shadow: var(--shadow-sm);
}

.filters-bar__inner {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-xl);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--clr-text-light);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* Chips stato */
.filter-chips {
    display: flex;
    gap: var(--sp-xs);
}

.chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--clr-border);
    font-size: 13px;
    font-weight: 500;
    color: var(--clr-text-muted);
    background: var(--clr-surface-alt);
    transition: all var(--transition);
}

.chip:hover {
    border-color: var(--clr-primary-light);
    color: var(--clr-primary);
}

.chip--active {
    background: var(--clr-primary);
    color: #fff;
    border-color: var(--clr-primary);
}

/* Search input */
.filter-group--search {
    flex: 1;
    min-width: 240px;
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    font-size: 15px;
    pointer-events: none;
}

.input-search {
    width: 100%;
    padding: 8px 36px 8px 36px;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--clr-text);
    background: var(--clr-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.input-search:focus {
    border-color: var(--clr-border-focus);
    box-shadow: 0 0 0 3px rgba(42, 74, 114, .14);
}

.input-search::placeholder {
    color: var(--clr-text-light);
}

.search-clear {
    position: absolute;
    right: 10px;
    font-size: 13px;
    color: var(--clr-text-light);
    transition: color var(--transition);
    padding: 2px 4px;
}

.search-clear:hover {
    color: var(--clr-text);
}

/* ============================================================
   7. LOADING BAR (Top page indicator)
   ============================================================ */
.loading-bar {
    height: 3px;
    background: transparent;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--sp-md);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease;
}

.loading-bar--active {
    opacity: 1;
    visibility: visible;
}

.loading-bar__fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--clr-accent), var(--clr-primary-light), var(--clr-accent));
    border-radius: 2px;
    transition: none;
}

.loading-bar--active .loading-bar__fill {
    animation: progressLoad 1.5s ease-in-out infinite;
}

@keyframes progressLoad {
    0% {
        width: 0%;
        opacity: 1;
    }

    50% {
        width: 100%;
        opacity: 1;
    }

    100% {
        width: 100%;
        opacity: 0.1;
    }
}

/* ============================================================
   7B. LOADING OVERLAY (Caricamento Tabelle)
   ============================================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.loading-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-lg);
    background: var(--clr-surface);
    padding: var(--sp-2xl) var(--sp-xl);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: loadingFadeIn 300ms ease;
}

@keyframes loadingFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Spinner animato */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--clr-border);
    border-top-color: var(--clr-accent);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--clr-text);
    letter-spacing: 0.3px;
}

.loading-subtext {
    font-size: 13px;
    color: var(--clr-text-muted);
    margin-top: -12px;
}

/* Effetto blur sulla tabella quando sta caricando */
.table-section--loading {
    filter: blur(3px);
    pointer-events: none;
    transition: filter 200ms ease;
}

/* ============================================================
   8. TABELLA ORDINI
   ============================================================ */
.table-section {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
    /* Altezza massima per mantenere visibili header e filtri */
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--clr-border);
    /* Separazione visiva se scorre */
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
    table-layout: auto;
}

/* Header colonne */
.orders-table thead {
    background: var(--clr-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.orders-table th {
    padding: 13px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--clr-primary-dark);
}

.orders-table th:first-child {
    border-radius: 0;
}

/* Righe */
.orders-table tbody tr {
    border-bottom: 1px solid var(--clr-border);
    transition: background var(--transition);
}

.orders-table tbody tr:last-child {
    border-bottom: none;
}

.orders-table tbody tr {
    cursor: pointer;
}

.orders-table tbody tr:hover {
    background: var(--clr-surface-alt);
}

/* Evidenziazione ordini in sospeso (> 20 giorni) */
.orders-table tbody tr.row--alert {
    background-color: #fff4e6;
    /* Sfondo arancio chiarissimo */
}

.orders-table tbody tr.row--alert:hover {
    background-color: #ffe8cc;
}

.orders-table tbody tr.row--alert .col-date {
    color: var(--clr-danger);
    font-weight: 700;
}

.orders-table tbody tr.row--alert .col-date::after {
    content: ' ⚠️';
    font-size: 1.1em;
}

.orders-table td {
    padding: 13px 16px;
    font-size: 13.5px;
    vertical-align: middle;
    color: var(--clr-text);
}

/* Colonne specifiche */
.col-date {
    color: var(--clr-text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.col-code {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    color: var(--clr-primary);
}

.col-art-code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--clr-text-muted);
}

.col--qty {
    text-align: right;
}

.td-qty {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.col--stato {
    text-align: center;
    width: auto;
    min-width: 140px;
    white-space: nowrap;
    vertical-align: middle;
}

.orders-table th.col--stato {
    text-align: center;
}

/* Colonne adattive che non occupano troppo spazio */
.orders-table th:nth-child(1),
/* Data - uppercase */
.orders-table td:nth-child(1) {
    width: auto;
    white-space: nowrap;
    text-transform: uppercase;
}

/* Se siamo nella tabella operatori, la prima colonna (Nome) deve poter essere minuscola */
#operatori-table td:nth-child(1) {
    text-transform: none;
}

/* 2. Cliente - si adatta al contenuto */
.orders-table th:nth-child(2),
.orders-table td:nth-child(2) {
    width: auto;
    text-transform: uppercase;
}

/* 3. Concessionaria / Fornitore - si adatta al contenuto */
.orders-table th:nth-child(3),
.orders-table td:nth-child(3) {
    width: auto;
    text-transform: uppercase;
}

/* 4. Articolo / Descrizione - si adatta al contenuto */
.orders-table th:nth-child(4),
.orders-table td:nth-child(4) {
    width: auto;
    text-transform: uppercase;
}

/* 5. Operatore - Rimosso uppercase dai dati, mantieni per header */
.orders-table th:nth-child(5) {
    width: auto;
    text-transform: uppercase;
}

.orders-table td:nth-child(5) {
    width: auto;
    text-transform: none;
}

/* 6. Stato - uppercase */
.orders-table th:nth-child(6),
.orders-table td:nth-child(6) {
    text-transform: uppercase;
}

.orders-table th:last-child,
/* Azioni */
.orders-table td:last-child {
    width: 1%;
    white-space: nowrap;
}

/* --- Badge stato --- */
.badge-stato {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-stato__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Stato: aperto */
.badge-stato--aperto {
    background: var(--clr-stato-aperto-bg);
    color: var(--clr-stato-aperto-txt);
}

.badge-stato--aperto .badge-stato__dot {
    background: var(--clr-stato-aperto-dot);
    box-shadow: 0 0 5px rgba(45, 190, 94, .4);
}

/* Stato: chiuso */
.badge-stato--chiuso {
    background: var(--clr-stato-chiuso-bg);
    color: var(--clr-stato-chiuso-txt);
}

.badge-stato--chiuso .badge-stato__dot {
    background: var(--clr-stato-chiuso-dot);
}

/* Stato: annullato */
.badge-stato--annullato {
    background: var(--clr-stato-annullato-bg);
    color: var(--clr-stato-annullato-txt);
}

.badge-stato--annullato .badge-stato__dot {
    background: var(--clr-stato-annullato-dot);
}

/* --- Badge articoli (numero di righe nell'ordine) --- */
.desc-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.articoli-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 2px 8px;
    background: var(--clr-primary-light);
    color: white;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

/* Note - colonna con larghezza fissa */
.col-note {
    width: 200px;
    max-width: 200px;
    color: var(--clr-text-muted);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    cursor: help;
    padding-right: 20px;
}

.col-note--empty {
    color: var(--clr-text-light);
    font-style: normal;
    cursor: default;
}

.col-note--truncated .note-indicator {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--clr-accent);
    font-size: 10px;
    pointer-events: none;
}

/* Tooltip per note lunghe */
/* Tooltip globale JS */
.global-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    background: var(--clr-accent);
    color: #fff;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-style: normal;
    white-space: normal;
    max-width: 320px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
    line-height: 1.5;
}

.global-tooltip--visible {
    opacity: 1;
}

/* --- Azioni --- */
.col--actions {
    text-align: right;
}

.td-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-xs);
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--clr-text-muted);
    background: transparent;
    border: 1.5px solid transparent;
    transition: all var(--transition);
}

.btn-action:hover {
    background: var(--clr-surface-alt);
    border-color: var(--clr-border);
}

.btn-action--edit:hover {
    color: var(--clr-primary);
    border-color: var(--clr-primary-light);
    background: #eef2f7;
}

.btn-action--deliver:hover {
    color: var(--clr-stato-consegnato-dot);
    border-color: var(--clr-stato-consegnato-dot);
    background: var(--clr-stato-consegnato-bg);
}

.btn-action--delete:hover {
    color: var(--clr-danger);
    border-color: var(--clr-danger);
    background: var(--clr-danger-light);
}

/* Indicatore "multi riga" sotto la descrizione */
.riga-multi {
    display: block;
    margin-top: 3px;
    font-size: 11.5px;
    color: var(--clr-text-light);
    font-style: italic;
}

/* Pulsante copia codice prodotto */
.btn-copy-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-left: 5px;
    border: none;
    background: transparent;
    color: var(--clr-text-light);
    font-size: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    vertical-align: middle;
}

.btn-copy-code:hover {
    color: var(--clr-primary);
    background: var(--clr-surface-alt);
}

.btn-copy-code--copied {
    color: var(--clr-success, #2dbe5e) !important;
}

/* ============================================================
   9. STATO VUOTO
   ============================================================ */
.empty-state {
    padding: var(--sp-2xl) var(--sp-lg);
    text-align: center;
}

.empty-state__icon {
    font-size: 40px;
    display: block;
    margin-bottom: var(--sp-md);
}

.empty-state__text {
    color: var(--clr-text-muted);
    font-size: 15px;
}

/* ============================================================
   10. MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15, 28, 46, 0.52);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-lg);
    /* Animazione ingresso */
    opacity: 0;
    transition: opacity 220ms ease;
    pointer-events: none;
}

.modal-overlay--confirm {
    z-index: 1050;
}

.modal-overlay:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--clr-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 900px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    /* Animazione slide-up */
    transform: translateY(18px);
    transition: transform 260ms cubic-bezier(.4, 0, .2, 1);
}

.modal-overlay:not([hidden]) .modal {
    transform: translateY(0);
}

.modal--small {
    max-width: 440px;
}

/* Modal header */
.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-lg) var(--sp-lg) var(--sp-md);
    border-bottom: 1px solid var(--clr-border);
}

.modal__title {
    font-size: 18px;
    font-weight: 700;
    color: var(--clr-primary);
}

.modal__close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    font-size: 18px;
    color: var(--clr-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal__close:hover {
    background: var(--clr-danger-light);
    color: var(--clr-danger);
}

/* Modal body – scrollabile */
.modal__body {
    padding: var(--sp-lg);
    overflow-y: auto;
    flex: 1;
}

/* Modal footer */
.modal__footer {
    padding: var(--sp-md) var(--sp-lg);
    border-top: 1px solid var(--clr-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-sm);
    background: var(--clr-surface-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Conferma cancellazione – testo */
.modal-confirm__text {
    color: var(--clr-text);
    font-size: 15px;
    line-height: 1.6;
}

/* Modal autenticazione – body centrato */
.modal__body--centered {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: var(--sp-lg);
}

/* Modal autenticazione – footer */
.modal__footer--centered {
    justify-content: center;
    gap: 15px;
    padding-top: 10px;
}

/* Form autenticazione */
#form-auth {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Input password autenticazione */
#input-auth-password {
    padding-left: 40px;
    text-align: center;
    letter-spacing: 3px;
    width: 100%;
}

/* ============================================================
   11. FORM ORDINE (dentro modal)
   ============================================================ */
.form-row {
    display: flex;
    gap: var(--sp-md);
    margin-bottom: var(--sp-md);
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group--full {
    flex-basis: 100%;
}

.form-group--data,
.form-group--operatore,
.form-group--stato {
    flex: 0 0 220px;
    /* Non crescono, non rimpiccioliscono, base 220px */
}

@media (max-width: 768px) {

    .form-group--data,
    .form-group--operatore,
    .form-group--stato {
        flex: 1 1 100%;
        /* Su mobile tornano a occupare tutto lo spazio */
    }
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--clr-text);
}

.form-required {
    color: var(--clr-danger);
    margin-left: 2px;
}

/* Input / Select / Textarea */
.form-input,
.form-select,
.form-textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--clr-text);
    background: var(--clr-surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

/* Input in maiuscolo (tranne le note e le select) */
.form-input {
    text-transform: uppercase;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--clr-border-focus);
    box-shadow: 0 0 0 3px rgba(42, 74, 114, .12);
}

.form-input[readonly] {
    background: var(--clr-surface-alt);
    color: var(--clr-text-muted);
}

/* Escludi le note e il nome operatore dal maiuscolo */
#txt-note,
#input-nome-operatore,
#input-auth-password {
    text-transform: none !important;
}

.form-textarea {
    resize: vertical;
    min-height: 56px;
}

/* Errori di validazione */
.form-error {
    font-size: 12px;
    color: var(--clr-danger);
    min-height: 16px;
    font-weight: 500;
}

/* --- Sezione righe ordine --- */
.form-section {
    margin-top: var(--sp-lg);
    border-top: 1px solid var(--clr-border);
    padding-top: var(--sp-md);
}

/* Banner avviso garanzia scaduta (> 12 mesi) */
.garanzia-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff8e1;
    border: 1px solid #f59c00;
    border-left: 4px solid #e65100;
    border-radius: var(--radius-md);
    color: #7a4000;
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: var(--sp-md);
    animation: fadeInAlert 250ms ease;
}

.garanzia-alert i {
    font-size: 18px;
    color: #e65100;
    flex-shrink: 0;
}

@keyframes fadeInAlert {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-sm);
}

.form-section__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--clr-primary);
}

/* Pulsante "Aggiunge Riga" */
.btn--add-riga {
    padding: 5px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    background: rgba(232, 117, 58, 0.1);
    color: var(--clr-accent);
    border: 0.5px solid var(--clr-accent);
    transition: all var(--transition);
}

.btn--add-riga:hover {
    background: var(--clr-accent);
    color: white;
}

/* Singola riga articolo */
.riga-articolo {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-sm);
    background: var(--clr-surface-alt);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-sm);
    transition: border-color var(--transition);
}

.riga-articolo:hover {
    border-color: var(--clr-border-focus);
}

.riga-articolo__fields {
    display: flex;
    gap: var(--sp-sm);
    flex: 1;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* Distribuzioni colonne riga */
.riga-group--codice {
    flex: 1;
    min-width: 100px;
}

.riga-group--desc {
    flex: 2.5;
    min-width: 180px;
}

.riga-group--qty {
    flex: 0.6;
    min-width: 55px;
}

/* Input numero – nasconde frecce in Chrome */
.riga-quantita::-webkit-outer-spin-button,
.riga-quantita::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.riga-quantita {
    -moz-appearance: textfield;
    appearance: textfield;
    text-align: center;
    font-weight: 600;
}

/* Pulsante rimozione riga */
.btn-remove-riga {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 13px;
    color: var(--clr-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.btn-remove-riga:hover {
    background: var(--clr-danger-light);
    color: var(--clr-danger);
}

/* ============================================================
    12. DETAIL MODAL – Visualizzazione dettagli ordine
    ============================================================ */
.detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-md);
    overflow-y: auto;
}

.detail-modal {
    background: var(--clr-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.detail-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--sp-lg);
    border-bottom: 1px solid var(--clr-border);
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-light));
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.detail-modal__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.detail-modal__subtitle,
.detail-modal__header p {
    margin: 4px 0 0;
    font-size: 14px;
    opacity: 0.9;
    font-weight: 500;
    text-transform: uppercase !important;
}

.detail-modal__close {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition);
}

.detail-modal__close:hover {
    opacity: 0.7;
}

.detail-modal__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-md);
    padding: var(--sp-lg);
    background: var(--clr-surface-alt);
    border-bottom: 1px solid var(--clr-border);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--clr-text);
}

.detail-modal__body {
    flex: 1;
    padding: var(--sp-lg);
    overflow-y: auto;
}

.detail-modal__section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--clr-primary);
    margin: 0 0 var(--sp-md);
    padding-bottom: var(--sp-sm);
    border-bottom: 2px solid var(--clr-accent);
}

.detail-rows {
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
}

.detail-row {
    display: flex;
    gap: var(--sp-md);
    padding: var(--sp-md);
    background: var(--clr-surface-alt);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    align-items: flex-start;
    transition: all var(--transition);
}

.detail-row:hover {
    border-color: var(--clr-primary-light);
    background: white;
}

.detail-row--consegnato {
    opacity: 0.7;
    background: var(--clr-stato-chiuso-bg);
}

.detail-row__checkbox {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding-top: 2px;
}

.riga-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--clr-accent);
}

.riga-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.detail-row__content {
    flex: 1;
    min-width: 0;
}

.detail-row__codice {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--clr-primary);
    margin-bottom: 4px;
}

.detail-row__desc {
    font-size: 14px;
    color: var(--clr-text);
    margin-bottom: 4px;
    word-break: break-word;
}

.detail-row__qty {
    font-size: 12px;
    color: var(--clr-text-muted);
}

.detail-row__status {
    flex-shrink: 0;
    text-align: right;
}

.detail-row__actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

.btn-riga-action {
    width: 32px;
    height: 32px;
    border: 1px solid var(--clr-border);
    background: white;
    color: var(--clr-text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-riga-action:hover {
    border-color: var(--clr-text-muted);
    color: var(--clr-text);
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge--consegnato {
    background: var(--clr-stato-consegnato-bg);
    color: var(--clr-stato-consegnato-txt);
}

.status-badge--attesa {
    background: #fef3c7;
    color: #92400e;
}

.detail-modal__footer {
    display: flex;
    gap: var(--sp-md);
    padding: var(--sp-lg);
    border-top: 1px solid var(--clr-border);
    background: var(--clr-surface-alt);
    flex-wrap: wrap;
}

.detail-modal__footer .btn {
    flex: 1;
    min-width: 120px;
}

/* ============================================================
    13. LOADING BAR ANIMATION
    ============================================================ */

/* ============================================================
   13. STATO BADGE (COLORATO)
   ============================================================ */
.stato-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.3;
}

.stato-badge::before {
    content: '';
    font-size: 14px;
    line-height: 1;
}

.stato-badge.stato--aperto {
    background: var(--clr-stato-aperto-bg);
    color: var(--clr-stato-aperto-txt);
}

.stato-badge.stato--aperto::before {
    content: '⏳';
}

.stato-badge.stato--consegnato,
.stato-badge.stato--chiuso {
    background: var(--clr-stato-consegnato-bg);
    color: var(--clr-stato-consegnato-txt);
}

.stato-badge.stato--consegnato::before,
.stato-badge.stato--chiuso::before {
    content: '✓';
}

.stato-badge.stato--annullato {
    background: var(--clr-stato-annullato-bg);
    color: var(--clr-stato-annullato-txt);
}

.stato-badge.stato--annullato::before {
    content: '✕';
}

/* Stati garanzie */
.stato-badge.stato--spedito-al-fornitore {
    background: #e3f2fd;
    color: #1976d2;
}

.stato-badge.stato--accettata {
    background: #e8f5e9;
    color: #2dbe5e;
}

.stato-badge.stato--rifiutata {
    background: #ffebee;
    color: #d44848;
}

/* ============================================================
   14. ACTION BUTTONS (mini buttons per tabella)
   ============================================================ */
.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
    background: var(--clr-surface-alt);
    border: 1px solid var(--clr-border);
    color: var(--clr-text-muted);
    transition: all var(--transition);
    cursor: pointer;
}

.btn-action:hover {
    background: var(--clr-border);
    color: var(--clr-text);
}

.btn-action--delete:hover {
    background: var(--clr-danger-light);
    color: var(--clr-danger);
    border-color: var(--clr-danger);
}

/* ============================================================
   15. RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {

    :root {
        --sp-lg: 16px;
        --sp-xl: 20px;
    }

    .header-inner {
        padding: 0 var(--sp-md);
    }

    .logo-text {
        font-size: 17px;
    }

    .nav-list {
        gap: 2px;
    }

    .nav-link {
        padding: 7px 10px;
        font-size: 12.5px;
    }

    .nav-link span:not(.nav-icon) {
        display: none;
    }

    .app-main {
        padding: var(--sp-md);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--sp-sm);
    }

    .filters-bar__inner {
        flex-direction: column;
        align-items: stretch;
        gap: var(--sp-md);
    }

    .filter-group--search {
        min-width: unset;
    }

    .modal {
        max-width: 100%;
        max-height: 92vh;
    }

    .modal__body {
        padding: var(--sp-md);
        max-height: 60vh;
        overflow-y: auto;
    }

    .form-row {
        flex-direction: column;
    }

    .riga-articolo {
        flex-direction: column;
        align-items: stretch;
    }

    .riga-articolo__fields {
        flex-direction: column;
        gap: var(--sp-xs);
        width: 100%;
    }

    .riga-group--codice,
    .riga-group--desc,
    .riga-group--qty {
        flex: 1;
        min-width: unset;
        width: 100%;
    }

    .btn-remove-riga {
        align-self: flex-end;
        margin-top: var(--sp-xs);
    }

    /* Tabella responsive */
    .table-scroll {
        overflow-x: auto;
    }

    .orders-table {
        font-size: 12px;
    }

    .orders-table th,
    .orders-table td {
        padding: 8px;
    }
}

@media (max-width: 480px) {

    .page-title {
        font-size: 19px;
    }

    .chip {
        padding: 5px 11px;
        font-size: 12px;
    }

    .btn--new-order {
        width: 100%;
        justify-content: center;
    }

    .orders-table {
        font-size: 11px;
    }

    .orders-table th,
    .orders-table td {
        padding: 6px;
    }

    .col--actions {
        white-space: nowrap;
    }

    .btn-action {
        width: 28px;
        height: 28px;
        font-size: 12px;
        margin: 0 1px;
    }
}

/* ============================================================
   SEZIONE IMPOSTAZIONI – TAB (Operatori / Cestino)
   ============================================================ */

.settings-tabs {
    display: flex;
    gap: 4px;
    padding: 0 0 var(--sp-lg);
    border-bottom: 2px solid var(--clr-border);
    margin-bottom: var(--sp-lg);
}

.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--clr-text-muted);
    background: transparent;
    border: 1.5px solid transparent;
    border-bottom: none;
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
    bottom: -2px;
}

.settings-tab:hover {
    color: var(--clr-primary);
    background: var(--clr-surface-alt);
}

.settings-tab--active {
    color: var(--clr-primary);
    background: var(--clr-surface);
    border-color: var(--clr-border);
    border-bottom-color: var(--clr-surface);
}

/* Badge numero elementi nel tab Cestino */
.cestino-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--clr-danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* Tab panel */
.tab-panel {
    animation: fadeIn 180ms ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sub-header in tab panel (Operatori) */
.page-header--sub {
    padding: 0 0 var(--sp-md);
    align-items: center;
}

/* ============================================================
   CESTINO – Sezioni Ordini / Tappeti
   ============================================================ */

.cestino-section {
    margin-bottom: var(--sp-2xl);
}

.cestino-section__header {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    margin-bottom: var(--sp-md);
    padding-bottom: var(--sp-sm);
    border-bottom: 2px solid var(--clr-accent);
}

.cestino-section__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--clr-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

/* Colonna data eliminazione: lieve enfasi */
.col-deleted-at {
    color: var(--clr-danger);
    font-size: 12.5px;
    white-space: nowrap;
}

/* Pulsante Ripristina (btn-action--restore) */
.btn-action--restore {
    color: var(--clr-accent);
}

.btn-action--restore:hover {
    color: white;
    background: var(--clr-accent);
    border-color: var(--clr-accent);
}

/* ============================================================
   MODAL RIPRISTINO – Scelta stato (Aperto / Chiuso)
   ============================================================ */

.ripristino-choices {
    display: flex;
    gap: var(--sp-md);
    margin-top: var(--sp-sm);
}

.ripristino-choice {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: var(--sp-lg) var(--sp-md);
    border: 2px solid var(--clr-border);
    border-radius: var(--radius-lg);
    background: var(--clr-surface-alt);
    cursor: pointer;
    transition: all 200ms ease;
    text-align: center;
}

.ripristino-choice:hover {
    border-color: var(--clr-primary-light);
    background: #eef3f8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.ripristino-choice:active {
    transform: translateY(0);
}

.ripristino-choice__icon {
    font-size: 26px;
    color: var(--clr-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--clr-surface);
    border: 1.5px solid var(--clr-border);
    transition: all 200ms ease;
}

.ripristino-choice:hover .ripristino-choice__icon {
    background: var(--clr-primary);
    color: white;
    border-color: var(--clr-primary);
}

.ripristino-choice__label {
    font-weight: 700;
    font-size: 15px;
    color: var(--clr-primary);
}

.ripristino-choice__desc {
    font-size: 12px;
    color: var(--clr-text-muted);
    line-height: 1.4;
}

/* Versione Chiuso: usa accent archiviazione */
#btn-ripristino-chiuso:hover {
    border-color: var(--clr-text-muted);
    background: #f5f5f0;
}

#btn-ripristino-chiuso:hover .ripristino-choice__icon {
    background: var(--clr-text-muted);
    color: white;
    border-color: var(--clr-text-muted);
}

@media (max-width: 480px) {
    .ripristino-choices {
        flex-direction: column;
    }

    .settings-tabs {
        flex-wrap: wrap;
    }

    .settings-tab {
        flex: 1;
        justify-content: center;
        border-radius: var(--radius-sm);
        bottom: 0;
    }
}

/* ============================================================
   AUTOCOMPLETE DROPDOWN – Suggerimenti fornitori
   ============================================================ */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border-focus);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.autocomplete-item {
    padding: 8px 14px;
    font-size: 13px;
    color: var(--clr-text);
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.autocomplete-item:hover,
.autocomplete-item--active {
    background: var(--clr-primary);
    color: #fff;
}

.autocomplete-item strong {
    font-weight: 700;
    color: var(--clr-accent);
}

.autocomplete-item--active strong {
    color: var(--clr-accent);
}

/* ============================================================
   PAGINATION CONTROLS
   ============================================================ */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 16px;
    background: var(--clr-surface);
    border-top: 1px solid var(--clr-border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    gap: 16px;
}

.pagination-info {
    font-size: 13px;
    color: var(--clr-text-muted);
    font-weight: 500;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

.btn--pagination {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    background: var(--clr-primary);
    color: white;
    border: 1px solid var(--clr-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 200ms ease;
}

.btn--pagination:hover:not(:disabled) {
    background: var(--clr-accent);
    border-color: var(--clr-accent);
}

.btn--pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}