:root {
    --left-column-width: 300px;
    --primary-color: #000000;
    --secondary-color: #ff6600;
    --light-gray: #f5f5f5;
    --medium-gray: #9d9d9d;
    --dark-gray: #333;
    --text-color: #333;
    --border-color: #ddd;
}

/** {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}*/

html, body {
    height: 100% !important;
    width: 100% !important;
    overflow-x: hidden;
}

body {
    background-color: var(--light-gray);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header-shop {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.containershop {
    width: 99%;
    margin: 0 auto;
    padding: 0 0px;
    flex: 1;
    display: grid;
    grid-template-columns: var(--left-column-width) 1fr; /* Usa la variabile */
    gap: 20px;
    min-height: 0;
    overflow: visible;
}

.header-shop .containershop {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: none;
    grid-template-columns: none;
    overflow: visible;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    display: grid;
    grid-auto-flow: column;
    gap: 1.5rem;
    align-items: center;
}

.logo-img {
    height: 75px;
    width: auto;
}

.left-column {
    background: white;
    margin: .75rem 0;
    border-radius: 10px;
    padding: .5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.right-column {
    background: white;
    margin: .75rem 0;
    border-radius: 10px;
    padding: .75rem;
}

.search-section {
    padding: 8px 0;
    margin: 0 0 8px 0;
    flex: 1;
    border-bottom: 1px solid var(--light-gray);
    overflow-y: auto;
    overflow-x: hidden;
}

    .search-section::-webkit-scrollbar {
        width: 6px;
    }

    .search-section::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    .search-section::-webkit-scrollbar-thumb {
        background: var(--medium-gray);
        border-radius: 3px;
    }

        .search-section::-webkit-scrollbar-thumb:hover {
            background: var(--dark-gray);
        }

.image-section {
    padding: 15px;
    text-align: center;
    flex-shrink: 0;
    max-height: 200px;
    overflow: hidden;
}

.chain-diagram {
    max-width: 100%;
    width: 100%;
    height: auto;
}

.right-column {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

h1 {
    color: var(--primary-color);
    margin-bottom: 30px;
    text-align: center;
}

/* SISTEMA UNIFICATO PER TUTTI GLI INPUT DEL FORM */
.form-group {
    margin-bottom: 0;
    display: grid;
    grid-template-rows: auto auto;
    align-items: flex-start;
}

    .form-group label {
        display: block;
        margin-bottom: 2px;
        font-weight: bold;
        color: var(--primary-color);
        padding-right: 5px;
    }

    /* Regola base per tutti gli input e select - QUESTA È LA CHIAVE */
    .form-group input,
    .form-group select {
        width: 100%;
        padding: 5px;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        font-size: 14px;
        background-color: white;
    }

        .form-group input:focus,
        .form-group select:focus {
            outline: none;
            border-color: var(--secondary-color);
            box-shadow: 0 0 0 2px rgba(255, 102, 0, 0.2);
        }

/* Layout per input compositi (quantità, etc.) */
.quantity-input-group {
    display: flex;
    gap: 8px;
}

    .quantity-input-group input {
        flex: 1;
        min-width: 180px;
        max-width: none;
    }

    .quantity-input-group select {
        flex: 0 0 80px;
        width: 60px;
    }

.formFields {
    display: grid;
    row-gap: 8px;
    column-gap: 1rem;
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
    padding: 0 0px 10px 0;
    margin: 0;
}

.formFooter {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-shrink: 0;
    padding: 8px 0 5px 0;
    border-top: 1px solid var(--light-gray);
    background: white;
}

    .formFooter button {
        flex: 1;
        padding: 9px 16px;
    }

/* Rimuovo le regole duplicate di label e select che confliggevano */

button {
    grid-column: 1 / -1;
    padding: 12px 20px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
    width: 200px;
}

    button:hover {
        background-color: #e55c00;
    }

.button-group {
    display: flex;
    justify-content: center;
    gap: 20px;
    grid-column: 1 / -1;
    margin-top: 20px;
}

.button-secondary {
    background-color: var(--primary-color);
}

    .button-secondary:hover {
        background-color: #333;
    }

#searchButton {
    justify-self: center;
}

#orderButtonInline,
#orderButton {
    justify-self: flex-end;
}

#cartButton {
    justify-content: center;
}

/* Select2 customization */
.select2-container {
    width: 100% !important;
}

.select2-selection {
    height: 32px !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 4px !important;
}

.select2-results__option {
    font-size: 13px !important; /* NUOVA REGOLA */
    padding: 6px 8px !important; /* Opzionale: riduci anche il padding delle opzioni */
}

.select2-selection__placeholder {
    font-size: 13px !important; /* NUOVA REGOLA */
}

.select2-selection__rendered {
    line-height: 32px !important;
    padding-left: 7px !important;
    font-size: 13px !important;
}

.select2-selection__arrow {
    height: 30px !important;
}

/* Tabulator customization */
.tabulator {
    font-size: 14px !important;
    width: 100%;
    border: 1px solid var(--border-color);
    background-color: white;
    margin-bottom: 20px;
    overflow: hidden;
    height: 100% !important;
    min-height: 0;
}

.tabulator-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f5f5f5 !important;
    border-bottom: 2px solid var(--primary-color) !important;
}

