/* ============================================================
   ESTILOS COMPARTIDOS - Catálogo y Administración
   ============================================================ */

:root {
    --color-bg: #f7f7f8;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-primary: #111827;
    --color-accent: #16a34a;       /* verde WhatsApp */
    --color-accent-dark: #128c3e;
    --color-sale: #dc2626;         /* rojo oferta */
    --radius: 14px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .05);
    --max-width: 1200px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px;
}

/* ---------------- Barra superior de anuncio ---------------- */
.topbar {
    background: var(--color-primary);
    color: #fff;
    text-align: center;
    font-size: .82rem;
    padding: 8px 12px;
    letter-spacing: .3px;
}

/* ---------------- Header / navegación ---------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: saturate(180%) blur(6px);
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.brand {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 1px;
}
.brand small { display: block; font-size: .6rem; font-weight: 500; color: var(--color-muted); letter-spacing: 2px; }
.header-actions a {
    font-size: .9rem;
    color: var(--color-muted);
    padding: 8px 12px;
    border-radius: 8px;
}
.header-actions a:hover { color: var(--color-text); background: var(--color-bg); }

/* ---------------- Hero ---------------- */
.hero {
    text-align: center;
    padding: 48px 16px 24px;
}
.hero .eyebrow {
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: .72rem;
    color: var(--color-muted);
    margin-bottom: 10px;
}
.hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    margin-bottom: 10px;
}
.hero p { color: var(--color-muted); max-width: 560px; margin: 0 auto; }

/* ---------------- Filtros de categoría ---------------- */
.filters {
    position: sticky;
    top: 64px;
    z-index: 40;
    background: var(--color-bg);
    padding: 16px 0;
}
.filters-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}
.chip {
    flex: 0 0 auto;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 9px 18px;
    border-radius: 999px;
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all .15s ease;
}
.chip:hover { border-color: var(--color-primary); }
.chip.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* ---------------- Grid de productos ---------------- */
.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 28px 0 14px;
    padding-left: 4px;
}
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px;
    padding-bottom: 40px;
}
.product-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .18s ease, box-shadow .18s ease;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.product-media {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #eef0f2;
    overflow: hidden;
}
.product-media img { width: 100%; height: 100%; object-fit: cover; }
.product-media .no-image {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: var(--color-muted); font-size: .85rem;
}
.badge-sale {
    position: absolute;
    top: 10px; left: 10px;
    background: var(--color-sale);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
}
.product-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-name { font-weight: 700; font-size: 1rem; }
.product-desc { color: var(--color-muted); font-size: .85rem; flex: 1; }
.product-price { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.price-current { font-size: 1.15rem; font-weight: 800; }
.price-old { color: var(--color-muted); text-decoration: line-through; font-size: .9rem; }
.price-sale { color: var(--color-sale); }

/* ---------------- Botón WhatsApp ---------------- */
.btn-whatsapp {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--color-accent);
    color: #fff;
    border: none;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: .92rem;
    width: 100%;
    transition: background .15s ease;
}
.btn-whatsapp:hover { background: var(--color-accent-dark); }
.btn-whatsapp svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------------- Botón flotante WhatsApp ---------------- */
.fab-whatsapp {
    position: fixed;
    bottom: 22px; right: 22px;
    z-index: 60;
    background: var(--color-accent);
    color: #fff;
    border-radius: 999px;
    padding: 14px 20px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 30px rgba(22,163,74,.4);
}
.fab-whatsapp svg { width: 22px; height: 22px; fill: currentColor; }

