html {
    overflow-x: hidden; /* Prevent horizontal scrolling globally */
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    background: #f7f7f7;
    color: #333;
    overflow-x: hidden;
    width: 100vw;
    box-sizing: border-box;
    transition: background-color 0.3s ease; /* Smooth transition for background */
}

body.delivery-mode {
    background: #d3d3d3; /* Darker gray for delivery mode */
}

canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 998; /* Below modals (999 and 1001) */
    pointer-events: none; /* Prevent click interference */
}

header {
    text-align: center;
    padding: 15px;
    background: #e74c3c;
    color: white;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.logo {
    width: 80px;
    margin-bottom: 8px;
}

h1 {
    font-size: 2em;
    margin: 0;
}

header p {
    font-size: 1em;
    margin: 5px 0;
}

#bolsita {
    position: fixed;
    top: 15px;
    right: 10px;
    background: #2ecc71;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    transition: transform 0.3s ease;
    z-index: 1000;
    max-width: 140px;
    box-sizing: border-box;
}

#bolsita.pulse {
    transform: scale(1.1);
}

main {
    margin: 0 auto;
    padding: 15px 8px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
}

.toggle-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 70px;
    height: 34px;
    animation: pulseToggle 1.5s ease 1;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    transition: 0.4s;
    border-radius: 34px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background: #e74c3c;
}

input:checked + .slider:before {
    transform: translateX(36px);
}

.toggle-switch:hover .slider {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.toggle-labels {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.toggle-labels span {
    font-size: 1.2em;
    cursor: pointer;
    color: #7f8c8d;
    font-weight: 600;
    transition: color 0.3s ease;
}

.toggle-labels span.active {
    color: #e74c3c;
    font-weight: bold;
}

.menu-container {
    display: block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.menu-container.active {
    opacity: 1;
    transform: translateY(0);
}

.menu-section {
    margin: 30px 0;
}

.menu-section h2 {
    font-size: 1.8em;
    color: #e74c3c;
    text-align: center;
}

.menu-scroll {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding: 10px 5px;
    scrollbar-width: thin;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.menu-scroll::-webkit-scrollbar {
    height: 6px;
}

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

.item {
    flex: 0 0 240px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    padding: 12px;
    text-align: center;
    min-width: 200px;
    max-width: 90%;
    box-sizing: border-box;
}

.item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
}

.item h3 {
    font-size: 1.3em;
    margin: 8px 0;
    color: #333;
}

.item p {
    font-size: 0.9em;
    color: #7f8c8d;
    margin: 0 0 8px;
}

.order-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.order-now-btn {
    background: #2ecc71;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.order-now-btn:hover {
    background: #27ae60;
}

.order-btn {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, #e74c3c, #f1c40f);
    color: white;
    padding: 12px 25px;
    border-radius: 25px;
    text-decoration: none;
    font-size: 1.1em;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    cursor: pointer;
    animation: pulseButton 2s ease infinite;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.order-btn:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.4);
}

.order-btn:disabled {
    background: #7f8c8d;
    cursor: not-allowed;
    transform: translateX(-50%);
    animation: none;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    background: #2ecc71;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s ease;
}

.qty-btn:hover {
    background: #27ae60;
}

.qty-btn.minus {
    background: #e74c3c;
}

.qty-btn.minus:hover {
    background: #c0392b;
}

.qty-display {
    font-size: 1.1em;
    color: #333;
}

.flavor-select {
    width: 100%;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.9em;
    margin-bottom: 8px;
}

#whatsapp, #qr-code {
    text-align: center;
    margin: 30px 0;
}

#whatsapp h2, #qr-code h2 {
    font-size: 1.8em;
    color: #e74c3c;
}

.btn-whatsapp {
    background: #2ecc71;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 1.1em;
    display: inline-block;
    transition: background 0.3s ease;
}

.btn-whatsapp:hover {
    background: #27ae60;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

#confirmation-modal {
    z-index: 1001; /* Higher than other modals */
}

#order-form-modal {
    z-index: 1000;
}

