/* =====================================================================
   MAYORISTAS — franja de portada y apartado /mayoristas
   Sólo tokens de la tienda (--t-*): el modo oscuro los redefine, así que
   esto no necesita reglas propias en tienda-oscuro.css.
   ===================================================================== */

/* [hidden] explícito: estas cajas declaran display y, sin esto, el
   atributo hidden no las esconde. */
.t-mayor-banda[hidden],
.t-mayor[hidden],
.t-mayor__barra[hidden] { display: none !important; }

/* ---------- Franja en la portada ---------- */
.t-mayor-banda {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
    align-items: center;
    gap: 28px;
    margin: 0 0 32px;
    padding: 26px 30px;
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius);
    background: var(--t-surface);
}
.t-mayor-banda__copy h2 {
    margin: 6px 0 6px;
    font-size: clamp(1.25rem, 2.2vw, 1.6rem);
    line-height: 1.15;
    color: var(--t-ink);
}
.t-mayor-banda__copy p { margin: 0; color: var(--t-muted); font-size: .92rem; line-height: 1.5; }
.t-mayor-banda__reglas {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}
.t-mayor-banda__reglas > div {
    padding: 12px;
    border-radius: var(--t-radius-sm);
    background: var(--t-surface-2);
}
.t-mayor-banda__reglas dt { font-weight: 800; font-size: 1.15rem; color: var(--t-primary-ink, var(--t-primary)); }
.t-mayor-banda__reglas dd { margin: 2px 0 0; font-size: .76rem; line-height: 1.35; color: var(--t-muted); }
.t-mayor-banda__cta { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; color: #fff !important; }

@media (max-width: 960px) {
    .t-mayor-banda { grid-template-columns: 1fr; gap: 16px; padding: 22px 18px; }
    .t-mayor-banda__cta { justify-self: start; }
}
@media (max-width: 420px) {
    .t-mayor-banda__reglas { grid-template-columns: 1fr; }
}

/* ---------- Apartado /mayoristas ---------- */
.t-mayor { padding: 6px 0 40px; }
.t-mayor__head { max-width: 640px; margin: 18px 0 20px; display: grid; gap: 8px; }
.t-mayor__head h1 { margin: 0; font-size: clamp(1.6rem, 3.4vw, 2.2rem); line-height: 1.1; color: var(--t-ink); }
.t-mayor__lead { margin: 0; color: var(--t-muted); line-height: 1.5; }

.t-mayor__reglas {
    list-style: none;
    margin: 0 0 24px;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    counter-reset: regla;
}
.t-mayor__reglas li {
    counter-increment: regla;
    position: relative;
    padding: 14px 16px 14px 50px;
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius-sm);
    background: var(--t-surface);
    display: grid;
    gap: 4px;
}
.t-mayor__reglas li::before {
    content: counter(regla);
    position: absolute;
    left: 14px;
    top: 14px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .8rem;
    color: #fff;
    background: var(--t-primary);
}
.t-mayor__reglas strong { color: var(--t-ink); font-size: .95rem; }
.t-mayor__reglas span { color: var(--t-muted); font-size: .84rem; line-height: 1.45; }

.t-mayor__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
}

.t-mayor__tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.t-mayor__buscar { flex: 1 1 220px; }
.t-mayor__buscar input,
.t-mayor__filtro select {
    width: 100%;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--t-border);
    border-radius: 999px;
    background: var(--t-surface);
    color: var(--t-ink);
    font-size: .9rem;
}
.t-mayor__buscar input:focus,
.t-mayor__filtro select:focus { outline: 2px solid var(--t-primary); outline-offset: 1px; }
.t-mayor__check { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--t-ink); }
.t-mayor__conteo { margin: 4px 0 12px; font-size: .82rem; color: var(--t-muted); }

.t-mayor__grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.t-mayor__vacio { padding: 24px; text-align: center; color: var(--t-muted); border: 1px dashed var(--t-border); border-radius: var(--t-radius-sm); }

