/* ============================================================
   style.css — Estilos globales del Marketplace
   Filosofía: mobile-first (diseñamos para pantalla pequeña primero)
   Paleta inspirada en la imagen de referencia:
     Primario:   #2563EB (azul vibrante)
     Fondo:      #EEF2FF (azul muy claro)
     Tarjeta:    #FFFFFF
     Amarillo:   #F59E0B (precio, estrellas)
     Verde:      #10B981 (stock disponible)
     Rojo:       #EF4444 (favorito activo, stock bajo)
   ============================================================ */

/* ---------- Variables CSS (custom properties) ---------- */
:root {
    --blue:       #2563EB;
    --blue-light: #EEF2FF;
    --blue-mid:   #DBEAFE;
    --yellow:     #F59E0B;
    --green:      #10B981;
    --red:        #EF4444;
    --gray-1:     #F9FAFB;
    --gray-2:     #E5E7EB;
    --gray-3:     #9CA3AF;
    --gray-4:     #6B7280;
    --text:       #111827;
    --white:      #FFFFFF;

    --radius-sm:  10px;
    --radius-md:  16px;
    --radius-lg:  24px;

    /* Altura de la barra de navegación inferior */
    --nav-height: 64px;
}

/* ---------- Modo oscuro ----------
   Se activa añadiendo la clase "dark" al <body> desde app.js.
   Las variables cambian y todos los elementos que las usan se adaptan. */
body.dark {
    --blue-light: #0F172A;
    --blue-mid:   #1E3A5F;
    --gray-1:     #1A2535;   /* fondo de inputs y áreas secundarias */
    --gray-2:     #2D3F55;   /* bordes */
    --gray-3:     #64748B;   /* texto desactivado */
    --gray-4:     #A0B0C8;   /* texto secundario — más claro que antes para mejor contraste */
    --text:       #E8F0FE;   /* texto principal — blanco azulado */
    --white:      #162032;   /* superficie de tarjetas y topbar */
    background:   #0A1628;
}

/* Inputs, textareas y selects necesitan color explícito porque
   los navegadores aplican su propio color que no hereda --text */
body.dark input,
body.dark textarea,
body.dark select {
    color: var(--text);
    background: var(--gray-1);
    border-color: var(--gray-2);
    color-scheme: dark; /* evita el fondo blanco del navegador en selects */
}

body.dark input::placeholder,
body.dark textarea::placeholder {
    color: var(--gray-3);
}

/* La barra de navegación inferior necesita sombra superior visible */
body.dark .bottom-nav {
    border-top-color: var(--gray-2);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.4);
}

/* El topbar sticky necesita separación visible del contenido */
body.dark .topbar {
    box-shadow: 0 1px 8px rgba(0,0,0,0.4);
}

/* Page header */
body.dark .page-header {
    border-bottom-color: var(--gray-2);
}

/* Las tarjetas de producto necesitan sombra diferenciada */
body.dark .product-card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* El borde de inputs al hacer focus en modo oscuro */
body.dark .search-bar__input:focus,
body.dark .form-input:focus {
    background: var(--gray-1);
    border-color: var(--blue);
}

/* El chip de categoría activo ya usa --blue, pero el inactivo
   necesita más contraste en modo oscuro */
body.dark .category-chip {
    border-color: var(--gray-2);
    color: var(--gray-4);
}

/* Menú de perfil */
body.dark .profile-menu-item {
    border-bottom-color: var(--gray-2);
    color: var(--text);
}

/* Sección de ajustes */
body.dark .setting-row {
    border-bottom-color: var(--gray-2);
}