/* ---------------- Estados vacíos / carga ---------------- */
.empty-state, .loading-state {
    text-align: center;
    color: var(--color-muted);
    padding: 60px 20px;
}
.spinner {
    width: 34px; height: 34px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   ADMIN
   ============================================================ */
.admin-body { background: var(--color-bg); }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card p { color: var(--color-muted); font-size: .9rem; margin-bottom: 20px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
}
.form-control:focus { outline: 2px solid var(--color-primary); outline-offset: 0; border-color: transparent; }
textarea.form-control { resize: vertical; min-height: 80px; }

.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    font-size: .92rem;
    transition: filter .15s ease, background .15s ease;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-block { width: 100%; }
.btn-danger { background: var(--color-sale); color: #fff; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

.admin-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.admin-header .container {
    display: flex; align-items: center; justify-content: space-between;
    height: 60px;
}
.admin-main { padding: 24px 0 60px; }

.admin-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 860px) {
    .admin-grid { grid-template-columns: 1fr; }
}

/* Pestañas del admin */
.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
}
.tab-btn {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--color-muted);
    font-size: .95rem;
    font-weight: 700;
    padding: 12px 18px;
    margin-bottom: -1px;
    transition: color .15s ease, border-color .15s ease;
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.admin-pager { padding: 16px 0 4px; }

.panel-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; }

/* tabla / listas admin */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    margin-bottom: 8px;
    background: #fff;
}
.list-item img {
    width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: #eef0f2;
}
.list-item .info { flex: 1; min-width: 0; }
.list-item .info strong { display: block; font-size: .92rem; }
.list-item .info span { font-size: .8rem; color: var(--color-muted); }
.list-item .actions { display: flex; gap: 6px; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.toast {
    position: fixed;
    bottom: 20px; left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--color-primary);
    color: #fff;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: .9rem;
    box-shadow: var(--shadow);
    transition: transform .3s ease;
    z-index: 100;
    max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--color-sale); }
.toast.success { background: var(--color-accent); }

.hidden { display: none !important; }

.muted-small { color: var(--color-muted); font-size: .82rem; }

.thumb-preview {
    width: 100%;
    max-width: 160px;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    margin-top: 8px;
    background: #eef0f2;
}


/* ============================================================
   BUSCADOR + FILTROS (catálogo)
   ============================================================ */
.filters-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 14px;
    color: var(--color-muted);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 11px 14px 11px 42px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: .95rem;
    font-family: inherit;
    background: var(--color-surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, .08);
}

/* Info de resultados */
.result-info {
    color: var(--color-muted);
    font-size: .85rem;
    margin: 4px 4px 16px;
}

/* ============================================================
   PAGINACIÓN
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 48px;
}
.page-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 10px;
    font-weight: 600;
    font-size: .92rem;
    transition: all .15s ease;
}
.page-btn:hover:not(:disabled):not(.active) { border-color: var(--color-primary); }
.page-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    cursor: default;
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-dots { color: var(--color-muted); padding: 0 4px; }

/* ============================================================
   IMÁGENES EN TARJETAS (zoom / contador)
   ============================================================ */
.product-media.is-clickable { cursor: zoom-in; }
.media-zoom {
    position: absolute;
    bottom: 10px; right: 10px;
    width: 34px; height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(17, 24, 39, .65);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .18s ease, background .18s ease;
}
.product-card:hover .media-zoom { opacity: 1; }
.media-zoom:hover { background: rgba(17, 24, 39, .9); }
.media-count {
    position: absolute;
    bottom: 10px; left: 10px;
    background: rgba(17, 24, 39, .65);
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 999px;
}

/* ============================================================
   LIGHTBOX (visor de imágenes)
   ============================================================ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.lightbox.open { display: flex; }
.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    backdrop-filter: blur(2px);
}
.lightbox-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    gap: 12px;
}
.lightbox-title { font-weight: 700; font-size: 1.05rem; }
.lightbox-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    padding: 0 6px;
    opacity: .85;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-img {
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 10px;
    background: #111;
}
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px; height: 46px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, .3); }
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }
.lightbox-counter {
    text-align: center;
    color: #fff;
    font-size: .88rem;
    opacity: .8;
}
.lightbox-thumbs {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    max-height: 96px;
    overflow-y: auto;
}
.lb-thumb {
    width: 60px; height: 60px;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    background: #222;
    opacity: .6;
    transition: opacity .15s ease, border-color .15s ease;
}
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lb-thumb.active { border-color: #fff; opacity: 1; }
.lb-thumb:hover { opacity: 1; }

/* ============================================================
   GALERÍA DE IMÁGENES (admin)
   ============================================================ */
