@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');

:root {
    --primary: #6c5ce7;
    --primary-hover: #a29bfe;
    --secondary: #00cec9;
    --dark: #2d3436;
    --gray: #636e72;
    --light: #f1f2f6;
    --white: #ffffff;
    --danger: #ff7675;
    --success: #55efc4;
    --warning: #fab1a0;
    --shadow: 0 8px 30px rgba(0,0,0,0.08);
    --shadow-hover: 0 15px 45px rgba(0,0,0,0.12);
    --radius: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --glass: rgba(255, 255, 255, 0.03125);
    --glass-border: rgba(255, 255, 255, 0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--dark);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

h1, h2, h3 {
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 20px;
    color: var(--white);
    text-shadow: 0 4px 12px rgba(0,0,0,0.1);
    text-align: center;
}

h1 { font-size: 3.5rem; }
h2 { font-size: 2.5rem; }
h3 { font-size: 1.8rem; }

.view-container {
    background: var(--glass);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    max-width: 1200px;
    margin: 40px auto;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(20px); } 
    to { opacity: 1; transform: translateY(0); } 
}

#home-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

#home-wrapper:has(#view-home.hidden) {
    display: none;
}

#btn-allergene {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 8px 15px;
    margin-bottom: 4px;
    border-radius: 25px;
    text-decoration: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    transition: var(--transition);
}

#btn-allergene:hover {
    background: rgba(0,0,0,0.15);
}

#btn-impressum {
    display: inline-flex;
    align-self: flex-end;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 8px 15px;
    margin-top: 4px;
    border-radius: 25px;
    text-decoration: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    transition: var(--transition);
}

#btn-impressum:hover {
    background: rgba(0,0,0,0.15);
}

#select-branch, #select-product, #choose-option {
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

#lang-selector {
    position: fixed;
    top: 20px;
    right: 80px;
    z-index: 5000;
    display: flex;
    gap: 15px;
    background: var(--glass);
    backdrop-filter: blur(2.5px);
    border: 1px solid var(--glass-border);
    padding: 8px 15px;
    border-radius: 25px;
    box-shadow: var(--shadow);
}

.lang-flag {
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
    opacity: 0.7;
}

.lang-flag:hover, .lang-flag.active {
    transform: scale(1.2);
    opacity: 1;
}

.gear-icon {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    fill: var(--gray);
    transition: var(--transition);
    z-index: 5000;
    background: var(--glass);
    backdrop-filter: blur(2.5px);
    border: 1px solid var(--glass-border);
    padding: 8px;
    border-radius: 50%;
    box-shadow: var(--shadow);
}

.gear-icon:hover {
    transform: rotate(90deg);
    fill: var(--primary);
    box-shadow: var(--shadow-hover);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2.5px);
    justify-content: center;
    align-items: center;
    z-index: 4000;
}

.modal-content {
    background: var(--white);
    padding: 45px;
    border-radius: 35px;
    box-shadow: 0 35px 70px rgba(0,0,0,0.3);
    text-align: center;
    width: 90%;
    max-width: 420px;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(0,0,0,0.05);
}

@keyframes popIn { 
    from { transform: scale(0.8); opacity: 0; } 
    to { transform: scale(1); opacity: 1; } 
}

input, textarea, select {
    display: block;
    margin: 15px 0;
    padding: 16px 22px;
    width: 100%;
    box-sizing: border-box;
    border: 2px solid #edf2f7;
    border-radius: 18px;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    background: #f8fafc;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    background: var(--white);
    outline: none;
    box-shadow: 0 0 0 5px rgba(108, 92, 231, 0.18);
}

button {
    padding: 16px 32px;
    cursor: pointer;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 18px;
    font-size: 1rem;
    font-weight: 700;
    transition: var(--transition);
    box-shadow: 0 10px 25px rgba(108, 92, 231, 0.35);
    border: 1px solid rgba(255,255,255,0.15);
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 15px 35px rgba(108, 92, 231, 0.45);
}

button:active {
    transform: translateY(-1px);
}

