* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f5;
    color: #333;
}

.header {
    background: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 400px;
    margin: 2rem auto;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #27ae60;
    color: white;
}

.btn-secondary:hover {
    background: #219a52;
}

.btn-outline {
    background: transparent;
    border: 2px solid #3498db;
    color: #3498db;
}

.btn-outline:hover {
    background: #3498db;
    color: white;
}

.btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
}

.status {
    font-weight: 600;
}

.status.online {
    color: #27ae60;
}

.status.offline {
    color: #e74c3c;
}

.actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.clients-container {
    background: white;
    border-radius: 8px;
    padding: 1rem;
}

.loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.clients-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.client-card {
    border: 1px solid #ecf0f1;
    border-radius: 8px;
    padding: 1.5rem;
    background: #f8f9fa;
    cursor: pointer;
}

.client-card h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.client-card p {
    margin: 0.5rem 0;
    color: #555;
}

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #e74c3c;
    color: white;
    padding: 10px;
    text-align: center;
    font-weight: bold;
}

.demo-credentials {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #3498db;
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .clients-list {
        grid-template-columns: 1fr;
    }
}

/* Stili per la barra di ricerca */
.search-container {
    margin-bottom: 2rem;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
    scroll-margin-top: 20px;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.search-input::placeholder {
    color: #999;
}

.search-results {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

/* Miglioramenti responsive */
@media (max-width: 768px) {
    .search-input {
        font-size: 16px; /* Previene zoom su iOS */
        padding: 14px 16px; /* Più grande per mobile */
    }
}

/* Stili per la pagina di dettaglio cliente */
.client-detail {
    padding: 0;
    height: calc(100dvh - 80px);
}

.client-layout {
    display: flex;
    height: 100%;
}

/* Header migliorato */
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    padding: 0.5rem 1rem;
}

/* Menu laterale - SEMPRE VISIBILE A SINISTRA */
.client-menu {
    width: 300px;
    min-width: 280px; /* Larghezza minima */
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    padding: 1rem;
    overflow-y: auto;
    flex-shrink: 0; /* Impedisce al menu di restringersi */
}

.menu-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.menu-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #3498db;
}

.menu-icon {
    width: 40px;
    height: 40px;
    background: #3498db;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.menu-text h3 {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    color: #2c3e50;
}

.menu-text p {
    margin: 0;
    font-size: 0.8rem;
    color: #6c757d;
}

/* Contenuto principale - ADATTATIVO */
.client-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    min-width: 0; /* Permette al contenuto di restringersi */
}

.client-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.client-header h2 {
    color: #2c3e50;
    margin: 0;
}

.client-actions {
    display: flex;
    gap: 1rem;
}

/* Griglia informazioni */
.client-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.info-section {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
}

.info-section.full-width {
    grid-column: 1 / -1;
}

.info-section h3 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-section h3 i {
    color: #3498db;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item label {
    font-weight: 600;
    color: #6c757d;
    font-size: 0.9rem;
}

.info-item span {
    color: #2c3e50;
    font-size: 1rem;
}

/* Indirizzi */
.address-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.address-item h4 {
    margin: 0 0 0.5rem 0;
    color: #495057;
    font-size: 1rem;
}

.address-item p {
    margin: 0;
    color: #6c757d;
    line-height: 1.5;
}

/* RESPONSIVE - MANTIENI MENU A SINISTRA */
@media (max-width: 1200px) {
    .client-menu {
        width: 250px;
        min-width: 250px;
    }
    
    .menu-text h3 {
        font-size: 0.85rem;
    }
    
    .menu-text p {
        font-size: 0.75rem;
    }
}

@media (max-width: 1024px) {
    .client-menu {
        width: 220px;
        min-width: 220px;
    }
    
    .client-content {
        padding: 1.5rem;
    }
    
    .client-info-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .menu-card {
        padding: 0.75rem;
    }
    
    .menu-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .client-layout {
        height: auto;
        min-height: calc(100dvh - 80px);
    }
    
    .client-menu {
        width: 200px;
        min-width: 200px;
    }
    
    .client-content {
        padding: 1rem;
    }
    
    .client-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .client-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .address-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .menu-cards {
        gap: 0.5rem;
    }
    
    .menu-card {
        padding: 0.6rem;
        gap: 0.75rem;
    }
    
    .menu-text h3 {
        font-size: 0.8rem;
    }
    
    .menu-text p {
        font-size: 0.7rem;
    }
}

