/* Celeste Core - Food Mode Addons Modal CSS (Responsive & Modern) */

/* Bloqueo de scroll e interacción del fondo cuando el modal está activo */
body.celeste-modal-open,
html.celeste-modal-open {
    overflow: hidden !important;
    touch-action: none !important;
    height: 100vh !important;
    overscroll-behavior: contain !important;
}

.celeste-addons-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999999 !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.celeste-addons-modal-overlay.is-active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.celeste-addons-modal-container {
    background: #ffffff;
    width: 100%;
    max-width: 480px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    transform: translateY(20px) scale(0.96);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    box-sizing: border-box;
}

.celeste-addons-modal-overlay.is-active .celeste-addons-modal-container {
    transform: translateY(0) scale(1);
}

/* Indicador visual tipo Bottom-Sheet (Oculto en Desktop, visible en Móvil) */
.celeste-modal-drag-handle {
    display: none;
    width: 40px;
    height: 4px;
    background-color: #cbd5e1;
    border-radius: 99px;
    margin: 10px auto 2px;
}

/* Botón de cierre */
.celeste-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    z-index: 10;
}

.celeste-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

/* Cabecera del modal */
.celeste-modal-header {
    padding: 22px 24px 16px;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(180deg, #fafafa 0%, #ffffff 100%);
    flex-shrink: 0;
}

.celeste-modal-product-title {
    margin: 0 0 4px 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #0f172a;
    padding-right: 36px;
    line-height: 1.3;
}

.celeste-modal-subtitle {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
}

/* Cuerpo desplegable con scroll */
.celeste-modal-body {
    padding: 16px 24px 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.celeste-modal-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px 0;
    color: #64748b;
    font-size: 0.95rem;
}

.celeste-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: celeste-spin 0.8s linear infinite;
}

@keyframes celeste-spin {
    to { transform: rotate(360deg); }
}

.celeste-addons-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.celeste-addon-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, transform 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.celeste-addon-item:hover {
    border-color: #94a3b8;
    background-color: #f8fafc;
}

.celeste-addon-item.is-selected {
    border-color: #2563eb;
    background-color: #eff6ff;
}

.celeste-addon-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.celeste-addon-checkbox {
    width: 20px;
    height: 20px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.celeste-addon-item label,
.celeste-addon-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
    cursor: pointer;
}

.celeste-addon-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: #2563eb;
    flex-shrink: 0;
    margin-left: 8px;
}

/* Pie fijo del modal */
.celeste-modal-footer {
    padding: 16px 24px calc(20px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #f1f5f9;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex-shrink: 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
}

.celeste-modal-price-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
}

.celeste-price-amount {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
}

.celeste-btn-add-to-cart {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    min-height: 48px;
}

.celeste-btn-add-to-cart:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.celeste-btn-add-to-cart:active {
    transform: translateY(0);
}

.celeste-btn-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

/* Ocultar el selector de cantidad en Modo Tienda de Comida */
body.celeste-food-mode .quantity,
body.celeste-food-mode form.cart .quantity,
body.celeste-food-mode .cart .product-quantity input.qty,
body.celeste-food-mode .woocommerce-mini-cart-item .quantity {
    display: none !important;
}

/* ==========================================================================
   DISEÑO ADAPTATIVO / RESPONSIVE (Móviles y Tablets)
   ========================================================================== */

@media screen and (max-width: 640px) {
    .celeste-addons-modal-overlay {
        padding: 0;
        align-items: flex-end; /* Anclado al borde inferior como Bottom-Sheet */
    }

    .celeste-addons-modal-container {
        max-width: 100%;
        width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 88vh;
        transform: translateY(100%); /* Desliza desde abajo */
    }

    .celeste-addons-modal-overlay.is-active .celeste-addons-modal-container {
        transform: translateY(0);
    }

    .celeste-modal-drag-handle {
        display: block; /* Muestra barra de arrastre superior */
    }

    .celeste-modal-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }

    .celeste-modal-header {
        padding: 12px 20px 14px;
    }

    .celeste-modal-product-title {
        font-size: 1.1rem;
    }

    .celeste-modal-body {
        padding: 14px 20px 16px;
    }

    .celeste-addon-item {
        padding: 12px 14px;
        min-height: 48px;
    }

    .celeste-modal-footer {
        padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 12px));
    }
}

/* ==========================================================================
   OPTIMIZACIÓN DE TABLA DE CARRITO EN MODO TIENDA DE COMIDA
   ========================================================================== */

/* 1. Ocultar columnas innecesarias de Cantidad y Precio unitario en tabla de carrito y mini-cart */
body.celeste-food-mode table.cart .product-quantity,
body.celeste-food-mode table.cart .product-price,
body.celeste-food-mode .shop_table .product-quantity,
body.celeste-food-mode .shop_table .product-price,
body.celeste-food-mode .cel-mini-item-qty,
body.celeste-food-mode .cel-mini-item-price-label {
    display: none !important;
}

/* 2. Ajustes de tabla de carrito limpia y sin distorsión */
body.celeste-food-mode table.cart td.product-name,
body.celeste-food-mode table.cart td.product-subtotal {
    padding: 16px 12px !important;
    vertical-align: middle !important;
}

body.celeste-food-mode table.cart td.product-subtotal {
    font-weight: 700 !important;
    color: #0f172a !important;
    text-align: right !important;
}

/* 3. Adaptación responsive para tabla de carrito en móviles (Celulares < 768px) */
@media screen and (max-width: 768px) {
    body.celeste-food-mode table.cart,
    body.celeste-food-mode table.shop_table {
        display: block !important;
        width: 100% !important;
        border: none !important;
        background: transparent !important;
    }

    body.celeste-food-mode table.cart tbody,
    body.celeste-food-mode table.cart tr {
        display: block !important;
        width: 100% !important;
    }

    body.celeste-food-mode table.cart thead {
        display: none !important; /* Ocultar cabeceras fijas en móviles */
    }

    body.celeste-food-mode table.cart tr.cart_item {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
        padding: 12px 14px !important;
        margin-bottom: 12px !important;
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 14px !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
        gap: 8px !important;
        box-sizing: border-box !important;
    }

    body.celeste-food-mode table.cart td.product-remove {
        order: 1 !important;
        padding: 0 !important;
        margin-right: 4px !important;
    }

    body.celeste-food-mode table.cart td.product-thumbnail {
        order: 2 !important;
        padding: 0 !important;
    }

    body.celeste-food-mode table.cart td.product-thumbnail img {
        width: 44px !important;
        height: 44px !important;
        border-radius: 8px !important;
        object-fit: cover !important;
    }

    body.celeste-food-mode table.cart td.product-name {
        order: 3 !important;
        flex: 1 1 45% !important;
        padding: 0 8px !important;
        font-size: 0.88rem !important;
        line-height: 1.3 !important;
    }

    body.celeste-food-mode table.cart td.product-subtotal {
        order: 4 !important;
        padding: 0 !important;
        font-size: 0.95rem !important;
        font-weight: 800 !important;
        white-space: nowrap !important;
        text-align: right !important;
    }
}