/* Badges de estado con fondo hardcodeado — ajuste para oscuro */
body.dark .order-badge.pending   { background: #3D2E00; color: #FCD34D; }
body.dark .order-badge.shipped   { background: #1E3A5F; color: #93C5FD; }
body.dark .order-badge.delivered { background: #064E3B; color: #6EE7B7; }

/* ---------- Reset básico ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    /* Previene zoom involuntario en iOS al enfocar inputs */
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--blue-light);
    color: var(--text);
    /* Espacio inferior para que el contenido no quede bajo la nav */
    padding-bottom: calc(var(--nav-height) + 16px);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font: inherit;
}

input, textarea, select {
    font: inherit;
}

/* ---------- Utilidades ---------- */
.container {
    max-width: 480px;   /* ancho máximo para simular pantalla móvil */
    margin: 0 auto;
    padding: 0 16px;
}

.sr-only {
    /* Texto solo visible para lectores de pantalla (accesibilidad) */
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Topbar (cabecera de página) ---------- */
.topbar {
    background: var(--white);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.topbar__logo {
    font-size: 22px;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.topbar__greeting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--blue-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    overflow: hidden;
}

.topbar__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.topbar__welcome {
    font-size: 11px;
    color: var(--gray-4);
}

.topbar__name {
    font-size: 14px;
    font-weight: 600;
}

/* Botón del carrito en el topbar */
.topbar__cart-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--blue-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.cart-badge {
    /* Número rojo sobre el ícono del carrito */
    position: absolute;
    top: -4px; right: -4px;
    background: var(--red);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none; /* oculto si el carrito está vacío */
}

.cart-badge.visible {
    display: flex;
}

/* ---------- Barra de búsqueda ---------- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-bar__input-wrap {
    flex: 1;
    position: relative;
}

.search-bar__icon {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--gray-3);
    font-size: 16px;
    pointer-events: none;
}

.search-bar__input {
    width: 100%;
    padding: 11px 14px 11px 40px;
    border: 1.5px solid var(--gray-2);
    border-radius: var(--radius-md);
    background: var(--gray-1);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar__input:focus {
    border-color: var(--blue);
    background: var(--white);
}

.search-bar__filter-btn {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    background: var(--blue);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

/* ---------- Chips de categorías ---------- */
.categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;         /* scroll horizontal */
    padding: 16px 16px 4px;
    scrollbar-width: none;    /* oculta scrollbar en Firefox */
}

.categories::-webkit-scrollbar {
    display: none;            /* oculta scrollbar en Chrome/Safari */
}

.category-chip {
    flex-shrink: 0;           /* no se encoge aunque no haya espacio */
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;     /* píldora */
    background: var(--white);
    border: 1.5px solid var(--gray-2);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-4);
    transition: all 0.15s;
}

.category-chip.active,
.category-chip:hover {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--white);
}

/* ---------- Banner promocional ---------- */
.promo-banner {
    margin: 12px 16px;
    background: linear-gradient(135deg, var(--blue) 0%, #1D4ED8 100%);
    border-radius: var(--radius-lg);
    padding: 20px;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
}

/* Círculo decorativo detrás del banner */
.promo-banner::before {
    content: '';
    position: absolute;
    right: -30px; top: -30px;
    width: 140px; height: 140px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
}

.promo-banner__text {
    flex: 1;
}

.promo-banner__tag {
    font-size: 11px;
    background: rgba(255,255,255,0.2);
    padding: 3px 8px;
    border-radius: 999px;
    display: inline-block;
    margin-bottom: 6px;
}

.promo-banner__title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 4px;
}

.promo-banner__sub {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 14px;
}

.promo-banner__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--yellow);
    color: #1A1A1A;
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.promo-banner__img {
    width: 100px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

/* ---------- Sección con título ---------- */
.section {
    padding: 0 16px;
    margin-top: 20px;
}

.section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section__title {
    font-size: 17px;
    font-weight: 700;
}

.section__link {
    font-size: 13px;
    color: var(--blue);
    font-weight: 500;
}

/* ---------- Grid de productos (2 columnas) ---------- */
.products-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ---------- Tarjeta de producto ---------- */
.product-card {
    background: var(--white);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
}

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

.product-card__img-wrap {
    position: relative;
    aspect-ratio: 1;        /* cuadrado perfecto */
    background: var(--gray-1);
    overflow: hidden;
}

.product-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Emoji/placeholder cuando no hay imagen */
.product-card__img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

/* Precio superpuesto sobre la imagen */
.product-card__price-badge {
    position: absolute;
    bottom: 8px; left: 4px;
    background: var(--blue);
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    max-width: calc(100% - 8px);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Botón de favorito (corazón) */
.product-card__fav-btn {
    position: absolute;
    right: 8px;
    width: 30px; height: 30px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    transition: transform 0.15s;
}

.product-card__fav-btn:active {
    transform: scale(1.2);
}

.product-card__fav-btn.active {
    color: var(--red);
}

/* Información de texto de la tarjeta */
.product-card__info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.product-card__stock {
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
}

.product-card__stock.low {
    color: var(--red);
}

.product-card__rating {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--gray-4);
}

.product-card__stars {
    color: var(--yellow);
    font-size: 12px;
}

.product-card__name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text);
    /* Limita a 2 líneas con puntos suspensivos */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Barra de navegación inferior ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--white);
    border-top: 1px solid var(--gray-2);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 200;
    max-width: 480px;
    margin: 0 auto;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 0;
    color: var(--gray-3);
    font-size: 11px;
    font-weight: 500;
    transition: color 0.15s;
}

.nav-item.active {
    color: var(--blue);
}

.nav-item__icon {
    font-size: 20px;
    line-height: 1;
}