@media (max-width: 640px) {
    .client-layout {
        flex-direction: column;
        height: auto;
    }
    
    .client-menu {
        width: 100%;
        min-width: auto;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
        padding: 0.75rem;
        overflow-x: auto;
    }
    
    .menu-cards {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .menu-card {
        min-width: 160px;
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .menu-text h3 {
        font-size: 0.8rem;
        margin-bottom: 0.1rem;
    }
    
    .menu-text p {
        font-size: 0.7rem;
    }
    
    .client-content {
        padding: 1rem;
    }
}

/* Scrollbar personalizzata per il menu */
.client-menu::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.client-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.client-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.client-menu::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Stili per schermi molto piccoli */
@media (max-width: 480px) {
    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .back-btn {
        align-self: flex-start;
    }
    
    .client-menu {
        padding: 0.5rem;
    }
    
    .menu-card {
        min-width: 140px;
        padding: 0.5rem;
    }
    
    .menu-icon {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .client-content {
        padding: 0.75rem;
    }
    
    .info-section {
        padding: 1rem;
    }
}

/* Assicurati che il layout non si rompa */
.client-layout {
    display: flex;
}

.client-menu {
    position: sticky;
    top: 0;
    height: 100%;
    max-height: calc(100dvh - 80px);
}

/* Per evitare problemi di overflow su mobile */
@media (max-width: 640px) {
    .client-menu {
        position: relative;
        height: auto;
        max-height: none;
    }
    
    .menu-cards {
        flex-wrap: nowrap;
    }
}

/* Variante compatta per menu su schermi piccoli */
@media (max-width: 640px) {
    .menu-card.compact {
        min-width: 120px;
    }
    
    .menu-card.compact .menu-text h3 {
        font-size: 0.75rem;
    }
    
    .menu-card.compact .menu-text p {
        display: none; /* Nascondi la descrizione su mobile molto piccolo */
    }
}

/* Alternativa: menu icon-only su schermi molto piccoli */
@media (max-width: 480px) {
    .products-list-container {
        height: calc(100dvh - 160px); /* Ancora più compatto su schermi piccoli */
        overflow-y: auto;  /* Assicurati che sia auto o scroll */
        -webkit-overflow-scrolling: touch; /* Per fluidità su iOS */
    }

    .menu-card.icon-only {
        min-width: 60px;
        padding: 0.5rem;
    }
    
    .menu-card.icon-only .menu-text {
        display: none;
    }
    
    .menu-card.icon-only .menu-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
}

/* Stili per la pagina nuovo ordine */
.order-detail {
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Intestazione ordine */
.order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    gap: 2rem;
}

.order-client-info h2 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
}

.order-client-info p {
    margin: 0 0 1rem 0;
    color: #6c757d;
}

.destination-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.destination-selector label {
    font-weight: 600;
    color: #495057;
}

.destination-selector select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.order-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1rem;
}

.total-amount {
    text-align: right;
}

.total-amount h3 {
    margin: 0 0 0.5rem 0;
    color: #6c757d;
    font-size: 1rem;
}

.amount {
    font-size: 1.5rem;
    font-weight: bold;
    color: #27ae60;
}

.confirm-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

/* Tabs prodotti */
.product-tabs {
    display: flex;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
}

.tab-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.tab-btn:first-child {
    border-radius: 8px 0 0 0;
}

.tab-btn:last-child {
    border-radius: 0 8px 0 0;
}

.tab-btn.active {
    background: #3498db;
    color: white;
}

.tab-btn:not(.active):hover {
    background: #e9ecef;
}

/* Lista prodotti */
.order-products {
    background: white;
    border: 1px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin-bottom: 1.5rem;
}

.products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.products-header h3 {
    margin: 0;
    color: #2c3e50;
}

.products-count {
    color: #6c757d;
    font-weight: 600;
}

.products-table-container {
    overflow-x: auto;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
}

.products-table th {
    background: #f8f9fa;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap;
}

.products-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.products-table tbody tr:hover {
    background: #f8f9fa;
}

/* Input nella tabella */
.table-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
}