#order-preview-modal {
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 15px;
    border-radius: 8px;
    max-width: 90vw;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    animation: fadeInScale 0.3s ease forwards;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    position: relative;
}

#order-preview-modal .modal-content {
    padding-top: 50px;
}

.modal-content.closing {
    animation: fadeOutScale 0.3s ease forwards;
}

.close {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 1.4em;
    cursor: pointer;
    z-index: 1002;
    color: #333;
    line-height: 1;
    padding: 5px;
}

.modal-content h2 {
    font-size: 1.6em;
    color: #e74c3c;
    margin-top: 0;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
}

#preview-total {
    font-size: 1.1em;
    font-weight: bold;
    margin-top: 15px;
}

#custom-order-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#custom-order-form label {
    font-size: 1em;
    color: #333;
}

#custom-order-form input, #custom-order-form select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
}

#custom-order-form button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s ease;
}

#custom-order-form button:hover {
    background: #c0392b;
}

footer {
    text-align: center;
    padding: 15px;
    background: #e74c3c;
    color: white;
    position: relative;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .item {
        flex: 0 0 200px;
        min-width: 180px;
        max-width: 95%;
    }
    .menu-scroll {
        padding: 8px 4px;
    }
    h1 {
        font-size: 1.6em;
    }
    .toggle-labels span {
        font-size: 0.8em;
    }
    .order-now-btn {
        padding: 6px 12px;
        font-size: 0.8em;
    }
    .modal-content {
        padding: 10px;
        max-width: 95vw;
        max-height: 90vh;
    }
    #order-preview-modal .modal-content {
        padding-top: 40px;
    }
    .modal-content h2 {
        font-size: 1.4em;
    }
    #bolsita {
        top: 10px;
        right: 8px;
        padding: 5px 10px;
        font-size: 0.8em;
        max-width: 120px;
    }
    .close {
        top: 6px;
        right: 6px;
        font-size: 1.2em;
    }
}

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

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

@keyframes pulseToggle {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pulseButton {
    0% {
        transform: translateX(-50%) scale(1);
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    }
    50% {
        transform: translateX(-50%) scale(1.08);
        box-shadow: 0 5px 12px rgba(0, 0, 0, 0.4);
    }
    100% {
        transform: translateX(-50%) scale(1);
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Ordered Items Container */
.ordered-items-container {
    margin: 20px 0;
    padding: 15px;
    background: #fff5f5;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.5s ease forwards;
}

.ordered-items-container h3 {
    font-size: 1.4em;
    color: #d32f2f;
    margin: 0 0 15px;
    text-align: center;
    font-weight: 600;
}

#ordered-items-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ordered-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #ffebee;
    font-size: 1em;
    color: #333;
    opacity: 0;
    transform: translateX(-20px);
    animation: fadeInItem 0.3s ease forwards;
    animation-delay: calc(0.1s * var(--item-index));
}

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

.item-name {
    font-weight: 600;
    color: #2ecc71;
}

.item-details {
    font-weight: 400;
    color: #388e3c;
}

.no-items {
    text-align: center;
    color: #388e3c;
    font-style: italic;
}

.order-total {
    font-size: 1.2em;
    font-weight: bold;
    color: #d32f2f;
    text-align: right;
    margin-top: 15px;
    animation: fadeInTotal 0.5s ease forwards;
}

/* Confirmation Modal Specific Styles */
#confirmation-modal .modal-content h2 {
    color: #d32f2f;
    font-size: 1.8em;
    text-align: center;
    margin-bottom: 10px;
}

/* Animation for container */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animation for list items */
@keyframes fadeInItem {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animation for total */
@keyframes fadeInTotal {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ordered-items-container {
        padding: 10px;
    }

    .ordered-items-container h3 {
        font-size: 1.2em;
    }

    .ordered-item {
        font-size: 0.9em;
        padding: 8px 0;
    }

    .order-total {
        font-size: 1.1em;
    }

    #confirmation-modal .modal-content h2 {
        font-size: 1.5em;
    }
}