/* Botón circular de "Vender" en el nav */
.nav-item--sell {
    color: var(--blue);
}

.nav-sell-btn {
    background: var(--blue);
    color: white;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
    font-size: 20px;
}

/* Indicador de punto azul bajo el ícono activo */
.nav-item.active::after {
    content: '';
    width: 5px; height: 5px;
    background: var(--blue);
    border-radius: 50%;
    margin-top: 2px;
}

/* ---------- Página de detalle de producto ---------- */
.product-detail {
    background: var(--white);
    min-height: 100vh;
}

.product-detail__img-wrap {
    width: 100%;
    aspect-ratio: 1;
    background: var(--gray-1);
    position: relative;
    overflow: hidden;
}

.product-detail__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-detail__back {
    position: absolute;
    top: 16px; left: 16px;
    width: 36px; height: 36px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    z-index: 10;
}

.product-detail__fav {
    position: absolute;
    top: 16px; right: 16px;
    width: 36px; height: 36px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    z-index: 10;
}

.product-detail__fav.active {
    color: var(--red);
}

.product-detail__body {
    padding: 20px 16px;
}

.product-detail__category {
    font-size: 12px;
    color: var(--blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.product-detail__name {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 10px;
}

.product-detail__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.product-detail__price {
    font-size: 26px;
    font-weight: 800;
    color: var(--blue);
}

.product-detail__stock-info {
    font-size: 13px;
    color: var(--green);
    font-weight: 600;
}

.product-detail__rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.product-detail__desc {
    font-size: 14px;
    color: var(--gray-4);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Selector de cantidad */
.qty-control {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--gray-1);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: fit-content;
    margin-bottom: 20px;
}

.qty-control__btn {
    width: 40px; height: 40px;
    font-size: 20px;
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.qty-control__btn:hover {
    background: var(--blue-mid);
}

.qty-control__val {
    width: 44px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
}

/* Botón principal "Agregar al carrito" */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px;
    background: var(--blue);
    color: var(--white);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    transition: background 0.15s, transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.98);
    background: #1D4ED8;
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--white);
    color: var(--blue);
    border: 2px solid var(--blue);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.15s;
}

/* ---------- Carrito ---------- */
.cart-item {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.cart-item__img {
    width: 70px; height: 70px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--gray-1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.cart-item__info {
    flex: 1;
}

.cart-item__name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.cart-item__price {
    font-size: 15px;
    font-weight: 700;
    color: var(--blue);
}

.cart-item__remove {
    color: var(--gray-3);
    font-size: 20px;
    padding: 4px;
}

/* Resumen del total del carrito */
.cart-summary {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 12px;
}

.cart-summary__row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--gray-4);
    margin-bottom: 8px;
}

.cart-summary__row.total {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-2);
}

/* ---------- Formulario de venta ---------- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-4);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--gray-2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--white);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--blue);
}

.form-input.error {
    border-color: var(--red);
}

.form-select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--gray-2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--white);
    outline: none;
    cursor: pointer;
}

/* Zona de subida de imagen */
.upload-zone {
    border: 2px dashed var(--gray-2);
    border-radius: var(--radius-md);
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover {
    border-color: var(--blue);
    background: var(--blue-light);
}

.upload-zone__icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.upload-zone__text {
    font-size: 14px;
    color: var(--gray-4);
}

.upload-zone__preview {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    display: none;
}

/* ---------- Página de login/registro ---------- */
.auth-page {
    padding: 32px 24px;
    max-width: 480px;
    margin: 0 auto;
}

.auth-logo {
    text-align: center;
    font-size: 48px;
    margin-bottom: 8px;
}

.auth-title {
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
}

.auth-sub {
    text-align: center;
    font-size: 14px;
    color: var(--gray-4);
    margin-bottom: 28px;
}

.auth-tabs {
    display: flex;
    background: var(--gray-1);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    color: var(--gray-4);
    transition: all 0.15s;
}

.auth-tab.active {
    background: var(--white);
    color: var(--blue);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.auth-error {
    background: #FEE2E2;
    color: var(--red);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}

/* ---------- Órdenes ---------- */
.order-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
}

.order-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.order-card__id {
    font-size: 13px;
    color: var(--gray-4);
}

.order-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
}

