/* ============================================
   BimPos - Tienda cliente (PWA)
   Colores: Azul #1565C0 · Rojo #D32F2F · Blanco
   ============================================ */

:root {
    --blue: #1565C0;
    --blue-dark: #0D47A1;
    --blue-light: #E3F2FD;
    --red: #D32F2F;
    --red-dark: #B71C1C;
    --gray-bg: #F5F7FA;
    --text: #212121;
    --text-muted: #757575;
    --border: #E0E0E0;
    --green: #25D366;
    --green-dark: #1EBE57;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.15);
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--gray-bg);
    color: var(--text);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.app-header {
    background: linear-gradient(135deg, var(--blue-dark), var(--blue));
    color: #fff;
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(13, 71, 161, 0.3);
}

.header-inner { display: flex; align-items: center; justify-content: space-between; }

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
    width: 44px; height: 44px;
    background: #fff;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.brand-name { font-weight: 700; font-size: 1.15rem; line-height: 1.1; }
.brand-tag { font-size: 0.75rem; opacity: 0.85; }

.wa-header {
    color: #fff;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
}

.wa-header:active { background: var(--green); }

/* ---------- Anuncio ---------- */
.announcement {
    background: var(--red);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    padding: 8px 0;
}

/* ---------- Menú ---------- */
.menu-section { padding: 24px 0 120px; flex: 1; }

.menu-head { text-align: center; margin-bottom: 18px; }
.menu-head h1 { font-size: 1.6rem; font-weight: 800; margin: 0 0 4px; }
.menu-head p { color: var(--text-muted); margin: 0; font-size: 0.9rem; }

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow-x: visible;
    padding: 4px 2px 12px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar { display: none; }

.chip {
    flex: 0 0 auto;
    background: #fff;
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: 30px;
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    margin-top: 8px;
}

@media (max-width: 560px) {
    .product-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .product-img-wrap { height: 130px; }
    .product-emoji { font-size: 2.4rem; padding: 16px 0 6px; }
    .product-body h3 { font-size: 0.92rem; }
    .product-body p { font-size: 0.75rem; }
    .product-price { font-size: 1rem; }
    .add-btn { padding: 7px 10px; font-size: 0.78rem; }
}

.product-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.product-card:active { transform: scale(0.98); }

