/* Tutti i commenti nel codice sono in italiano */

/* Carrello fluttuante */
.carrello-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.carrello-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--menu-main-color, #047857);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.carrello-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.carrello-toggle:active {
    transform: scale(0.95);
}

.carrello-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

.carrello-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 90%;
    max-width: 400px;
    max-height: 70vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.carrello-panel.open {
    display: flex;
}

.carrello-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.carrello-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.carrello-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.carrello-close:hover {
    background: #e5e7eb;
}

.carrello-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.carrello-vuoto {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.carrello-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

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

.carrello-item-info {
    flex: 1;
}

.carrello-item-nome {
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.carrello-item-variante {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 4px;
}

.carrello-item-prezzo {
    color: var(--menu-main-color, #047857);
    font-weight: 600;
    margin-top: 4px;
}

.carrello-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.carrello-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 8px;
}

.carrello-item-qty button {
    background: none;
    border: none;
    font-size: 18px;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.carrello-item-qty button:hover {
    background: #f3f4f6;
}

.carrello-item-qty span {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
}

.carrello-item-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px;
    font-size: 20px;
    border-radius: 4px;
    transition: background 0.2s;
}

.carrello-item-remove:hover {
    background: #fee2e2;
}

.carrello-footer {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.carrello-totale {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 18px;
}

.carrello-totale strong {
    color: #111827;
}

.carrello-totale span {
    color: var(--menu-main-color, #047857);
    font-size: 20px;
}

.btn-checkout {
    width: 100%;
    padding: 12px 24px;
    background: var(--menu-main-color, #047857);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-checkout:hover {
    background: var(--menu-main-color, #047857);
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-checkout:active {
    transform: translateY(0);
}

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

/* Stili per il pulsante conferma tipo ordine */
#tipo-ordine-conferma:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #9ca3af;
}

/* Pulsante aggiungi al carrello sui prodotti */
.btn-aggiungi-carrello {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--menu-main-color, #047857);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, transform 0.1s;
}

.btn-aggiungi-carrello:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-aggiungi-carrello:active {
    transform: translateY(0);
}

.btn-aggiungi-carrello .btn-icon {
    font-size: 18px;
    font-weight: bold;
}

.btn-aggiungi-variante {
    margin-top: 8px;
    font-size: 12px;
    padding: 6px 12px;
}

/* Modal personalizzazione prodotto */
.personalizza-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
}

.personalizza-overlay.active {
    display: block;
}

.personalizza-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 2001;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.personalizza-modal.active {
    display: flex;
}

.personalizza-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}

.personalizza-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.personalizza-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.personalizza-close:hover {
    background: #e5e7eb;
}

.personalizza-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.personalizza-prezzo {
    text-align: center;
    padding: 12px;
    margin-bottom: 16px;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 18px;
}

.personalizza-prezzo strong {
    color: var(--menu-main-color, #047857);
}

.personalizza-body h4 {
    margin: 16px 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.personalizza-opzione-item,
.personalizza-ingrediente-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
}

.personalizza-opzione-item {
    position: relative;
}

.personalizza-opzione-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.personalizza-opzione-item label:hover {
    background-color: #f9fafb;
}

.personalizza-opzione-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--menu-main-color, #047857);
    flex-shrink: 0;
}

/* Pulsanti quantità per ingredienti */
.personalizza-qty-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.personalizza-qty-btn {
    padding: 6px 16px;
    border: 2px solid #d1d5db;
    background: white;
    color: #374151;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 50px;
}

.personalizza-qty-btn:hover {
    border-color: var(--menu-main-color, #047857);
    background: #f0fdf4;
    color: var(--menu-main-color, #047857);
}

.personalizza-qty-btn.active {
    background: var(--menu-main-color, #047857);
    border-color: var(--menu-main-color, #047857);
    color: white;
}

.personalizza-qty-btn.active:hover {
    background: var(--menu-main-color, #047857);
    opacity: 0.9;
}

/* Stepper per quantità numeriche */
.personalizza-qty-stepper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.personalizza-qty-stepper input[type="number"] {
    width: 60px;
    padding: 6px 8px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

.personalizza-qty-stepper input[type="number"]:focus {
    outline: none;
    border-color: var(--menu-main-color, #047857);
}

.personalizza-qty-stepper-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 2px solid #d1d5db;
    background: white;
    color: #374151;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.personalizza-qty-stepper-btn:hover {
    border-color: var(--menu-main-color, #047857);
    background: var(--menu-main-color, #047857);
    color: white;
}

.personalizza-qty-stepper-btn:active {
    transform: scale(0.95);
}

.personalizza-ingrediente-prezzo {
    color: var(--menu-main-color, #047857);
    font-weight: 600;
    font-size: 14px;
}

.personalizza-search {
    margin-bottom: 12px;
}

.personalizza-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.personalizza-footer {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    background: #f9fafb;
}

.btn-personalizza-annulla,
.btn-personalizza-aggiungi {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-personalizza-annulla {
    background: #e5e7eb;
    color: #374151;
}

.btn-personalizza-annulla:hover {
    background: #d1d5db;
}

.btn-personalizza-aggiungi {
    background: var(--menu-main-color, #047857);
    color: white;
}

.btn-personalizza-aggiungi:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-personalizza-aggiungi:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
    .carrello-container {
        bottom: 15px;
        right: 15px;
    }
    
    .carrello-toggle {
        width: 56px;
        height: 56px;
    }
    
    .carrello-panel {
        bottom: 80px;
        right: 15px;
        left: 15px;
        width: auto;
        max-height: 75vh;
    }
    
    .personalizza-modal {
        width: 95%;
        max-height: calc(100vh - 20px);
        top: 10px;
        transform: translate(-50%, 0);
    }
    
    /* Quando la tastiera è visibile, riduci ulteriormente l'altezza */
    @media (max-height: 600px) {
        .personalizza-modal {
            max-height: calc(100vh - 10px);
            top: 5px;
        }
        
        .personalizza-header {
            padding: 12px;
        }
        
        .personalizza-body {
            padding: 12px;
        }
        
        .personalizza-footer {
            padding: 12px;
        }
    }
}

/* Stile per item carrello cliccabile */
.carrello-item-clickable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.carrello-item-clickable:hover {
    background-color: #f9fafb;
}

.carrello-item-clickable:active {
    background-color: #f3f4f6;
}

/* MyPOS Embedded Checkout */
#mypos-embedded-container {
    margin-top: 20px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

#mypos-embedded-container h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

#mypos-wallet-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

#mypos-wallet-buttons > div {
    width: 100%;
}

#mypos-embedded-iframe {
    width: 100%;
    min-height: 400px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
}