.order-badge.pending  { background: #FEF3C7; color: #92400E; }
.order-badge.shipped  { background: #DBEAFE; color: #1E40AF; }
.order-badge.delivered{ background: #D1FAE5; color: #065F46; }

.order-card__total {
    font-size: 18px;
    font-weight: 700;
    color: var(--blue);
}

/* ---------- Perfil ---------- */
.profile-header {
    background: var(--white);
    padding: 24px 16px 16px;
    text-align: center;
    margin-bottom: 12px;
}

.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--blue-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 10px;
    overflow: hidden;
}

.profile-name {
    font-size: 18px;
    font-weight: 700;
}

.profile-email {
    font-size: 13px;
    color: var(--gray-4);
}

.profile-menu {
    background: var(--white);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-bottom: 1px solid var(--gray-2);
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    transition: background 0.15s;
}

.profile-menu-item:last-child {
    border-bottom: none;
}

.profile-menu-item:hover {
    background: var(--gray-1);
}

.profile-menu-item__icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.profile-menu-item.danger {
    color: var(--red);
}

/* ---------- Toast / notificación flotante ---------- */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    left: 50%; right: auto;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 999;
    white-space: nowrap;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}

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

/* ---------- Página vacía (carrito vacío, sin productos, etc.) ---------- */
.empty-state {
    text-align: center;
    padding: 60px 24px;
}

.empty-state__icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state__title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-state__text {
    font-size: 14px;
    color: var(--gray-4);
    margin-bottom: 24px;
}

/* ---------- Page header (para páginas internas) ---------- */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header__back {
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 20px;
    transition: background 0.15s;
}

.page-header__back:hover {
    background: var(--gray-1);
}

.page-header__title {
    font-size: 17px;
    font-weight: 700;
    flex: 1;
}

/* ---------- Filtros de categoría (página de listado) ---------- */
.filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 16px;
    scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--gray-2);
    background: var(--white);
    font-size: 13px;
    color: var(--gray-4);
    font-weight: 500;
    transition: all 0.15s;
}

.filter-chip.active {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--white);
}

/* ---------- Barra de carrito flotante (tipo "Ver carrito 3x $256") ---------- */
.cart-bar {
    position: fixed;
    bottom: calc(var(--nav-height) + 8px);
    left: 16px; right: 16px;
    max-width: calc(480px - 32px);
    margin: 0 auto;
    background: var(--blue);
    color: var(--white);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(37,99,235,0.4);
    z-index: 150;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    cursor: pointer;
}

.cart-bar.visible {
    transform: translateY(0);
    opacity: 1;
}

.cart-bar__left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-bar__count {
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.cart-bar__label {
    font-size: 15px;
    font-weight: 600;
}

.cart-bar__total {
    font-size: 16px;
    font-weight: 700;
}

/* ---------- Loader ---------- */
.loader {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--blue-mid);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ---------- Nav badge (mensajes no leídos) ---------- */
.nav-badge {
    display: none;
    position: absolute;
    top: -4px; right: -6px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---------- Chat: lista de conversaciones (inbox) ---------- */
.chat-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-2);
    cursor: pointer;
    background: var(--white);
    transition: background 0.15s;
}
.chat-item:active { background: var(--gray-1); }

.chat-avatar {
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--blue-mid);
    color: var(--blue);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item-info { flex: 1; min-width: 0; }

.chat-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 2px;
}

.chat-item-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-item-time {
    font-size: 11px;
    color: var(--gray-4);
    flex-shrink: 0;
}

.chat-item-product {
    font-size: 11px;
    color: var(--blue);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-preview {
    font-size: 13px;
    color: var(--gray-4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    background: var(--blue);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
}

/* ---------- Chat: burbujas de mensajes ---------- */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    padding-bottom: calc(var(--nav-height) + 60px);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-group {
    display: flex;
    flex-direction: column;
    max-width: 78%;
}
.msg-group--mine  { align-self: flex-end;  align-items: flex-end; }
.msg-group--theirs { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}
.msg-bubble--mine {
    background: var(--blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-bubble--theirs {
    background: var(--gray-2);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.msg-time {
    font-size: 10px;
    color: var(--gray-4);
    margin-top: 3px;
    padding: 0 4px;
}

/* ---------- Chat: input fijo ---------- */
.chat-input-bar {
    position: fixed;
    bottom: var(--nav-height);
    left: 0; right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--white);
    border-top: 1px solid var(--gray-2);
    z-index: 50;
}

.chat-input {
    flex: 1;
    height: 40px;
    padding: 0 14px;
    border: 1.5px solid var(--gray-2);
    border-radius: 999px;
    background: var(--gray-1);
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.chat-input:focus { border-color: var(--blue); }

.chat-send-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-send-btn:active { opacity: 0.8; }

/* ---- Badge de cuenta verificada ---- */
.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 700;
    color: #2563EB;
    background: #EFF6FF;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
    vertical-align: middle;
}
.verified-badge i { font-size: 10px; }
body.dark .verified-badge { background: #1E3A5F; color: #93C5FD; }
