:root {
    --var-primary-color: #14532d;
    --var-secondary-color: #1d4ed8
}

/* Reset e Variabili globali */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #f4f6f9;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.main-content {
    background: #ffffff;
    width: 100%;
    /*max-width: 400px;*/
    padding: 32px 24px;
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

/* Intestazione */
.login-header {
    text-align: center;
    margin-bottom: 32px;
}

    .login-header h2 {
        font-size: 28px;
        color: #1a1c1e;
        font-weight: 700;
        margin-bottom: 8px;
    }

/* Campi di input */
.input-group {
    margin-bottom: 20px;
}

    .input-group label {
        display: block;
        font-size: 14px;
        font-weight: 600;
        color: #374151;
        margin-bottom: 8px;
    }

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.forgot-password {
    font-size: 13px;
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

    .input-wrapper input {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px; /* Impedisce lo zoom automatico su iOS */
        border: 1.5px solid #e5e7eb;
        border-radius: 12px;
        background-color: #f9fafb;
        outline: none;
        transition: all 0.2s ease;
    }

        .input-wrapper input:focus {
            border-color: var(--var-primary-color);
            background-color: #ffffff;
            box-shadow: 0 0 0 4px color-mix(in srgb, var(--var-primary-color), transparent 90%);
        }

        /* campi in sola lettura: aspetto "spento" e nessuna evidenziazione al focus */
        .input-wrapper input[readonly] {
            background-color: #eef0f3;
            border-color: #eef0f3;
            color: #4b5563;
            box-shadow: none;
            cursor: default;
        }

/* Pulsante principale */
.btn-submit {
    position: relative;
    width: 100%;
    padding: 16px;
    background-color: var(--var-primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 10px;
}

    .btn-submit:hover {
        background-color: var(--var-secondary-color);
    }

/* Divisore */
.divider {
    text-align: center;
    margin: 24px 0;
    position: relative;
}

    .divider::before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0;
        right: 0;
        height: 1px;
        background-color: #e5e7eb;
        z-index: 1;
    }

    .divider span {
        background-color: #ffffff;
        padding: 0 12px;
        font-size: 13px;
        color: #9ca3af;
        position: relative;
        z-index: 2;
    }

p {
    margin-top: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #6c737f;
}

#messages-err {
    visibility: hidden;
    color: red;
    font-weight:bold;
    height:30px;
    padding:10px 0px;
}

#messages-respwd {
    visibility: hidden;
    color: var(--var-primary-color);
}
/*PAGINA PRINTLABEL*/
#page-printlabel {
    flex-direction: column;
    gap: 20px;
}

/* La pagina di stampa (@page) è definita in printlabel.html, per non applicarla alla stampa delle altre pagine.
   Le dimensioni in mm sono identiche a video e in stampa:
   il ridimensionamento automatico dei testi fatto a video vale anche per la stampa.
   Altezza 45,7 mm e non 50,8 (etichetta fisica): è il formato imposto dal servizio di stampa Zebra su Android
   (10,41 x 4,57 cm); con un'altezza maggiore il contenuto finiva sull'etichetta successiva */
.label {
    width: 101.6mm;
    height: 45.7mm;
    padding: 2mm 3mm;
    background: #ffffff;
    box-shadow: none !important; /* La box-shadow a video altera il calcolo del box-model in stampa */
    overflow: hidden;
    display: grid;
    grid-template-rows: 14mm 1fr 8mm;
    row-gap: 1mm;

}

    .label, .label * {
        font-family: Calibri, Carlito, Arial, sans-serif;
        font-weight: 700;
        color: #000000;
        line-height: 1.05;
    }

.label-top {
    display: grid;
    grid-template-columns: 1.6fr 14mm 1fr; /* più spazio alla data, che deve essere la più grande */
    column-gap: 3mm;
    align-items: center;
    min-height: 0;
}

/* Contenitori dei testi adattati: dimensione fissa, il font si riduce finché il testo non ci sta */
.label-fit {
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

/* safe: se il testo non sta, esce a destra (misurabile da scrollWidth) anziché a sinistra */
.label-qty {
    justify-content: safe flex-end;
}

.label-qr {
    width: 14mm;
    height: 14mm;
}

    .label-qr svg {
        display: block;
        width: 100%;
        height: 100%;
    }

.label-product {
    display: block;
    white-space: normal;
    overflow-wrap: normal;
}

@media print {
    #page-printlabel {
        display: block;
        min-height: 0;
        padding: 0;
        background: none;
    }

    #msg-container {
        display: none;
    }

    /* annulla il rimpicciolimento dell'anteprima a video fatto da fitPreview() */
    #labels {
        zoom: 1 !important;
    }

    /* una etichetta per pagina */
    .label {
        box-shadow: none;
        break-after: page;
    }

        .label:last-child {
            break-after: auto;
        }

        .label.label-copy {
            display: grid;
        }
}

/* le copie servono solo in stampa */
.label-copy {
    display: none;
}
/*END PAGINA PRINTLABEL*/

/*PAGINA STOCKS*/
.stocks-filters {
    margin-bottom: 24px;
}