.table-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

/* Colonna prodotto */
.product-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.product-image {
    width: 40px;
    height: 40px;
    background: #e9ecef;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

.product-details h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    color: #2c3e50;
}

.product-details .product-code {
    margin: 0;
    font-size: 0.8rem;
    color: #6c757d;
}

/* Colonna prezzi */
.price-cell {
    text-align: right;
    font-weight: 600;
    color: #2c3e50;
}

.discounted-price {
    color: #27ae60;
}

/* Azioni */
.actions-cell {
    text-align: center;
}

.remove-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-btn:hover {
    background: #c0392b;
}

/* Stato vuoto */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #dee2e6;
}

.empty-state h4 {
    margin: 0 0 0.5rem 0;
    color: #6c757d;
}

.empty-state p {
    margin: 0;
}

/* Footer ordine */
.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    position: sticky;
    bottom: 1rem;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.footer-total {
    font-size: 1.25rem;
}

.footer-actions {
    display: flex;
    gap: 1rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .order-header {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .order-summary {
        align-items: stretch;
        width: 100%;
    }
    
    .total-amount {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .order-detail {
        padding: 0.5rem;
    }
    
    .order-header,
    .order-products,
    .order-footer {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .product-tabs {
        border-radius: 0;
    }
    
    .products-table {
        font-size: 0.8rem;
    }
    
    .products-table th,
    .products-table td {
        padding: 0.5rem;
    }
    
    .table-input {
        font-size: 0.8rem;
        padding: 0.25rem;
    }
    
    .order-footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .footer-actions {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .product-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        border-radius: 0 !important;
    }
    
    .products-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

/* Modale */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 2dvh auto; /* 2% di margine verticale */
    border-radius: 8px;
    width: 100%;
    max-width: 800px;
    height: 90dvh; /* <--- FISSA l'altezza al 90% del viewport */
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
    overflow: hidden; /* <--- Impedisce che il contenuto "esca" dai bordi arrotondati */
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.large-modal {
    max-width: 1000px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0.5rem;
}

.modal-close:hover {
    color: #495057;
}

.modal-body {
    padding: 1.5rem; /* Riaggiungi il padding qui per il form */
    flex: 1;
    overflow-y: auto; /* <--- IMPORTANTE: abilita lo scroll qui */
    display: block;   /* Rimuovi flex se non serve per il layout interno */
}

/* Barra di ricerca modale */
.search-box {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    width: 100%;
    background: white;
    padding: 0px 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
    gap: 10px; /* Spazio tra lente e input */
    min-height: 50px;
}

.search-box i.fa-magnifying-glass {
    flex-shrink: 0;          /* Impedisce alla lente di rimpicciolirsi */
    margin-right: 10px;      /* Distanza dall'input */
    width: 20px;             /* Larghezza fissa per allineamento */
    text-align: center;
}

#productSearch {
    width: 100%;
    border: none !important; /* Rimuovi bordi interni se il box ha già il bordo */
    padding: 10px 35px 10px 0; /* Spazio a destra per la X */
    font-size: 16px;
    outline: none;
    background: transparent;
}

/* Lista prodotti modale */
.products-list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* IMPORTANTE per Safari */
    overflow-y: auto;  /* Assicurati che sia auto o scroll */
    -webkit-overflow-scrolling: touch; /* Per fluidità su iOS */
}

.products-list-header {
    flex-shrink: 0; /* Fissa l'header */
}

.products-list {
    flex: 1;
    overflow-y: auto; /* Scrolling solo nella lista */
    -webkit-overflow-scrolling: touch; /* Smooth scroll su iOS */
    min-height: 0; /* IMPORTANTE per Safari */
}

/* Scrollbar personalizzata per la lista */
.products-list::-webkit-scrollbar {
    width: 6px;
}

.products-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.products-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.products-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.product-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f3f4;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.product-list-item:hover {
    background-color: #f8f9fa;
}

.product-list-item:last-child {
    border-bottom: none;
}

.product-list-info h4 {
    margin: 0 0 0.25rem 0;
    color: #2c3e50;
    font-size: 1rem;
}

.product-code {
    margin: 0 0 0.25rem 0;
    color: #6c757d;
    font-size: 0.85rem;
}

.product-desc2 {
    margin: 0 0 0.5rem 0;
    color: #495057;
    font-size: 0.9rem;
}

.product-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.product-list-arrow {
    color: #6c757d;
}

/* Dettaglio prodotto */
.product-details {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.back-btn {
    background: none;
    border: none;
    color: #3498db;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-btn:hover {
    color: #2980b9;
}

.detail-header h3 {
    margin: 0;
    color: #2c3e50;
}

.product-info-card {
    background: #f8f9fa;
    margin: 1rem 1.5rem;
    padding: 1.5rem;
    border-radius: 8px;
    flex-shrink: 0;
}

.product-info-card h4 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
}

.product-info-card p {
    margin: 0 0 1rem 0;
    color: #495057;
}

.product-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.meta-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e9ecef;
}

.meta-item:last-child {
    border-bottom: none;
}

.meta-item label {
    font-weight: 600;
    color: #6c757d;
    font-size: 0.9rem;
}

.meta-item span {
    color: #2c3e50;
    font-weight: 500;
}

/* Input prodotto */
.product-inputs {
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #495057;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.input-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.discount-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

/* Riepilogo prezzi */
.price-summary {
    width: 50%;
    background: white;
    margin: 1rem 1.5rem;
    padding: 1.5rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    flex-shrink: 0;
}

.price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f3f4;
}

.price-item:last-child {
    border-bottom: none;
}

.price-item.total {
    font-weight: bold;
    font-size: 1.1rem;
    color: #2c3e50;
    border-top: 2px solid #e9ecef;
    margin-top: 0.5rem;
    padding-top: 1rem;
}

.price-item label {
    color: #6c757d;
}

.discounted {
    color: #27ae60;
    font-weight: 600;
}

/* Azioni dettaglio */
.detail-actions {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}

/* Errori modale */
.modal-error {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #6c757d;
}

.modal-error i {
    font-size: 3rem;
    color: #e74c3c;
    margin-bottom: 1rem;
}

/* Toast notification
.toast-notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: #27ae60;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1001;
    animation: slideInRight 0.3s ease;
} */
.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive modale */
@media (max-width: 480px) {
    .products-list-container {
        height: calc(100dvh - 180px); /* Più compatto su mobile */
        overflow-y: auto;  /* Assicurati che sia auto o scroll */
        -webkit-overflow-scrolling: touch; /* Per fluidità su iOS */
    }

    .modal-content {
        margin: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .large-modal {
        max-width: 100%;
    }
    
    .discount-inputs {
        grid-template-columns: 1fr;
    }
    
    .product-meta-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-actions {
        flex-direction: column;
        gap: 1rem;
    }
    
    .detail-actions button {
        width: 100%;
    }
}

/* Menu di Navigazione Principale */
.main-nav {
    background: white;
    border-bottom: 1px solid #e9ecef;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    min-width: 0;
}

.nav-btn:hover {
    background: #f8f9fa;
    color: #495057;
}

.nav-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: #f8f9fa;
}

.nav-btn i {
    font-size: 1.25rem;
}

.nav-btn span {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Sezioni */
.section {
    display: none;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section.active {
    display: block;
}

.section-header {
    margin-bottom: 1.5rem;
}

.section-header h2 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
}

/* Tabs Ordini/Preventivi */
.order-tabs {
    display: flex;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.order-tab-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    color: #6c757d;
    font-weight: 600;
}

.order-tab-btn:hover {
    background: #e9ecef;
}

.order-tab-btn.active {
    background: #3498db;
    color: white;
}

.badge {
    background: #e74c3c;
    color: white;
    border-radius: 12px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.order-tab-btn.active .badge {
    background: rgba(255, 255, 255, 0.3);
}

/* Contenuto Tabs */
.order-tab-content {
    display: none;
}

.order-tab-content.active {
    display: block;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #e9ecef;
}

.tab-header h3 {
    margin: 0;
    color: #2c3e50;
}

/* Lista Ordini */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.order-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.order-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #3498db;
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.order-info h4 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
}

.order-meta {
    display: flex;
    gap: 1rem;
    color: #6c757d;
    font-size: 0.9rem;
}

.order-amount {
    font-size: 1.25rem;
    font-weight: bold;
    color: #27ae60;
}

.order-actions {
    display: flex;
    gap: 0.5rem;
}

/* Filtri Scadenze */
.scadenze-filters {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
}

.filter-group select,
.filter-group input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 150px;
}

/* Lista Scadenze */
.scadenze-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.scadenza-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scadenza-item.scaduta {
    border-left: 4px solid #e74c3c;
    background: #fff5f5;
}

.scadenza-item.oggi {
    border-left: 4px solid #f39c12;
    background: #fffaf0;
}

.scadenza-item.prossima {
    border-left: 4px solid #3498db;
}

.scadenza-info h4 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
}

