/* ===== pedilo.pro — estilos mobile-first ===== */
:root {
    --brand: #2563eb;
    --brand-2: #1e40af;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1c1f24;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --ok: #16a34a;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
    --maxw: 920px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 16px;
}

img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 16px; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px; border-radius: var(--radius); border: 1px solid transparent;
    background: var(--brand); color: #fff; font-size: 16px; font-weight: 600;
    cursor: pointer; text-align: center; transition: filter .15s, transform .05s;
    width: auto;
}
.btn:hover { filter: brightness(.95); }
.btn:active { transform: translateY(1px); }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--secondary { background: var(--brand-2); }
.btn--danger { background: var(--danger); }
.btn--wa { background: #25d366; color: #06351c; }
.btn--sm { padding: 8px 12px; font-size: 14px; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], textarea, select {
    width: 100%; padding: 12px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 16px; background: var(--surface);
    color: var(--text); font-family: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 56px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.checkbox { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.checkbox input { width: 20px; height: 20px; }
.input-prefix { display: flex; align-items: center; gap: 8px; }
.captcha-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.captcha-img { border: 1px solid var(--border); border-radius: 10px; height: 56px; background: #f5f5f5; }
.input-prefix .pfx { color: var(--muted); font-weight: 600; white-space: nowrap; }

.row { display: grid; gap: 16px; }
@media (min-width: 640px) { .row.cols-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }

/* ---------- Flashes ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; }
.flash.success { background: #e9f9ef; color: #14622f; border: 1px solid #bdebcb; }
.flash.error { background: #fdeaea; color: #9b1c1c; border: 1px solid #f6c6c6; }

/* ---------- Auth / landing ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-box { width: 100%; max-width: 420px; }
.brandmark { font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.brandmark span { color: var(--brand); }
.center { text-align: center; }
.muted { color: var(--muted); }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }

.hero { text-align: center; padding: 48px 16px 24px; }
.hero h1 { font-size: 30px; letter-spacing: -.02em; }
.hero p { color: var(--muted); font-size: 18px; max-width: 560px; margin: 0 auto 24px; }
.features { display: grid; gap: 16px; margin-top: 32px; align-items: stretch; }
@media (min-width: 720px) { .features { grid-template-columns: repeat(3, 1fr); } }
/* Las tarjetas de la grilla no llevan el margen de apilado del panel. */
.features .card + .card { margin-top: 0; }
.feature { margin: 0; height: 100%; display: flex; flex-direction: column; }
.feature .ico { font-size: 28px; }

/* ---------- Layout panel ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .inner { max-width: var(--maxw); margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; }
.topbar--admin { border-bottom-color: #111827; box-shadow: inset 0 -3px 0 var(--brand); }
.admin-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; background: var(--brand); color: #fff; padding: 2px 6px; border-radius: 6px; vertical-align: middle; }
.tabs { display: flex; gap: 4px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 53px; z-index: 19; }
.tabs a { padding: 12px 16px; white-space: nowrap; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

.stat-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .num { font-size: 28px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ---------- Listas / tablas simples ---------- */
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--bg); flex: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .name { font-weight: 600; }
.list-item .sub { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.nuevo { background: #dbeafe; color: #1e40af; }
.badge.preparando { background: #fef3c7; color: #92400e; }
.badge.listo { background: #dcfce7; color: #166534; }
.badge.entregado { background: #e5e7eb; color: #374151; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* Filtros de pedidos */
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.filter-tabs a {
    padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
    color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.filter-tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.range-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-top: 12px; }
.range-form label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.range-form input[type=date] { width: auto; }
.summary-pill {
    display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px;
    border-top: 1px solid var(--border); color: var(--muted); font-size: 14px;
}
.summary-pill strong { color: var(--text); }
.filter-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 16px; }
.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.search-form input[type=search] { flex: 1; min-width: 180px; }

/* ============================================================= */
/* ===============  TIENDA PÚBLICA (con tema)  ================= */
/* ============================================================= */
body.store {
    --s-bg: #f6f7f9; --s-surface: #fff; --s-text: #1c1f24; --s-muted: #6b7280; --s-border: #e5e7eb;
    background: var(--s-bg); color: var(--s-text);
}
body.store[data-theme="dark"] {
    --s-bg: #0f1115; --s-surface: #1a1d23; --s-text: #f3f4f6; --s-muted: #9ca3af; --s-border: #2b2f37;
}
body.store .card { background: var(--s-surface); border-color: var(--s-border); color: var(--s-text); }

.store-banner { width: 100%; background: var(--s-surface); }
.store-banner img { display: block; width: 100%; max-height: 240px; object-fit: cover; }
.store-header { background: var(--s-surface); border-bottom: 1px solid var(--s-border); padding: 20px 16px; text-align: center; }
.store-header .logo { width: 84px; height: 84px; border-radius: 18px; object-fit: cover; margin: 0 auto 10px; box-shadow: var(--shadow); }
.store-header h1 { font-size: 24px; color: var(--brand); margin-bottom: 0; }
.store-slogan { color: var(--s-muted); margin: 6px 0 0; font-size: 15px; }

.cat-title { margin: 24px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--s-muted); }
.products { display: grid; gap: 12px; }
@media (min-width: 640px) { .products { grid-template-columns: 1fr 1fr; } }

.product {
    background: var(--s-surface); border: 1px solid var(--s-border); border-radius: var(--radius);
    overflow: hidden; display: flex; gap: 12px; padding: 12px; align-items: center;
}
.product .pimg { width: 80px; height: 80px; border-radius: 10px; object-fit: cover; background: var(--s-bg); flex: none; }
.product .pinfo { flex: 1; min-width: 0; }
.product .pname { font-weight: 700; }
.product .pdesc { color: var(--s-muted); font-size: 13px; margin-top: 2px; }
.product .pprice { font-weight: 800; color: var(--brand); margin-top: 6px; }
.product .add { flex: none; }
.product--soldout { opacity: 0.65; }
.product--soldout .pimg { filter: grayscale(1); }
.soldout-tag {
    display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700; background: #fee2e2; color: #b91c1c; vertical-align: middle;
}
.qty-ctrl { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--brand); border-radius: 999px; overflow: hidden; }
.qty-ctrl button { background: var(--brand); color: #fff; border: none; width: 34px; height: 34px; font-size: 18px; cursor: pointer; }
.qty-ctrl .q { min-width: 28px; text-align: center; font-weight: 700; }
.iconbtn { background: var(--brand); color: #fff; border: none; width: 38px; height: 38px; border-radius: 999px; font-size: 22px; line-height: 1; cursor: pointer; }

/* Barra de carrito fija (móvil) */
.cart-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--brand); color: #fff; padding: 12px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .15); transform: translateY(120%); transition: transform .2s;
}
.cart-bar.show { transform: translateY(0); }
.cart-bar .total { font-weight: 800; }
.cart-bar button { background: #fff; color: var(--brand); border: none; padding: 10px 16px; border-radius: 999px; font-weight: 700; cursor: pointer; }

/* Modal carrito / checkout */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 40; display: none; align-items: flex-end; justify-content: center; }
.modal.show { display: flex; }
.modal-card {
    background: var(--s-surface); color: var(--s-text); width: 100%; max-width: 520px;
    border-radius: 18px 18px 0 0; padding: 20px; max-height: 90vh; overflow-y: auto;
}
@media (min-width: 560px) { .modal { align-items: center; } .modal-card { border-radius: 18px; } }
.modal-card h2 { font-size: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head .close { background: none; border: none; font-size: 26px; cursor: pointer; color: var(--s-muted); line-height: 1; }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--s-border); }
.cart-line .grow { flex: 1; min-width: 0; }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; }
.seg .opt { display: block; text-align: center; padding: 10px; border: 1px solid var(--s-border); border-radius: var(--radius); cursor: pointer; font-weight: 600; }
.seg input:checked + .opt { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.err-box { background: #fdeaea; color: #9b1c1c; border: 1px solid #f6c6c6; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 12px; display: none; }
.err-box.show { display: block; }

/* Página de pedido */
.order-summary .line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--s-border); }
.order-summary .total { font-weight: 800; font-size: 18px; padding-top: 12px; }
#qrcode { display: flex; justify-content: center; margin: 16px 0; }
#qrcode img, #qrcode canvas { border-radius: 12px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }

.spacer-bottom { height: 90px; }

/* Pie de página */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 24px 0; background: var(--surface); }
.foot-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.foot-links { display: flex; flex-wrap: wrap; gap: 16px; }
.foot-links a { color: var(--muted); font-weight: 600; font-size: 14px; }
.foot-links a:hover { color: var(--brand); }

/* Páginas legales */
.legal { max-width: 760px; padding-top: 24px; padding-bottom: 24px; }
.legal h1 { font-size: 28px; }
.legal h2 { font-size: 18px; margin-top: 28px; }
.legal p, .legal li { color: var(--text); line-height: 1.7; }
.legal ul { padding-left: 20px; }

/* FAQ */
.faq { display: grid; gap: 12px; margin-top: 16px; }
@media (min-width: 640px) { .faq { grid-template-columns: 1fr 1fr; } }
.faq .card { margin: 0; }
.faq .card + .card { margin-top: 0; }
.faq h3 { font-size: 16px; }

/* Contenedor de anuncios */
.ad-slot { position: relative; }
.ad-slot ins { display: block; }
.ad-label {
    display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--s-muted, #9ca3af); margin-bottom: 4px;
}
/* Banner a todo el ancho (arriba/abajo) */
.ad-banner {
    margin: 20px 0; padding: 10px; border: 1px dashed var(--s-border, #e5e7eb);
    border-radius: var(--radius); background: var(--s-surface, #fff); min-height: 60px;
}
/* Intercalado: separador a todo el ancho de la grilla */
.ad-inline--separator {
    grid-column: 1 / -1; padding: 10px; border: 1px dashed var(--s-border, #e5e7eb);
    border-radius: var(--radius); background: var(--s-surface, #fff); min-height: 60px;
}
/* Intercalado: con el mismo formato que un producto (una celda de la grilla) */
.ad-inline--card {
    border: 1px solid var(--s-border, #e5e7eb); border-radius: var(--radius);
    background: var(--s-surface, #fff); padding: 12px; min-height: 104px;
    display: flex; flex-direction: column; justify-content: center;
}

/* ---------- Tickets de soporte (hilo de mensajes) ---------- */
.ticket-thread { display: flex; flex-direction: column; gap: 10px; }
.ticket-msg { max-width: 85%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); }
.ticket-msg--store { align-self: flex-end; background: #eff6ff; border-color: #bfdbfe; }
.ticket-msg--admin { align-self: flex-start; background: var(--bg); }
.ticket-msg__who { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.ticket-msg__body { white-space: pre-wrap; word-break: break-word; }
.ticket-msg__img { margin-top: 8px; max-width: 220px; max-height: 220px; border-radius: 10px; display: block; border: 1px solid var(--border); }