.img-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.img-item {
    position: relative;
    width: 84px; height: 84px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    background: #eef0f2;
}
.img-item.is-primary { border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-accent); }
.img-item img { width: 100%; height: 100%; object-fit: cover; }
.img-primary-tag {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: var(--color-accent);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    text-align: center;
    padding: 2px 0;
    letter-spacing: .3px;
}
.img-item-actions {
    position: absolute;
    top: 4px; right: 4px;
    display: flex;
    gap: 4px;
}
.img-btn {
    width: 22px; height: 22px;
    border: none;
    border-radius: 6px;
    background: rgba(17, 24, 39, .7);
    color: #fff;
    font-size: .72rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.img-btn:hover { background: rgba(17, 24, 39, .95); }
.img-btn-del:hover { background: var(--color-sale); }


/* ============================================================
   CARRITO
   ============================================================ */

/* Acciones dentro de la tarjeta */
.product-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.product-actions .btn-whatsapp { margin-top: 0; }

/* Botón Agregar al carrito */
.btn-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: .92rem;
    width: 100%;
    transition: filter .15s ease, background .15s ease;
}
.btn-add:hover { filter: brightness(1.18); }
.btn-add svg { fill: currentColor; }
.btn-add.added { background: var(--color-accent); }

/* Ícono de carrito en el header */
.cart-toggle {
    position: relative;
    background: transparent;
    border: none;
    color: var(--color-text);
    padding: 8px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}
.cart-toggle:hover { background: var(--color-bg); }
.cart-toggle svg { fill: currentColor; }
.cart-badge {
    position: absolute;
    top: 0; right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--color-accent);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Drawer del carrito */
.cart-drawer {
    position: fixed;
    inset: 0;
    z-index: 210;
    display: none;
}
.cart-drawer.open { display: block; }
.cart-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(2px);
}
.cart-panel {
    position: absolute;
    top: 0; right: 0;
    height: 100%;
    width: 400px;
    max-width: 92vw;
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(0, 0, 0, .18);
    transform: translateX(100%);
    animation: cart-slide-in .25s ease forwards;
}
@keyframes cart-slide-in { to { transform: translateX(0); } }
.cart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--color-border);
}
.cart-title { font-size: 1.2rem; font-weight: 800; }
.cart-close {
    background: transparent;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--color-muted);
    padding: 0 6px;
}
.cart-close:hover { color: var(--color-text); }

.cart-items { flex: 1; overflow-y: auto; padding: 12px 16px; }
.cart-empty { text-align: center; color: var(--color-muted); padding: 48px 16px; font-size: .92rem; }

.cart-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}
.cart-thumb {
    width: 62px; height: 62px;
    border-radius: 10px;
    overflow: hidden;
    background: #eef0f2;
    flex: 0 0 auto;
}
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-noimg {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: .62rem; color: var(--color-muted); text-align: center;
}
.cart-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cart-info strong { font-size: .92rem; }
.cart-unit { font-size: .78rem; color: var(--color-muted); }
.cart-qty {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}
.qty-btn {
    width: 28px; height: 28px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 8px;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
}
.qty-btn:hover { border-color: var(--color-primary); }
.qty-val { min-width: 20px; text-align: center; font-weight: 700; font-size: .92rem; }
.cart-line-end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
}
.cart-line-total { font-weight: 800; font-size: .95rem; white-space: nowrap; }
.cart-remove {
    background: transparent;
    border: none;
    color: var(--color-muted);
    font-size: 1.3rem;
    line-height: 1;
    padding: 0 4px;
}
.cart-remove:hover { color: var(--color-sale); }

.cart-foot {
    border-top: 1px solid var(--color-border);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cart-total-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 1rem;
}
.cart-total-row strong { font-size: 1.35rem; font-weight: 800; }
.cart-send { margin-top: 0; }
.cart-clear {
    background: transparent;
    border: none;
    color: var(--color-muted);
    font-size: .85rem;
    text-decoration: underline;
    padding: 2px;
}
.cart-clear:hover { color: var(--color-sale); }