.scadenza-meta {
    display: flex;
    gap: 1rem;
    color: #6c757d;
    font-size: 0.9rem;
}

.scadenza-amount {
    font-size: 1.25rem;
    font-weight: bold;
}

.scadenza-actions {
    display: flex;
    gap: 0.5rem;
}

/* Riepilogo Scadenze */
.scadenze-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.summary-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}

.summary-card h4 {
    margin: 0 0 1rem 0;
    color: #6c757d;
    font-size: 0.9rem;
}

.amount {
    font-size: 1.5rem;
    font-weight: bold;
}

.amount.negative {
    color: #e74c3c;
}

.amount.warning {
    color: #f39c12;
}

.amount.info {
    color: #3498db;
}

.amount.positive {
    color: #27ae60;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: wrap;
    }
    
    .nav-btn {
        flex: 1 0 50%;
        padding: 0.75rem 0.5rem;
    }
    
    .nav-btn span {
        font-size: 0.8rem;
    }
    
    .order-tabs {
        flex-direction: column;
    }
    
    .scadenze-filters {
        flex-direction: column;
        gap: 1rem;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-group select,
    .filter-group input {
        width: 100%;
    }
    
    .tab-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .order-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .scadenza-item {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .scadenze-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .section {
        padding: 1rem;
    }
    
    .nav-btn {
        flex: 1 0 100%;
    }
    
    .order-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Badge offline */
.offline-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #f39c12;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 1rem;
}

.offline-badge i {
    font-size: 0.8rem;
}

/* Messaggi di errore migliorati */
.error-message {
    text-align: center;
    padding: 3rem 2rem;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.error-message i {
    font-size: 3rem;
    color: #e74c3c;
    margin-bottom: 1rem;
}

.error-message h3 {
    color: #2c3e50;
    margin-bottom: 2rem;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.offline-warning {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    color: #856404;
}

/* Stato vuoto per dati mancanti */
.empty-data {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

.empty-data i {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #dee2e6;
}

.weight-cell {
    text-align: right;
    font-family: monospace;
    font-size: 14px;
    color: #666;
}

.product-weight-info {
    margin-top: 5px;
    font-size: 12px;
    color: #888;
}

/* PARTE ADMIN */
.admin-section {
    display: none;
    padding: 20px;
}

.admin-section.active {
    display: block;
}

.users-list {
    margin-top: 20px;
}

.user-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.user-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 5px;
}

.user-details {
    color: #666;
    font-size: 14px;
}

.user-email {
    color: #007bff;
}

.user-role {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-admin {
    background: #d4edda;
    color: #155724;
}

.role-agente {
    background: #cce5ff;
    color: #004085;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.admin-filters {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

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

.filter-group label {
    font-size: 14px;
    font-weight: 600;
}

.reports-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.report-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

/* Stili aggiuntivi per preventivi/offerte */
.type-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-left: 10px;
    vertical-align: middle;
}

.type-badge.quote {
    background-color: #3498db;
    color: white;
}

.type-badge.offer {
    background-color: #9b59b6;
    color: white;
}

/* Stile per la lista preventivi/offerte nella pagina principale */
.quote-item, .offer-item {
    border-left: 4px solid;
    padding-left: 10px;
}

.quote-item {
    border-left-color: #3498db;
}

.offer-item {
    border-left-color: #9b59b6;
}

.quote-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
}

.status-pending {
    background-color: #f39c12;
    color: white;
}

.status-synced {
    background-color: #2ecc71;
    color: white;
}

.status-error {
    background-color: #e74c3c;
    color: white;
}
/* Stili per preventivi/offerte */
.quote-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.quote-type-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 8px;
    vertical-align: middle;
}

.quote-type-badge.type-quote {
    background-color: #3498db;
    color: white;
}

.quote-type-badge.type-offer {
    background-color: #9b59b6;
    color: white;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-filter input {
    padding: 6px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

/* Stili per la modale nuovo cliente */
.client-form {
    padding: 10px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-group input:invalid:not(:focus):not(:placeholder-shown) {
    border-color: #dc3545;
}

.form-group input:valid:not(:focus):not(:placeholder-shown) {
    border-color: #28a745;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #6c757d;
}

.form-notes {
    margin-top: 20px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #007bff;
}

.form-notes p {
    margin: 0;
}

/* Responsive per mobile */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-group {
        flex: 0 0 100%;
    }
}

/* Messaggi di validazione */
.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.form-group.error input {
    border-color: #dc3545;
}

.form-group.error .error-message {
    display: block;
}

/* Loading per salvataggio */
#saveClientLoading {
    display: none;
    text-align: center;
    padding: 20px;
}

#saveClientLoading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Stili per clienti temporanei */
.temp-client {
    position: relative;
    border: 2px dashed #ffc107 !important;
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
    opacity: 0.95;
}

.temp-client:hover {
    border-color: #ff9800 !important;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(255, 193, 7, 0.2);
}

.temp-badge {
    display: inline-block;
    background: #ffc107;
    color: #333;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 10px;
    vertical-align: middle;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

.client-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.client-card-header h3 {
    margin: 0;
    flex: 1;
}

.client-card-body {
    padding: 10px 0;
}

.client-card-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 193, 7, 0.3);
    font-size: 12px;
}

.text-warning {
    color: #856404;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Overlay per clienti temporanei in dettaglio */
.temp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 193, 7, 0.1);
    z-index: 1;
    pointer-events: none;
    border-radius: 8px;
}

/* Indicatore nella lista */
.temp-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: #ffc107;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Tooltip per clienti temp */
.temp-tooltip {
    position: relative;
    display: inline-block;
}

.temp-tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
}

