/* ==========================================
   VARIABLES Y RESET
========================================== */
:root {
    /* El usuario dueño del negocio solo modificará el Primary Color desde su panel */
    --primary-color: #ff5e00; 
    --primary-hover: #e05300;
    --text-main: #1a1a1a;
    --text-muted: #666666;
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --border-color: #eeeeee;
    --success: #28a745;
    --danger: #dc3545;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --border-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Evita el parpadeo azul en móviles al hacer tap */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #e9ecef; /* Fondo oscuro exterior para simular app en Desktop */
    color: var(--text-main);
    line-height: 1.5;
}

/* Contenedor tipo App */
.app-container {
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--bg-main);
    min-height: 100vh;
    position: relative;
    box-shadow: var(--shadow-md);
}

/* ==========================================
   HEADER Y PERFIL
========================================== */
.store-header {
    background-color: var(--bg-card);
    padding-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.cover-image {
    height: 180px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
}

.store-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: -50px;
    position: relative;
    padding: 0 20px;
}

.store-logo img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--bg-card);
    object-fit: cover;
    background-color: #fff;
    box-shadow: var(--shadow-sm);
}

.store-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 10px;
    letter-spacing: -0.5px;
}

.store-description {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.store-address {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.store-address i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.store-badges {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    justify-content: center;
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-open {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.status-open i {
    font-size: 0.5rem;
}

.info-badge {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
}

/* ==========================================
   NAVEGACIÓN STICKY (CATEGORÍAS)
========================================== */
.category-nav {
    position: sticky;
    top: 0;
    background-color: var(--bg-card);
    z-index: 100;
    padding: 12px 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.category-list {
    display: flex;
    list-style: none;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none; /* Oculta scrollbar Firefox */
}

.category-list::-webkit-scrollbar {
    display: none; /* Oculta scrollbar Chrome/Safari */
}

.category-item {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 16px;
    background-color: var(--bg-main);
    color: var(--text-muted);
    border-radius: 20px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-item.active {
    background-color: var(--primary-color);
    color: #ffffff;
}

/* ==========================================
   LISTA DE PRODUCTOS (CARDS)
========================================== */
.menu-container {
    padding: 16px;
}

.category-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 20px 0 15px 0;
    color: var(--text-main);
}

.product-card {
    display: flex;
    background-color: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    justify-content: space-between;
    gap: 12px;
}

.product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

/* ATENCIÓN: Esta regla ha sido limpiada porque estaba bloqueando la expansión desde menu.php */
.product-desc {
    /* Las propiedades de colapso y expansión ahora viven nativamente en menu.php */
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 6px 0;
}

.product-price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: auto;
}

.product-media {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100px;
    position: relative;
}

.product-media img {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    object-fit: cover;
}

.btn-add {
    margin-top: -15px; /* Superposición sutil con la imagen para UX táctil */
    background-color: #ffffff;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 2px;
    transition: transform 0.1s active;
}

.btn-add:active {
    transform: scale(0.95);
}

/* Estado Agotado (Sold Out) */
.product-card.sold-out {
    opacity: 0.6;
    filter: grayscale(80%);
}

.sold-out-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-add.disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* ==========================================
   CARRITO FLOTANTE (BOTTOM BAR)
========================================== */
.bottom-spacer {
    height: 100px; /* Evita que el ultimo producto quede debajo del carrito */
}

.floating-cart {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 450px;
    background-color: var(--primary-color);
    color: #ffffff;
    border-radius: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    z-index: 1000;
}

.cart-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-badge {
    background-color: #ffffff;
    color: var(--primary-color);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.cart-total {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-checkout {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.d-none {
    display: none !important;
}

/* ==========================================
   MODAL DE CHECKOUT CUSTOMIZADO (UX/UI)
========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-end; /* Efecto Bottom Sheet en móviles */
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 500px;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
    
    /* Límite de altura y formato Flex para scroll interno */
    max-height: 90vh; 
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0; /* Evita que el título se aplaste */
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.btn-close-modal {
    background: var(--bg-main);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s;
}

.btn-close-modal:active {
    background: var(--border-color);
}

/* Cuerpo del modal con scroll independiente */
.modal-body {
    overflow-y: auto;
    flex-shrink: 1;
    padding-right: 5px; /* Evita que el scroll pegue al contenido */
}

/* Estilo para que la barra de scroll se vea profesional y no estorbe */
.modal-body::-webkit-scrollbar {
    width: 4px;
}
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

.modal-footer {
    flex-shrink: 0; /* Evita que el botón de WhatsApp desaparezca o se encoja */
    margin-top: 15px;
    padding-top: 10px;
}

.modal-instruction {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    font-weight: 500;
}

.delivery-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.delivery-option input {
    display: none;
}

.option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    background-color: var(--bg-main);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.option-card i {
    font-size: 1.6rem;
}

/* Estado seleccionado adaptado al color dinámico */
.delivery-option input:checked + .option-card {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: transparent;
}

.delivery-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.delivery-details label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.delivery-details input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
    background-color: var(--bg-main);
}

.delivery-details input:focus {
    border-color: var(--primary-color);
    background-color: var(--bg-card);
}

.btn-confirm-order {
    width: 100%;
    background-color: #25D366; /* Verde oficial de WhatsApp para máximo CTR */
    color: white;
    border: none;
    padding: 16px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.1s active;
}

.btn-confirm-order:active {
    transform: scale(0.98);
}

.btn-confirm-order i {
    font-size: 1.4rem;
}

/* Comportamiento en Desktop */
@media (min-width: 501px) {
    .modal-overlay {
        align-items: center;
    }
    .modal-content {
        border-radius: 24px;
        transform: scale(0.9);
        opacity: 0;
        max-height: 85vh; /* Un poco más de margen en desktop */
    }
    .modal-overlay.active .modal-content {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================
   NUEVOS ESTILOS: RESUMEN Y MÉTODOS DE PAGO
========================================== */
.checkout-summary {
    background-color: var(--bg-main);
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.summary-row.total-row {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #ccc;
    margin-bottom: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
    background-color: var(--bg-main);
}

.form-group input:focus {
    border-color: var(--primary-color);
    background-color: var(--bg-card);
}

/* Opciones de Pago */
.payment-section {
    margin-top: 20px;
}

.payment-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.payment-option input {
    display: none;
}

.payment-option input:checked + .option-card {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: transparent;
}

.bank-info-box {
    background-color: rgba(37, 211, 102, 0.1);
    border: 1px solid rgba(37, 211, 102, 0.3);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.bank-info-box p {
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 5px;
    line-height: 1.4;
}

.alert-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #005c2a;
    background-color: #d1f4e0;
    padding: 10px;
    border-radius: 8px;
}

.alert-note i {
    font-size: 1.1rem;
}

/* ==========================================
   ESTILOS EXCLUSIVOS PARA PANEL DE ADMINISTRADOR
========================================== */
.admin-topbar {
    background-color: #1a1a1a;
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 3000;
    padding: 10px 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.admin-topbar-content {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-admin-config {
    background-color: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Espacio extra para que la topbar no tape el diseño de la app */
.admin-mode-container {
    margin-top: 45px; 
    min-height: calc(100vh - 45px);
}

/* Envolturas y Botones de Edición In-Place */
.editable-section {
    position: relative;
}

.editable-wrapper {
    position: relative;
    border: 2px dashed transparent;
    transition: border 0.3s;
    border-radius: 12px;
    padding: 5px;
}

.editable-wrapper:hover {
    border-color: #ccc;
}

.btn-edit {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 10;
}

.btn-edit-sm {
    width: 28px;
    height: 28px;
    font-size: 1rem;
}

.absolute-top-right {
    position: absolute;
    top: 10px;
    right: 10px;
}

.absolute-bottom-right {
    position: absolute;
    bottom: 5px;
    right: 5px;
}

.btn-add-category {
    background: rgba(0,0,0,0.05);
    border: 1px dashed #aaa;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.category-header-admin {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-edit-text {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* ==============================================
   MODIFICACIÓN QUIRÚRGICA: FOTO A LA DERECHA
============================================== */
.admin-product-card {
    flex-direction: row; /* Restaura el flujo horizontal principal (Foto a la derecha) */
    flex-wrap: wrap;     /* Permite que la caja de controles salte a la siguiente fila */
    gap: 0;
}

.admin-product-card .product-content {
    width: calc(100% - 110px); /* Ocupa todo el espacio menos la foto */
    flex: unset; /* Sobrescribe la regla genérica para respetar el diseño */
}

.admin-product-card .product-media {
    width: 100px;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
    margin-top: 0; /* Asegura alineación perfecta con el título */
}

.admin-product-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    width: 100%; /* Obliga a los controles a tomar su propia fila inferior completa */
}

.btn-edit-product {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Toggle Switch (Interruptor Disponible/Agotado) */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Botón Flotante Añadir Producto */
.btn-fab-add {
    position: fixed;
    bottom: 30px;
    right: 20px;
    background-color: var(--text-main);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 1000;
}

@media (min-width: 501px) {
    .btn-fab-add {
        left: 50%;
        transform: translateX(120px);
        right: auto;
    }
}

/* Formularios en Modales de Admin */
.admin-form textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
}
.admin-form textarea:focus {
    border-color: var(--primary-color);
}
.admin-select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    background-color: white;
}
.admin-image-upload {
    background-color: #f1f3f5;
    border: 2px dashed #ced4da;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 20px;
}
.admin-image-upload i {
    font-size: 2.5rem;
    color: #adb5bd;
}