.tabulator-col {
    background-color: #f5f5f5 !important;
    border-right: 1px solid var(--border-color) !important;
}

.tabulator-col-content {
    padding: 8px !important;
}

.tabulator-cell {
    padding: 8px !important;
    border-right: 1px solid var(--border-color) !important;
}

.tabulator-row {
    border-bottom: 1px solid var(--border-color) !important;
    min-height: 40px;
}

.row-odd {
    background-color: #f9f9f9 !important;
}

.row-even {
    background-color: white !important;
}

.tabulator-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background-color: #f8f8f8;
    border-top: 2px solid #ddd;
    padding: 5px;
    text-align: center;
    display: flex;
    align-items: center;
    min-height: 45px;
    width: 100%;
}

.tabulator-footer-contents {
    width: 100%;
}

.tabulator-footer div {
    padding: 8px 0;
}

.tabulator-paginator {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 5px;
}

    .tabulator-paginator button {
        color: black;
        width: fit-content;
    }

.tabulator-page-size {
    width: 70px !important;
    margin-right: 10px;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.tabulator-pages {
    display: inline-flex;
    margin: 0 10px;
}

.tabulator-page {
    margin: 2px;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    background-color: white;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s ease;
}

    .tabulator-page.active {
        background-color: var(--primary-color);
        color: var(--secondary-color) !important;
    }

    .tabulator-page:hover:not(.active) {
        background-color: #f0f0f0;
    }

/* Page jump controls */
.page-jump {
    display: inline-flex;
    align-items: center;
    margin-left: 10px;
}

    .page-jump input {
        width: 50px;
        padding: 4px;
        margin: 0 5px;
        border: 1px solid var(--border-color);
        border-radius: 3px;
        text-align: center;
    }

    .page-jump button {
        padding: 4px 8px;
        margin: 0;
        width: auto;
    }

/* Stile per i trattamenti */
.trattamentoCell {
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 3px;
    background-color: #f0f0f0;
    display: inline-block;
    min-width: 40px;
    text-align: center;
}

.tabulator-placeholder {
    padding: 20px;
    text-align: center;
    color: #999;
}

.results {
    display: flex;
    flex-direction: column;
    background-color: white;
    height: 100%;
    min-height: 0;
    margin-top: 0;
}

.results-header {
    color: var(--primary-color);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.results-table,
#resultsContainer {
    position: relative;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    height: auto;
    max-height: none;
    margin-top: 0;
    margin-bottom: 0;
    transition: height 0.3s ease;
}

.tabulator-tableHolder {
    overflow: auto !important;
    margin-bottom: 0 !important;
}

/* Footer 
footer {
    background-color: var(--primary-color);
    color: white;
    padding: 20px 0;
    margin-top: 40px;
}

    footer .container {
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    footer button {
        padding: 8px 12px !important;
        font-size: 12px !important;
        width: auto !important;
        margin: 0 5px !important;
    }

    footer .footer-buttons {
        display: flex;
        gap: 10px;
    }
*/


/* Stili per il Carrello */
.cart-button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: bold;
}

    .cart-button:hover {
        background-color: #e55c00;
    }