.temp-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.temp-tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* --- Stili per clienti BLOCCATI --- */

.blocked-client {
    position: relative;
    border: 2px solid #dc3545 !important; /* Linea continua per trasmettere rigidità */
    background: linear-gradient(135deg, #fff5f5 0%, #fde8e8 100%);
    opacity: 0.95;
}

.blocked-client:hover {
    border-color: #bd2130 !important;
    background: linear-gradient(135deg, #fde8e8 0%, #f8d7da 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(220, 53, 69, 0.2);
}

.blocked-badge {
    display: inline-block;
    background: #dc3545;
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 10px;
    vertical-align: middle;
    text-transform: uppercase;
}

.blocked-footer {
    border-top: 1px solid rgba(220, 53, 69, 0.3) !important;
}

.text-danger {
    color: #a71d2a;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

/* Indicatore circolare rosso (in alto a destra) */
.blocked-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 10px;
    height: 10px;
    background: #dc3545;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(220, 53, 69, 0.5);
}

/* Overlay specifico per dettaglio bloccato */
.blocked-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(220, 53, 69, 0.05);
    z-index: 1;
    pointer-events: none;
    border-radius: 8px;
}

/* Badge rosso nel titolo del dettaglio */
.blocked-badge-detail {
    background-color: #dc3545;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.5em; /* Più piccolo rispetto al nome */
    vertical-align: middle;
    margin-left: 15px;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Feedback visivo per il menu se il cliente è bloccato */
.client-is-blocked .menu-card:nth-child(-n+3) {
    border-left: 4px solid #dc3545;
    opacity: 0.7;
    position: relative;
}

.client-is-blocked .menu-card:nth-child(-n+3):hover {
    cursor: not-allowed;
    background-color: #fff5f5;
    transform: none; /* Rimuove l'animazione di hover per dare senso di blocco */
}

/* Icona di lucchetto opzionale sulle azioni bloccate */
.client-is-blocked .menu-card:nth-child(-n+3)::after {
    content: '\f023'; /* Icona lock di FontAwesome */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 10px;
    right: 10px;
    color: #dc3545;
    font-size: 14px;
}

/* Nota sulla riga */
.product-notes {
    margin: 1rem 1.5rem;
}

.product-notes .input-group {
    display: flex;
    flex-direction: column;
}

.product-notes textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: none; /* Impedisce di allargare il box a mano rompendo il layout */
    min-height: 80px;
    transition: border-color 0.2s;
}

.product-notes textarea:focus {
    outline: none;
    border-color: #2c3e50;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.product-notes label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

/* Stili per il popup note */
.notes-container {
    max-width: 600px;
    margin: 0 auto;
}

.notes-container .input-group {
    margin-bottom: 20px;
}

.notes-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.notes-container label small {
    font-weight: normal;
    color: #666;
    margin-left: 5px;
}

.notes-container textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.3s;
}

.notes-container textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.char-counter {
    text-align: right;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

/* Note precedenti */
.previous-note-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
}

.note-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.note-date {
    color: #6c757d;
    font-size: 14px;
}

.note-order-number {
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.note-content {
    margin-top: 10px;
}

.note-content strong {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}

.note-content p {
    margin: 0 0 10px 0;
    color: #495057;
    font-size: 14px;
    line-height: 1.5;
}

.btn-small {
    padding: 4px 12px;
    font-size: 12px;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.btn-small i {
    margin-right: 4px;
}

/* Stile per il container destinazione + note */
.destination-notes-container {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .destination-notes-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .destination-notes-container .btn {
        align-self: flex-start;
    }
}

/* Correzione dimensioni modale e spazi */
#notesModal .modal-content {
    max-width: 600px;
    width: 90%;
    margin: 30px auto;
    /* Rimuove l'altezza fissa se presente e permette alla modale di adattarsi al contenuto */
    height: auto; 
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
}

/* Gestione dello scroll interno se il contenuto è lungo */
#notesModal .modal-body {
    overflow-y: auto;
    padding: 20px;
}

/* Centratura e spaziatura del tasto Salva */
#notesModal .modal-footer {
    display: flex;
    justify-content: center; /* Centra il contenuto orizzontalmente */
    padding: 20px;          /* Spazio intorno al bottone */
    padding-bottom: 30px;   /* Spazio extra sotto il bottone */
    border-top: 1px solid #eee;
}