.product-img-wrap {
    background: linear-gradient(160deg, var(--blue-light), #fff);
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    padding: 8px;
    display: block;
}

.product-emoji {
    font-size: 3rem;
    text-align: center;
    padding: 22px 0 8px;
    background: linear-gradient(160deg, var(--blue-light), #fff);
}

.product-body { padding: 8px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.product-body h3 { font-size: 1.02rem; font-weight: 700; margin: 0 0 3px; }
.product-body p { color: var(--text-muted); font-size: 0.8rem; margin: 0 0 10px; flex: 1; }

.product-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

.product-price { font-size: 1.15rem; font-weight: 800; color: var(--blue-dark); }

.add-btn {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex; align-items: center; gap: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.add-btn:active { background: var(--red); }

/* ---------- Modal selector de salsas ---------- */
.sauce-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.sauce-overlay.show { opacity: 1; visibility: visible; }

.sauce-modal {
    background: #fff;
    width: 100%;
    max-width: 480px;
    border-radius: 18px 18px 0 0;
    padding: 20px 18px 24px;
    transform: translateY(30px);
    transition: transform 0.25s;
    max-height: 85vh;
    overflow-y: auto;
}

.sauce-overlay.show .sauce-modal { transform: translateY(0); }

@media (min-width: 520px) {
    .sauce-overlay { align-items: center; }
    .sauce-modal { border-radius: 18px; }
}

.sauce-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.sauce-head h3 { margin: 0; font-size: 1.1rem; font-weight: 800; }
.sauce-head p { margin: 2px 0 0; color: var(--text-muted); font-size: 0.82rem; }
.sauce-close {
    border: none; background: none;
    font-size: 1.4rem; color: var(--text-muted);
    cursor: pointer; line-height: 1; padding: 4px;
    font-family: inherit;
}

.sauce-quick { display: flex; gap: 8px; margin: 12px 0; }
.sauce-quick-btn {
    flex: 1;
    border: 2px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 9px 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.sauce-quick-btn.all:hover { border-color: var(--blue); background: var(--blue-light); color: var(--blue-dark); }
.sauce-quick-btn.none:hover { border-color: var(--red); background: #FFEBEE; color: var(--red); }

.sauce-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.sauce-opt { position: relative; }
.sauce-opt input { position: absolute; opacity: 0; pointer-events: none; }
.sauce-opt span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 12px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    transition: all 0.15s;
    user-select: none;
}
.sauce-opt span .sauce-emoji { font-size: 1.1rem; }
.sauce-opt input:checked + span {
    border-color: var(--red);
    background: #FFEBEE;
    color: var(--red);
}

.adicion-block {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}

.adicion-block h4 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text);
}

.adicion-price {
    margin-left: auto;
    color: var(--red);
    font-size: 0.8rem;
    white-space: nowrap;
}

.sauce-actions { display: flex; gap: 10px; margin-top: 16px; }
.sauce-cancel {
    flex: 1;
    border: 2px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 13px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
}
.sauce-confirm {
    flex: 2;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 13px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
}
.sauce-confirm:active { background: var(--red-dark); }

/* ---------- Barra flotante carrito ---------- */
.cart-fab {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--red);
    color: #fff;
    border-radius: 40px;
    padding: 12px 22px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    z-index: 1000;
    font-weight: 700;
    border: none;
    text-decoration: none;
    font-family: inherit;
}

.cart-count {
    background: #fff;
    color: var(--red);
    border-radius: 50%;
    min-width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
    padding: 0 6px;
}

.cart-total { background: rgba(255, 255, 255, 0.2); padding: 5px 12px; border-radius: 20px; font-size: 0.9rem; }

/* ---------- Página de carrito ---------- */
.cart-section { padding: 24px 0; flex: 1; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.page-head h1 { font-size: 1.5rem; font-weight: 800; margin: 0; }

.btn-link { color: var(--blue); font-weight: 700; text-decoration: none; font-size: 0.9rem; }
.btn-link:hover { text-decoration: underline; }

.card-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.cart-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.ci-emoji { font-size: 1.5rem; }
.ci-info { flex: 1; min-width: 0; }
.ci-name { font-weight: 600; font-size: 0.92rem; }
.ci-price { color: var(--text-muted); font-size: 0.8rem; }
.ci-sauces { color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }

.ci-qty { display: flex; align-items: center; gap: 6px; }

.qty-btn {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text);
    font-family: inherit;
}

.qty-btn.plus { background: var(--blue); border-color: var(--blue); color: #fff; }
.qty-val { font-weight: 700; min-width: 20px; text-align: center; }
.ci-sub { font-weight: 700; min-width: 60px; text-align: right; }

.ci-remove {
    border: none;
    background: none;
    color: var(--red);
    font-size: 1rem;
    cursor: pointer;
    padding: 6px;
}

.cart-summary { padding: 14px 0 0; }

.sum-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.15rem;
    font-weight: 700;
    padding: 10px 0;
}

.sum-row strong { color: var(--red); font-size: 1.3rem; }

.sub { color: var(--text-muted); margin: 0 0 16px; font-size: 0.88rem; display: flex; gap: 10px; flex-wrap: wrap; }

.checkout-btn {
    display: block;
    width: 100%;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    font-family: inherit;
    cursor: pointer;
}

.checkout-btn:active { background: var(--red-dark); }

/* ---------- Checkout ---------- */
.checkout-section { padding: 24px 0; flex: 1; }

.checkout-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 18px;
    align-items: start;
}

@media (max-width: 760px) {
    .checkout-layout { grid-template-columns: 1fr; }
}

.checkout-form h1 { font-size: 1.4rem; font-weight: 800; margin: 0 0 2px; }
.checkout-form .sub { margin: 0 0 18px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }

.form-input {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s;
    resize: vertical;
}

.form-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.payment-options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.type-option { position: relative; }
.type-option input { position: absolute; opacity: 0; }
.type-option span {
    display: block;
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: 12px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
}

.type-option input:checked + span {
    border-color: var(--blue);
    background: var(--blue-light);
    color: var(--blue-dark);
}

.field-hint { display: block; font-size: 0.78rem; color: #6b7280; margin-top: 4px; }
.field-hint.total-hint { font-size: 1rem; font-weight: 600; color: #b45309; background: #fef3c7; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; margin-top: 8px; text-align: center; }

/* ---------- Compartir tienda ---------- */
.share-box { max-width: 460px; margin: 0 auto; text-align: center; }
.share-qr-wrap {
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    margin: 6px auto 16px;
    display: inline-block;
}
.share-qr { width: 260px; height: 260px; display: block; }
.share-url-row { display: flex; gap: 8px; }
.share-copy-btn {
    flex: 0 0 auto;
    border: 2px solid var(--blue);
    background: #fff;
    color: var(--blue-dark);
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}
.share-hint { color: var(--text-muted); font-size: 0.82rem; margin-top: 12px; }

.bill-options { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bill-btn {
    border: 2px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.bill-btn.active, .bill-btn:hover {
    border-color: var(--blue);
    background: var(--blue-light);
    color: var(--blue-dark);
}
#cashInput { flex: 1; min-width: 140px; }
.change-result {
    margin-top: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.qr-box { text-align: center; padding: 12px; }
.qr-img {
    width: 200px;
    height: 200px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}
.qr-key-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px auto 4px;
    max-width: 300px;
}
.qr-key-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; }
.qr-key {
    font-size: 1rem;
    font-weight: 800;
    color: var(--blue-dark);
    background: var(--blue-light);
    padding: 8px 14px;
    border-radius: 10px;
    word-break: break-all;
}
.qr-copy-btn {
    border: 2px solid var(--blue);
    background: #fff;
    color: var(--blue-dark);
    border-radius: 10px;
    padding: 7px 14px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.qr-copy-btn:active { background: var(--blue-light); }
.qr-missing { color: #b45309; font-weight: 600; }
.qr-hint { font-size: 0.82rem; color: #6b7280; margin-top: 8px; }

.submit-btn {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    transition: background 0.15s;
}

.submit-btn:active { background: var(--red-dark); }

.checkout-summary h2 { font-size: 1.15rem; font-weight: 800; margin: 0 0 14px; }

.resumen-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.88rem;
}

.res-emoji { font-size: 1.1rem; }
.res-name { flex: 1; }
.res-price { font-weight: 700; }

.resumen-totals { padding-top: 6px; }
.rt-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 0.92rem; }
.rt-row.total { font-weight: 800; font-size: 1.15rem; border-top: 2px solid var(--border); margin-top: 6px; padding-top: 10px; }
.rt-row.total span:last-child { color: var(--red); }

/* ---------- Confirmación / WhatsApp ---------- */
.confirmation-section { padding: 40px 0; flex: 1; }

.confirm-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    margin: 0 auto;
    padding: 36px 26px;
    text-align: center;
}

.confirm-check {
    font-size: 3.5rem;
    width: 84px; height: 84px;
    margin: 0 auto 14px;
    background: #E8F5E9;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.confirm-card h1 { font-size: 1.5rem; font-weight: 800; margin: 0 0 6px; }
.confirm-card > p { color: var(--text-muted); margin: 0 0 18px; font-size: 0.92rem; }

.order-code {
    background: var(--blue-light);
    border: 2px dashed var(--blue);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 20px;
}

.order-code span { font-size: 0.85rem; color: var(--text-muted); display: block; }
.order-code .code { font-size: 2.2rem; font-weight: 900; letter-spacing: 0.15em; color: var(--blue-dark); }

.wa-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--green);
    color: #fff;
    text-decoration: none;
    padding: 15px 20px;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 800;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
    transition: background 0.15s;
}

.wa-send-btn:active { background: var(--green-dark); }

.confirm-hint { font-size: 0.8rem; color: var(--text-muted); margin: 12px 0 20px !important; }

.confirm-summary { text-align: left; margin-bottom: 20px; }
.cs-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
.cs-row span:first-child { color: var(--text-muted); }
.cs-row.total { font-weight: 800; font-size: 1.1rem; border-bottom: none; }
.cs-row.total span:last-child { color: var(--red); }

.confirm-thanks {
    margin-top: 24px;
    padding: 22px 18px;
    border-radius: 16px;
    background: linear-gradient(160deg, var(--blue-dark), var(--blue));
    color: #fff;
    text-align: center;
}

.thanks-badge {
    width: 56px; height: 56px;
    margin: 0 auto 10px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
}

.confirm-thanks h2 { margin: 0 0 8px; font-size: 1.25rem; font-weight: 800; }
.confirm-thanks p { margin: 0 auto 14px; font-size: 0.88rem; opacity: 0.95; max-width: 300px; line-height: 1.5; }

.thanks-brand {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    padding: 8px 18px;
    border-radius: 30px;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

.thanks-slogan { margin-top: 10px; font-size: 0.8rem; font-weight: 600; opacity: 0.9; }

/* ---------- Alertas ---------- */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 14px; }
.alert-danger { background: #FFEBEE; color: var(--red); }

.empty-cart { text-align: center; color: var(--text-muted); padding: 30px 0; }

/* ---------- Toast ---------- */
.toast-msg {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--blue-dark);
    color: #fff;
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
}

.toast-msg.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
.app-footer {
    background: var(--blue-dark);
    color: #fff;
    padding: 18px 0;
    margin-top: auto;
}

.footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-wrap: wrap;
    gap: 6px;
}

.footer-row a { color: #fff; text-decoration: none; }
.footer-credit { font-size: 0.75rem; opacity: 0.7; margin-top: 6px; }
.footer-credit .admin-link { color: inherit; text-decoration: none; opacity: 0.55; }
.footer-credit .admin-link:hover { opacity: 1; }