.cart-count {
    background-color: white;
    color: var(--secondary-color);
    border-radius: 10px;
    width: fit-content;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    padding: 10px;
    max-width: 50%;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Modal del carrello */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 20px;
    border-radius: 5px;
    width: 80%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.close-modal {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--dark-gray);
}

    .close-modal:hover {
        color: var(--secondary-color);
    }

.cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

    .cart-table th {
        background-color: var(--light-gray);
        padding: 10px;
        text-align: left;
        border-bottom: 2px solid var(--primary-color);
    }

    .cart-table td {
        padding: 10px;
        border-bottom: 1px solid var(--border-color);
    }

.cart-empty {
    text-align: center;
    padding: 20px;
    color: var(--dark-gray);
}

.cart-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.cart-total {
    font-weight: bold;
    font-size: 1.2rem;
}

.quantity-controls {
    display: flex;
    align-items: center;
}

    .quantity-controls button {
        background-color: var(--light-gray);
        color: var(--dark-gray);
        border: 1px solid var(--border-color);
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        margin: 0;
        user-select: none !important;
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
    }

    .quantity-controls input {
        width: 50px;
        height: 30px;
        text-align: center;
        border: 1px solid var(--border-color);
    }

    .quantity-controls button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        background-color: #f0f0f0;
    }

.remove-from-cart {
    background-color: #ff3b30;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
}

    .remove-from-cart:hover {
        background-color: #d63028;
    }

.quantity-cell {
    display: flex;
    align-items: center;
    gap: 5px;
}

    .quantity-cell input {
        width: 60px;
        padding: 4px;
        text-align: center;
        border: 1px solid var(--border-color);
        border-radius: 4px;
    }

.add-to-cart {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
}

    .add-to-cart:hover {
        background-color: #e55c00;
    }

/* Classe per riga non disponibile */
.row-no-stock {
    background-color: #fff0f0 !important;
}

/* Stile per il messaggio di articolo non disponibile */
.no-stock-message {
    color: #cc0000;
    font-weight: bold;
    font-style: italic;
    padding: 5px;
    background-color: #fff0f0;
    border-radius: 4px;
    display: inline-block;
}


.welcome-message {
    color: #f1f1f1;
    font-weight: 600;
    font-size: 1.1rem;
    margin-right: 20px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

#usernameDisplay {
    color: #f1f1f1;
    margin-left: 6px;
    font-weight: 700;
}

/* MODAL LOGIN - SEMPRE VISIBILE (desktop + mobile) */
.login-modal {
    max-width: 380px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    overflow: hidden;
    animation: popIn 0.3s ease-out;
}

.login-header {
    background: linear-gradient(135deg, #333, #ff6600);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .login-header h2 {
        margin: 0;
        font-size: 1.4rem;
    }

.close-modal {
    font-size: 1.6rem;
    cursor: pointer;
    opacity: 0.9;
}

.login-form {
    padding: 30px 24px 24px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.input-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

    .input-wrapper input {
        width: 100%;
        max-width: 100%;
        padding: 14px 14px 14px 44px;
        border: 2px solid #ddd;
        border-radius: 10px;
        font-size: 1rem;
        box-sizing: border-box; /* <-- CHIAVE! */
        transition: all 0.3s;
    }

        .input-wrapper input:focus {
            outline: none;
            border-color: #3498db;
            box-shadow: 0 0 0 4px rgba(52,152,219,0.15);
        }

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #95a5a6;
    font-size: 1.1rem;
}

.login-btn {
    width: 100%;
    margin-top: 10px;
    padding: 14px;
    background: #ff6600;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s;
}

    .login-btn:hover {
        transform: translateY(-2px);
    }

    .login-btn:active {
        transform: translateY(0);
    }

.error-msg {
    margin: 0;
    text-align: center;
    color: #e74c3c;
    font-size: 0.9rem;
    min-height: 22px;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* FORZA IL CENTRAMENTO DEL FORM */
.login-form {
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
}


/* Media Queries */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: minmax(280px, auto) minmax(0, 1fr);
        gap: 15px;
        height: calc(100vh - 100px);
    }

    .left-column {
        min-width: 280px;
        max-width: 380px;
    }

    .formFields {
        grid-template-columns: 1fr;
    }
}