/* Rimuovi margini eccessivi dai container interni */
.notes-container {
    max-width: 100%;
}

.notes-container .input-group:last-child {
    margin-bottom: 0;
}

/* Modale per l'ADMIN */
/* Sfondo oscurato */
.modal-overlay-admin {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Oscura il resto della pagina */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Contenitore della modale */
.modal-content-admin {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    max-height: 90dvh;
    overflow-y: auto; /* Permette lo scroll se il form è lungo */
}

.modal-header-admin {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

.form-group-admin {
    margin-bottom: 15px;
}

.form-group-admin label {
    display: block;
    margin-bottom: 5px;
}

.form-group-admin input, .form-group select {
    width: 100%;
    padding: 8px;
    box-sizing: border-box; /* Evita che l'input esca dai bordi */
}

/* Stili per il bottone di ricerca admin */
#adminDateFilterBtn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    margin-top: 24px; /* Allinea con i campi data */
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
}

#adminDateFilterBtn:hover {
    background: #2980b9;
}

#adminDateFilterBtn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

#adminDateFilterBtn i {
    font-size: 14px;
}

/* Responsive per admin filters */
@media (max-width: 768px) {
    .admin-filters {
        flex-direction: column;
        gap: 15px;
    }
    
    #adminDateFilterBtn {
        margin-top: 0;
        width: 100%;
        justify-content: center;
    }
}