.t-mayor-card {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 10px 14px 10px 10px;
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius-sm);
    background: var(--t-surface);
}
.t-mayor-card.is-en-pedido { border-color: var(--t-primary); }
.t-mayor-card__media {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--t-surface-2);
    display: block;
}
.t-mayor-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.t-mayor-card__info { display: grid; gap: 3px; min-width: 0; }
.t-mayor-card__nombre {
    color: var(--t-ink);
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.t-mayor-card__nombre:hover { color: var(--t-primary); text-decoration: underline; }
.t-mayor-card__codigo { font-size: .74rem; color: var(--t-muted); }
.t-mayor-card__codigo em { font-style: normal; color: var(--t-primary-ink, var(--t-primary)); font-weight: 600; }
.t-mayor-card__precios { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-top: 2px; }
.t-mayor-card__precios span { display: grid; font-size: .86rem; color: var(--t-muted); }
.t-mayor-card__precios small { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.t-mayor-card__mayor { color: var(--t-ink) !important; font-weight: 700; font-size: 1rem !important; }
.t-mayor-card__pct {
    align-self: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--t-surface-2);
    color: var(--t-success) !important;
    font-weight: 700;
    font-size: .76rem !important;
}
.t-mayor-card__acciones { display: grid; justify-items: end; gap: 6px; }
.t-mayor-card__ya { font-size: .74rem; color: var(--t-primary-ink, var(--t-primary)); font-weight: 600; white-space: nowrap; }

.t-mayor-btn {
    min-height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--t-border);
    background: var(--t-surface);
    color: var(--t-ink);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    white-space: nowrap;
}
.t-mayor-btn:hover { border-color: var(--t-primary); color: var(--t-primary); }
.t-mayor-btn--primario { background: var(--t-primary); border-color: var(--t-primary); color: #fff; }
.t-mayor-btn--primario:hover { background: var(--t-primary-dark); color: #fff; }

/* ---------- Pedido ---------- */
.t-mayor__pedido {
    position: sticky;
    top: calc(var(--t-header-h, 120px) + 12px);
    padding: 18px;
    border: 1px solid var(--t-border);
    border-radius: var(--t-radius);
    background: var(--t-surface);
    box-shadow: var(--t-shadow-sm);
    max-height: calc(100vh - var(--t-header-h, 120px) - 24px);
    overflow: auto;
}
.t-mayor__pedido h2 { margin: 0 0 12px; font-size: 1.1rem; color: var(--t-ink); }
.t-mayor-pedido__vacio { margin: 0; font-size: .86rem; color: var(--t-muted); line-height: 1.5; }
.t-mayor-lineas { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.t-mayor-linea { padding-bottom: 10px; border-bottom: 1px solid var(--t-border); display: grid; gap: 6px; }
.t-mayor-linea__top { display: flex; justify-content: space-between; gap: 8px; }
.t-mayor-linea__nombre { font-size: .88rem; font-weight: 600; color: var(--t-ink); line-height: 1.3; }
.t-mayor-linea__quitar {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border: 0; border-radius: 50%;
    background: transparent;
    color: var(--t-muted);
    font-size: 1.2rem; line-height: 1;
    cursor: pointer;
}
.t-mayor-linea__quitar:hover { background: var(--t-surface-2); color: var(--t-danger); }
.t-mayor-linea__controles { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.t-mayor-linea__precio { text-align: right; font-size: .76rem; color: var(--t-muted); line-height: 1.35; }
.t-mayor-linea__precio strong { font-size: .92rem; color: var(--t-ink); }

.t-mayor-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--t-border);
    border-radius: 999px;
    overflow: hidden;
}
.t-mayor-qty button {
    width: 34px; height: 34px;
    border: 0;
    background: var(--t-surface-2);
    color: var(--t-ink);
    font-size: 1rem;
    cursor: pointer;
}
.t-mayor-qty button:hover { color: var(--t-primary); }
.t-mayor-qty input {
    width: 52px; height: 34px;
    border: 0;
    text-align: center;
    background: var(--t-surface);
    color: var(--t-ink);
    font-weight: 600;
    -moz-appearance: textfield;
}
.t-mayor-qty input::-webkit-outer-spin-button,
.t-mayor-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.t-mayor-estado {
    justify-self: start;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    background: var(--t-surface-2);
    color: var(--t-muted);
}
.t-mayor-estado.is-ok { color: var(--t-success); }

.t-mayor-surtido { display: grid; gap: 6px; margin: 0 0 12px; font-size: .8rem; color: var(--t-muted); }
.t-mayor-surtido strong { color: var(--t-ink); }
.t-mayor-surtido__barra { height: 6px; border-radius: 999px; background: var(--t-surface-2); overflow: hidden; }
.t-mayor-surtido__barra i { display: block; height: 100%; background: var(--t-primary); transition: width .2s ease; }
.t-mayor-surtido.is-ok .t-mayor-surtido__barra i { background: var(--t-success); }

.t-mayor-totales { margin: 0 0 8px; display: grid; gap: 4px; }
.t-mayor-totales > div { display: flex; justify-content: space-between; font-size: .86rem; color: var(--t-muted); }
.t-mayor-totales dd { margin: 0; color: var(--t-ink); }
.t-mayor-totales .is-ahorro dd { color: var(--t-success); font-weight: 600; }
.t-mayor-totales .is-total { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--t-border); font-size: 1rem; }
.t-mayor-totales .is-total dt,
.t-mayor-totales .is-total dd { color: var(--t-ink); font-weight: 800; }
.t-mayor-pedido__nota { margin: 0 0 12px; font-size: .74rem; color: var(--t-muted); }
.t-mayor-enviar { width: 100%; color: #fff !important; }
/* Con el pedido en pantalla, la barra sobra (y taparía el total). */
.t-mayor.is-pedido-visible .t-mayor__barra { display: none !important; }
.t-mayor-vaciar { display: block; margin: 10px auto 0; font-size: .8rem; }

/* Barra fija en el celular: el pedido queda abajo de la lista. */
.t-mayor__barra {
    display: none;
    position: fixed;
    left: 16px;
    right: 96px;
    bottom: 20px;
    z-index: 40;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border: 0;
    border-radius: 999px;
    background: var(--t-ink);
    color: var(--t-surface);
    font-size: .9rem;
    box-shadow: var(--t-shadow);
    cursor: pointer;
}

@media (max-width: 960px) {
    .t-mayor__reglas { grid-template-columns: 1fr; }
    .t-mayor__layout { grid-template-columns: 1fr; }
    .t-mayor__pedido { position: static; max-height: none; }
    .t-mayor__barra { display: flex; }
}
@media (max-width: 720px) {
    /* Queda arriba de la barra inferior de la tienda (.t-tabbar). */
    /* A la derecha queda lugar para el botón flotante de WhatsApp. */
    .t-mayor__barra { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); right: 84px; }
}
@media (max-width: 560px) {
    .t-mayor-card { grid-template-columns: 56px minmax(0, 1fr); padding: 10px; }
    .t-mayor-card__media { width: 56px; height: 56px; }
    .t-mayor-card__acciones { grid-column: 1 / -1; grid-auto-flow: column; justify-content: space-between; align-items: center; }
    .t-mayor-card__nombre { white-space: normal; }
}

/* Tarjeta en el apartado Explorar */
.t-exp-card--mayoristas { border-left: 4px solid #7a5cc4; }