button.close-btn {
    background: var(--gray);
    box-shadow: 0 10px 25px rgba(99, 110, 114, 0.25);
}

button.delete-btn {
    background: var(--danger);
    box-shadow: 0 10px 25px rgba(255, 118, 117, 0.25);
}

button.success-btn {
    background: var(--success);
    box-shadow: 0 10px 25px rgba(85, 239, 196, 0.35);
    color: #2d3436;
}

.grid-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 30px;
    margin-top: 45px;
}

.hidden {
    display: none;
}

#app-logo {
    display: block;
    max-height: 120px;
    max-width: 100%;
    margin: 0 auto 12px;
    object-fit: contain;
}

.view-container {
    position: relative;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    text-align: center;
    padding: 20px 10px;
    animation: fadeIn 0.4s ease;
}

.grid-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
}

/* Forza vans-container ad usare flex quando è visibile */
#vans-container.grid-buttons {
    display: flex !important;
}

.big-btn {
    padding: 30px;
    font-size: 1.3em;
    background: linear-gradient(135deg, #1dd1a1, #10ac84);
    box-shadow: 0 10px 20px rgba(29, 209, 161, 0.3);
    border-radius: var(--radius);
    color: white;
    border: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.product-btn {
    aspect-ratio: 0.6; /* Più larghi e più alti per spazio testo */
    min-height: 220px; /* Altezza aumentata per testo sotto */
    min-width: 160px; /* Larghezza minima aumentata */
    max-width: 200px; /* Larghezza massima per uniformità */
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    color: var(--dark);
    border: 1px solid rgba(0,0,0,0.03);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Product image area */
.product-img-wrapper {
    width: 100%;
    height: auto; /* Altezza automatica per mantenere proporzioni */
    min-height: 160px; /* Altezza aumentata per foto più grande */
    max-height: 180px; /* Altezza massima per non coprire troppo */
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-img {
    width: 100%;
    height: 100%;
    background-size: contain; /* contain invece di cover per mantenere proporzioni */
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.5s ease;
}

.product-btn:hover .product-img {
    transform: scale(1.1);
}

/* Nascondi wrapper immagine quando c'è backgroundImage per evitare duplicazione */
.product-btn[style*="background-image"] .product-img-wrapper,
.product-btn[style*="backgroundImage"] .product-img-wrapper {
    display: none;
}

/* Mostra testo quando c'è backgroundImage - UNICO BLOCCO */
.product-btn[style*="background-image"] .product-name,
.product-btn[style*="backgroundImage"] .product-name {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 10px 8px 10px; /* Padding unico */
    text-align: center;
    font-weight: 600;
    font-size: 1.0rem;
    color: var(--dark);
    border-top: 1px solid rgba(0,0,0,0.05);
    z-index: 2;
}

.product-btn[style*="background-image"] .product-price,
.product-btn[style*="backgroundImage"] .product-price {
    display: none; /* Nascondo il prezzo separato */
}

/* Product name area - AL BORDO INFERIORE */
.product-btn .product-name {
    padding: 8px 10px 4px 10px; /* Padding ridotto e attaccato al basso */
    text-align: center;
    font-weight: 600;
    font-size: 1.0rem;
    color: var(--dark);
    background: var(--white);
    border-top: 1px solid rgba(0,0,0,0.05);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    margin-top: auto; /* Spinge il testo verso il basso */
}

/* Product price area - AL BORDO INFERIORE */
.product-btn .product-price {
    padding: 4px 10px 8px 10px; /* Padding ridotto e attaccato al basso */
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary);
    background: var(--white);
    border-top: 1px solid rgba(0,0,0,0.05);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

/* For buttons without image */
.product-btn:not(.has-image) {
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
    text-align: center;
}

/* Reduced size for composition steps */
.product-btn.composition-step {
    min-width: 80px;
    min-height: 110px;
    max-width: 100px;
    font-size: 0.8rem;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

.product-btn.composition-step .product-img-wrapper {
    min-height: 80px;
    max-height: 90px;
}

.product-btn.composition-step .product-name {
    font-size: 0.7rem;
    padding: 4px 5px;
}

.product-btn.composition-step[style*="background-image"] .product-name,
.product-btn.composition-step[style*="backgroundImage"] .product-name {
    font-size: 0.7rem;
    padding: 4px 5px;
}

.product-btn:not(.has-image) .product-name {
    padding: 20px 12px 8px 12px;
    border: none;
    background: var(--white);
}

.product-btn:not(.has-image) .product-price {
    padding: 4px 12px 20px 12px;
    border: none;
    background: var(--white);
}

/* Composition Widget Styles */
.comp-widget {
    border: 3px solid var(--primary);
    flex-direction: column;
    align-items: stretch;
    cursor: default;
    background: var(--white);
    border-radius: 25px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.comp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
}

.comp-progress-container {
    width: 100%;
    height: 8px;
    background: var(--light);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

.comp-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    transition: width 0.3s ease;
    border-radius: 10px;
}

.comp-progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    font-size: 0.85rem;
    color: var(--gray);
}

.comp-status-text {
    color: var(--gray);
    font-size: 1rem;
    margin-bottom: 15px;
}

.comp-qty-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
    font-size: 0.85em;
}

.comp-qty-input {
    width: 50px;
    text-align: center;
    padding: 4px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 1em;
    font-weight: bold;
    color: #212529;
}

.panna-btn {
    background-color: #fd79a8;
    color: white;
    box-shadow: 0 4px 10px rgba(253, 121, 168, 0.4);
}

.product-btn.selected {
    border: 3px solid var(--success);
    background-color: #f0fff4;
    transform: scale(0.98);
}

.cart-widget {
    background: var(--dark);
    color: white;
    padding: 20px;
    border-radius: var(--radius);
    margin: 20px 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 25px rgba(45, 52, 54, 0.3);
    transition: var(--transition);
}

.cart-widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(45, 52, 54, 0.4);
}

.item-list {
    list-style: none;
    padding: 0;
    text-align: left;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.item-list li {
    border-bottom: 1px solid #f1f2f6;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

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

.item-list li:hover {
    background: #fafafa;
}

.blink-red {
    color: var(--danger);
    font-weight: bold;
    animation: blinker 1s linear infinite;
}

.order-card {
    flex-direction: column !important;
    align-items: stretch !important;
    background: var(--white);
    margin-bottom: 15px;
    border-radius: var(--radius);
    border: none !important;
    box-shadow: var(--shadow);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light);
    margin-bottom: 10px;
}

.order-total-price {
    font-size: 1.2em;
    font-weight: 800;
    color: var(--primary);
}

.order-product-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

@keyframes blinker {
    50% { opacity: 0; }
}

@media (min-width: 768px) {
    body { 
        padding: 20px; 
    }
    .view-container { 
        padding: 40px; 
    }
}

@media (max-width: 767px) {
    h1, h2, h3 { 
        font-size: 2em; 
    }
    .big-btn { 
        padding: 20px; 
        font-size: 1.1em; 
    }
    .product-btn { 
        min-height: 100px; 
    }
}

@media (min-width: 1024px) {
    .item-list:not(#cart-list) {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 15px;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }
    .item-list:not(#cart-list) li {
        background: var(--white);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        border: 1px solid rgba(0,0,0,0.05);
        flex-direction: column;
        gap: 10px;
        height: 100%;
    }
    .item-list:not(#cart-list) li:not(.order-card) {
        align-items: center;
        text-align: center;
    }
    .item-list:not(#cart-list) li:not(.order-card) > div {
        justify-content: center;
        width: 100%;
        display: flex;
        gap: 10px;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: rgba(45, 52, 54, 0.98);
    color: white;
    padding: 20px 30px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    border: 2px solid rgba(255,255,255,0.2);
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast.toast-out {
    opacity: 0;
    transform: scale(0.8);
}

@keyframes toastIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes toastOut {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(0.8); opacity: 0; }
}