/* PAGINAZIONE */
.pagination-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.pagination-info {
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 600;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    color: #495057;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

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

.pagination-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
}

.page-number {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: #495057;
    transition: all 0.2s ease;
}

.page-number:hover:not(.active) {
    background: #e9ecef;
    border-color: #adb5bd;
}

.page-number.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.page-number.ellipsis {
    background: transparent;
    border: none;
    cursor: default;
    min-width: auto;
}

.pagination-limit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-limit label {
    font-size: 0.9rem;
    color: #6c757d;
}

.pagination-limit select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .pagination-container {
        padding: 1rem;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .page-number {
        min-width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .pagination-limit {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Stili specifici per email */
.email-sent {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.email-sent:hover {
    background-color: #c3e6cb;
    border-color: #b1dfbb;
}

.email-failed {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.email-failed:hover {
    background-color: #f5c6cb;
    border-color: #f1b0b7;
}
/* Stili per la validazione */
.form-group-admin.error input {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-group-admin.success input {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.validation-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}
.stepper-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-btn {
    width: 40px;
    height: 40px;
    font-size: 22px;
    font-weight: bold;
    border-radius: 8px;
    border: 1px solid var(--border-color, #ccc);
    background: var(--btn-bg, #f5f5f5);
    cursor: pointer;
    touch-action: manipulation;
}

.step-btn:active {
    transform: scale(0.95);
}

.stepper-control input[type="number"] {
    text-align: center;
    width: 70px;
    font-size: 18px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    flex-grow: 1;
}

.search-wrapper input {
    width: 100%;
    padding-right: 40px; /* Spazio per il bottone */
}

.search-clear-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    /*padding: 5px;*/
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    transition: all 0.2s;
}

.search-clear-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.search-clear-btn i {
    font-size: 16px;
}

.search-clear-btn-admin {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    transition: all 0.2s;
}

.search-clear-bt-admin i {
    font-size: 16px;
}

/* Per il search-box dei prodotti che ha già un'icona */
.search-box .search-wrapper input {
    padding-left: 35px; /* Spazio per l'icona di ricerca */
}

.search-box .search-clear-btn .search-clear-bt-admin {
    right: 30px;
}

/* Breadcrumb navigation */
.breadcrumb-nav {
    background-color: #f8f9fa;
    padding: 10px 20px;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 20px;
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    margin-bottom: 0;
    list-style: none;
    background-color: transparent;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.breadcrumb-item + .breadcrumb-item {
    padding-left: 8px;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    padding-right: 8px;
    color: #6c757d;
    font-size: 16px;
    font-weight: bold;
}

.breadcrumb-item a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-item a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: #6c757d;
    font-weight: 500;
}

/* Icone nel breadcrumb */
.breadcrumb-item i {
    margin-right: 5px;
    font-size: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .breadcrumb-nav {
        padding: 8px 15px;
    }
    
    .breadcrumb-item {
        font-size: 13px;
    }
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content-mini {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-content-mini h3 { margin-top: 0; margin-bottom: 10px; }

#noteTextArea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px; /* Evita lo zoom automatico su iOS */
    margin: 15px 0;
    box-sizing: border-box;
    resize: none;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-save, .btn-cancel {
    padding: 12px 20px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
}

.btn-save { background: #28a745; color: white; }
.btn-cancel { background: #dc3545; color: white; }

/* Feedback visivo sul pulsante nella tabella */
.btn-note-row.has-note {
    background-color: #ffc107 !important; /* Giallo evidenziatore */
    color: #000 !important;
    border-color: #e0a800 !important;
}

/* Allinea i gruppi nella riga */
.discount-inputs {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: flex-end; /* Allinea etichette e bottoni */
}

.btn-note-row {
    height: 40px;
    width: 40px;
    border: 1px solid #ced4da;
    background: #f8f9fa;
    border-radius: 6px;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Stato quando la nota è presente */
.btn-note-row.has-note {
    background-color: #e7f3ff;
    border-color: #007bff;
    color: #007bff;
}

.btn-note-row:active {
    transform: scale(0.95);
    background-color: #dee2e6;
}

/* Ottimizzazione stepper per tablet */
.step-btn {
    min-width: 40px;
    height: 40px;
    font-size: 1.2rem;
}

input[type="number"] {
    height: 40px;
    font-size: 1rem;
}