.movements-section {
    margin-bottom: 32px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    padding-bottom: 8px;
    margin-bottom: 12px;
    border-bottom: 2px solid currentColor;
}

/* titolo di sezione con un pulsante a destra (es. "Azzera" in Da Aggiornare) */
.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

    .section-title-row h3 {
        font-size: inherit;
        font-weight: inherit;
    }

.today-title { color: #15803d; }
.modified-title { color: #b45309; }
.outdated-title { color: #b91c1c; }

.items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 14px 16px;
    border: 1.5px solid #e5e7eb;
    border-left-width: 5px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .stock-item:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

.stock-item-today {
    background-color: #f0fdf4;
    border-left-color: #15803d;
}

.stock-item-modified {
    background-color: #fffbeb;
    border-left-color: #f59e0b;
}

.stock-item-outdated {
    background-color: #fef2f2;
    border-left-color: #dc2626;
}

.stock-item-content {
    flex: 1;
}

.stock-item-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.stock-article {
    font-size: 15px;
    font-weight: 700;
    color: #1a1c1e;
}

.stock-date {
    font-size: 12px;
    color: #6c737f;
    white-space: nowrap;
}

.stock-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 20px;
    font-size: 13px;
    color: #6c737f;
}

.stock-detail-item {
    display: flex;
    justify-content: space-between;
}

.stock-detail-label {
    font-weight: 600;
    color: #374151;
    margin-right: 5px;
}

.btn-delete {
    padding: 10px 14px;
    background-color: #dc2626;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

    .btn-delete:hover {
        background-color: #b91c1c;
    }

.empty-message {
    text-align: center;
    padding: 20px;
    font-size: 14px;
    color: #9ca3af;
    font-style: italic;
}

@media (max-width: 608px) {
    .stock-item {
        flex-direction: column;
        align-items: stretch;
    }

    .stock-details {
        grid-template-columns: 1fr;
    }
}
/*END PAGINA STOCKS*/

/*PAGINA STOCK_NEW*/
/* Autocomplete di articolo e fornitore: lista dei risultati sotto il campo (.input-wrapper è già position: relative) */
.autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1001; /* sopra la barra del menu */
    max-height: 360px; /* ricalcolata da JS in base allo spazio visibile */
    overflow-y: auto;
    overscroll-behavior: contain; /* lo scorrimento della lista non trascina la pagina */
    list-style: none;
    margin: 0;
    padding: 6px;
    background: #ffffff;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

    .autocomplete-list[hidden] {
        display: none;
    }

.autocomplete-option {
    min-height: 44px; /* area di tocco comoda */
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.3;
    color: #1a1c1e;
    cursor: pointer;
}

    .autocomplete-option:hover,
    .autocomplete-option.active {
        background-color: color-mix(in srgb, var(--var-primary-color), transparent 90%);
    }

.autocomplete-info {
    padding: 10px 12px;
    font-size: 13px;
    font-style: italic;
    color: #6c737f;
}
/*END PAGINA STOCK_NEW*/

/*PAGINA READ_QRCODE*/
/* position: relative serve a qr-scanner per posizionare il riquadro di scansione sopra il video */
.qr-reader {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    background-color: #111827;
}

    .qr-reader video {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.qr-status {
    text-align: center;
    font-size: 15px;
}

    .qr-status.error {
        color: #dc2626;
        font-weight: 600;
    }

/* pulsante torcia sovrapposto al video, in basso a destra */
.qr-torch {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2; /* sopra il riquadro di scansione disegnato da qr-scanner */
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    cursor: pointer;
}

    .qr-torch[hidden] {
        display: none;
    }

    .qr-torch svg {
        width: 26px;
        height: 26px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .qr-torch.on {
        background-color: #facc15;
        color: #1a1c1e;
    }
/*END PAGINA READ_QRCODE*/

/*SPINNER SU PULSANTE*/
.swap-spinner {
    align-items: center;
    display: none; /*mettere flex*/
    justify-content: center;
    width: 30px;
    height: 30px;
    overflow: hidden;
    position: absolute;
    top: 12px;
    left: 15px;
}

    .swap-spinner.active {
        display: flex;
    }

@-webkit-keyframes swap {
    0%, 100% {
        -webkit-transform: scale(0);
        transform: scale(0);
    }

    50% {
        -webkit-transform: scale(1);
        transform: scale(1);
    }
}

@keyframes swap {
    0%, 100% {
        -webkit-transform: scale(0);
        transform: scale(0);
    }

    50% {
        -webkit-transform: scale(1);
        transform: scale(1);
    }
}

.swap-spinner:after, .swap-spinner:before {
    border-radius: 100%;
    content: '';
    height: 30px;
    opacity: .5;
    position: absolute;
    width: 30px;
}

.swap-spinner:after {
    -webkit-animation: swap 1.5s -0.75s infinite;
    animation: swap 1.5s -0.75s infinite;
    background-color: green;
}

.swap-spinner:before {
    -webkit-animation: swap 1.5s infinite;
    animation: swap 1.5s infinite;
    background-color: white;
}
/*END SPINNER SU PULSANTE*/

/* --- MENU --- */
/* Spazio per la barra di navigazione fissa in basso */
body.has-app-nav {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

/* overflow hidden: nasconde il pannello utente quando è fuori schermo a destra.
   touch-action pan-y: gli swipe orizzontali sulla barra arrivano alla pagina (apertura/chiusura del pannello) */
.app-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    overflow: hidden;
    touch-action: pan-y;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    --handle-width: 22px;
}

/* riga di voci (menu principale e pannello utente); a destra/sinistra lo spazio per la linguetta */
.app-nav-items {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px calc(8px + var(--handle-width)) calc(8px + env(safe-area-inset-bottom)) 8px;
}

/* Pannello utente: copre il menu principale scorrendo da destra */
.app-nav-panel {
    position: absolute;
    inset: 0;
    background: #ffffff;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

    .app-nav-panel .app-nav-items {
        height: 100%;
        padding-left: calc(8px + var(--handle-width));
        padding-right: 8px;
    }

.app-nav.panel-open .app-nav-panel {
    transform: translateX(0);
}

/* Linguetta: quella di apertura sta subito a sinistra del pannello, quindi a pannello chiuso è attaccata
   al bordo destro della barra e si sposta con il pannello durante l'animazione; quella di chiusura è sul bordo sinistro del pannello */
.app-nav-handle {
    position: absolute;
    top: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: var(--handle-width);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background-color: #e5e7eb;
    color: #374151;
    cursor: pointer;
}

    .app-nav-handle svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2.5;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.app-nav-handle-open {
    right: 100%;
    border-radius: 10px 0 0 10px;
}

.app-nav-handle-close {
    left: 0;
    border-radius: 0 10px 10px 0;
}

@media (prefers-reduced-motion: reduce) {
    .app-nav-panel {
        transition: none;
    }
}

.app-nav-item {
    flex: 1 1 0;
    max-width: 150px;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 4px;
    border: none;
    border-radius: 12px;
    background: none;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

    .app-nav-item svg {
        width: 28px;
        height: 28px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
        flex-shrink: 0;
    }

    .app-nav-item.active {
        color: var(--var-primary-color);
        background-color: color-mix(in srgb, var(--var-primary-color), transparent 90%);
    }

/* Azione principale della pagina di stampa */
.app-nav-print {
    background-color: var(--var-primary-color);
    color: #ffffff;
}

    .app-nav-print:disabled {
        opacity: 0.4;
        cursor: default;
    }

.app-nav-copies {
    flex: 0 0 72px;
    cursor: default;
}

    .app-nav-copies input {
        width: 60px;
        height: 36px;
        font-size: 18px; /* almeno 16px: impedisce lo zoom automatico su iOS */
        font-weight: 700;
        text-align: center;
        border: 1.5px solid #e5e7eb;
        border-radius: 10px;
        background-color: #f9fafb;
        outline: none;
    }

        .app-nav-copies input:focus {
            border-color: var(--var-primary-color);
            background-color: #ffffff;
        }

/* Pulsante secondario (es. "No" di confirmMsg) */
.btn-submit.btn-secondary {
    background-color: #e5e7eb;
    color: #374151;
}

    .btn-submit.btn-secondary:hover {
        background-color: #d1d5db;
    }

@media print {
    .app-nav {
        display: none;
    }
}
/* --- END MENU --- */

/* --- MESSAGES NOTIFICATION --- */
#msg-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Stile del singolo msg */
.msg {
    min-width: 250px;
    padding: 15px 20px;
    background: #333;
    color: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: pointer;
}

    .msg.show {
        opacity: 1;
        transform: translateX(0);
    }

    /* Varianti di colore */
    .msg.success {
        border-left: 5px solid #2ecc71;
        background: #1f2c24;
        color: #d4edda;
    }

    .msg.error {
        border-left: 5px solid #e74c3c;
        background: #2c1f1f;
        color: #f8d7da;
    }

    .msg.info {
        border-left: 5px solid #3498db;
        background: #1f262c;
        color: #d1ecf1;
    }

/* il testo della domanda eredita il colore del msg (la regola globale su p lo renderebbe grigio su fondo scuro) */
.confirm-dialog p {
    margin-top: 0;
    font-size: 15px;
    color: inherit;
}

/* Pulsanti Sì/No di confirmMsg: riusano .btn-submit e .btn-submit.btn-secondary */
.confirm-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

    .confirm-actions .btn-submit {
        flex: 1;
        margin-top: 0;
        padding: 12px;
        font-size: 15px;
    }
/* Adattamento Mobile */
@media (max-width: 608px) {
    #msg-container {
        top: 10px;
        right: 10px;
        left: 10px; /* Prende tutta la larghezza in alto */
    }

    .msg {
        min-width: auto;
        transform: translateY(-100%); /* Scivola dall'alto su mobile */
    }

        .msg.show {
            transform: translateY(0);
        }
}
/* --- END MESSAGES NOTIFICATION --- */

body#page-login{
    flex-direction:column
}

.logo-container{
    margin-bottom:30px;
}