/* Media query per tablet */
@media (max-width: 900px) {
    .container {
        grid-template-columns: minmax(250px, auto) minmax(0, 1fr);
        gap: 10px;
        height: calc(100vh - 100px);
    }

    .left-column {
        min-width: 250px;
        max-width: 320px;
    }

    .search-section {
        padding: 10px 0;
        margin: 0 0 10px 0;
    }

    .image-section {
        padding: 10px;
    }
}

@media (max-width: 768px) {
    body {
        display: block;
    }

    .containershop {
        grid-template-columns: 1fr; /* Singola colonna su mobile */
        height: auto;
        overflow: visible;
        display: flex; /* Cambia da grid a flex per controllare meglio l'ordine */
        flex-direction: column; /* Dispone gli elementi in colonna */
    }

    .left-column {
        height: auto;
        max-height: none; /* Rimuovi il limite di altezza */
        order: 1; /* Filtri in alto */
        margin: 0.75rem 0 0.5rem 0;
        display: flex;
        flex-direction: column;
    }

    .right-column {
        height: auto;
        overflow: visible;
        order: 2; /* Risultati sotto i filtri */
        margin: 0.5rem 0 0.75rem 0;
    }

    /* Mostra l'immagine e mettila per prima */
    .image-section {
        display: block !important; /* Sovrascrivi il display: none */
        order: -1; /* Metti l'immagine prima del form */
        padding: 10px 15px;
        max-height: 150px;
        flex-shrink: 0;
    }

    .chain-diagram {
        max-height: 130px;
        width: auto;
        object-fit: contain;
    }

    .search-section {
        max-height: none; /* Permetti che si espanda */
        overflow-y: visible;
    }

    .results {
        height: auto;
        min-height: 400px;
    }

    #resultsContainer {
        flex: none;
        min-height: 400px;
        height: 400px;
    }

    .tabulator {
        height: 400px !important;
    }

    /* Nascondi l'immagine del diagramma su mobile
    .image-section {
        display: none;
    } */

    .welcome-message {
        font-size: 0.95rem;
        margin-right: 10px;
    }

    .header-right {
        flex-wrap: wrap;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .containershop {
        padding: 0 0px; /* Riduci il padding laterale */
    }

    .left-column,
    .right-column {
        margin: 0.5rem 0;
        padding: 0.5rem;
    }

    .formFooter button {
        padding: 10px 12px;
        font-size: 14px;
    }

    .modal-content {
        width: 95%;
        margin: 20px auto;
        padding: 15px;
    }
}

/* Aggiungi questa media query per dispositivi in orientamento orizzontale */
@media (max-width: 900px) and (max-height: 600px) and (orientation: landscape) {
    .left-column {
        display: grid;
        grid-template-rows: 1fr auto;
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
    }

    .search-section {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        max-height: none;
    }

    .image-section {
        flex-shrink: 0;
        max-height: 80px;
        padding: 5px;
        overflow: hidden;
    }

    .chain-diagram {
        max-height: 70px;
        width: auto;
        object-fit: contain;
    }

    .formFields {
        row-gap: 6px;
    }

    .form-group label {
        font-size: 13px;
        margin-bottom: 1px;
    }

    .form-group input,
    .form-group select {
        padding: 4px;
        font-size: 13px;
    }

    .formFooter {
        padding: 6px 0 4px 0;
        margin-top: 8px;
    }

        .formFooter button {
            padding: 7px 12px;
            font-size: 13px;
        }
}

/* Per schermi molto piccoli in landscape */
@media (max-width: 768px) and (max-height: 450px) and (orientation: landscape) {
    .image-section {
        max-height: 60px;
        padding: 3px;
    }

    .chain-diagram {
        max-height: 50px;
    }

    .formFields {
        row-gap: 4px;
    }

    .form-group {
        margin-bottom: 0;
    }
}

/* Nascondi l'immagine su dispositivi mobili */
@media (max-width: 900px) {
    .image-section {
        display: none;
    }
}
