/* assets/public/layouts/users/search-overlay.css
 *
 * Full-screen search overlay. Uses Soltis design tokens (see global.css):
 *   • Surfaces:   --surface-primary, --surface-secondary, --surface-muted
 *   • Text:       --color-label-primary, --color-label-secondary,
 *                 --color-label-tertiary, --color-label-quaternary
 *   • Brand:      --color-brand-primary, --color-brand-primary-hover,
 *                 --color-brand-primary-subtle
 *   • Glass:      --glass-dark, --glass-blur
 *   • Separators: --separator-default, --separator-strong
 *   • Easing:     --ease-soltis, --dur-fast, --dur-normal
 *
 * Visual language matches the header's .u-search-pill (same surfaces,
 * borders, focus halo). Z-index sits at --z-overlay (300), below the
 * login modal at --z-modal (400) so a login prompt mid-search stacks
 * correctly on top of the search.
 */

/* ────────────────────────────────────────────────────────────────────────
 *  Body scroll lock + hide header while overlay is open
 *
 *  Soltis' --z-nav (600) sits above --z-overlay (300) and --z-modal (400)
 *  by design — the header is always-on-top in the normal layout. For a
 *  full-screen search overlay this is the wrong stacking, so instead of
 *  fighting the z-index scale, we visibility:hidden the header entirely
 *  while the overlay is open. The header reappears the moment the
 *  overlay closes (no transition needed, the overlay fade-out covers
 *  the hand-off).
 *
 *  Overlay z-index sits at --z-modal so that if the user mid-search
 *  triggers the login flow (e.g. visitor clicking "Agregar al carrito"
 *  with prices hidden), the login modal — also at --z-modal — stacks
 *  on top via DOM order (login is appended later than the overlay).
 * ────────────────────────────────────────────────────────────────────── */

.so-body-locked {
    overflow: hidden;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Overlay shell (glass design — shared aesthetic with the admin overlay)
 *
 *  Two visual states:
 *    IDLE     — backdrop blurs the page; the glass card containing the
 *               search input floats vertically centered, with an
 *               animated "¿Qué estás buscando hoy?" headline above it.
 *    EXPANDED — first keystroke slides the glass card up; headline
 *               collapses; results card slides in below.
 *  Toggling `.is-expanded` on the overlay drives the transition; no JS
 *  layout math.
 * ────────────────────────────────────────────────────────────────────── */

.so-overlay {
    position: fixed;
    inset: 0;
    /* Above the token z-scale on purpose — header / sticky banners must
     * sit beneath the search overlay. 9999 is the "literally on top"
     * convention; raise if a higher legitimate stack is ever introduced. */
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity var(--dur-fast, 150ms) var(--ease-soltis, ease);
}
.so-overlay.is-open {
    display: block;
    opacity: 1;
}

.so-backdrop {
    position: absolute;
    inset: 0;
    background: var(--glass-dark, rgba(15, 23, 42, 0.40));
    backdrop-filter: blur(18px) saturate(1.1);
    -webkit-backdrop-filter: blur(18px) saturate(1.1);
}

/* Stage — centered → top transition driven by padding-top. */
.so-stage {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: calc(50vh - 130px);
    padding-bottom: 24px;
    overflow-y: auto;
    transition: padding-top 460ms cubic-bezier(0.22, 0.7, 0.25, 1);
}
.so-overlay.is-expanded .so-stage {
    padding-top: 56px;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Glass card (headline + search input)
 *
 *  Sized to match the admin overlay's input card. Translucent surface
 *  with a backdrop blur — sits on top of the already-blurred backdrop,
 *  layering depth into the composition.
 * ────────────────────────────────────────────────────────────────────── */

.so-search-card {
    width: min(640px, 92vw);
    padding: 22px 22px 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(24px) saturate(1.1);
    -webkit-backdrop-filter: blur(24px) saturate(1.1);
    box-shadow:
        0 14px 50px rgba(15, 23, 42, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
    transition:
        padding 280ms cubic-bezier(0.22, 0.7, 0.25, 1),
        border-radius 280ms ease;
}
.so-overlay.so-replay .so-search-card {
    animation: so-card-in 380ms cubic-bezier(0.22, 0.7, 0.25, 1);
}
@keyframes so-card-in {
    0%   { opacity: 0; transform: translateY(14px) scale(0.985); }
    100% { opacity: 1; transform: translateY(0)    scale(1);     }
}
/* Expanded slims the card down — promoted to chrome. */
.so-overlay.is-expanded .so-search-card {
    padding: 10px 14px;
    border-radius: 16px;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Animated headline
 * ────────────────────────────────────────────────────────────────────── */

.so-headline {
    font-family: inherit;
    font-size: clamp(22px, 3.4vw, 32px);
    font-weight: 600;
    margin: 0 0 18px;
    text-align: center;
    letter-spacing: -0.01em;

    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0.55) 30%,
        rgba(255, 255, 255, 1.00) 50%,
        rgba(255, 255, 255, 0.55) 70%
    );
    background-size: 220% auto;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;

    opacity: 1;
    transform: translateY(0);
    max-height: 80px;
    overflow: hidden;
    transition:
        max-height 280ms cubic-bezier(0.22, 0.7, 0.25, 1),
        margin     280ms cubic-bezier(0.22, 0.7, 0.25, 1),
        opacity    180ms ease;

    animation: so-shimmer-text 4.5s linear infinite;
}
.so-overlay.so-replay .so-headline {
    animation:
        so-headline-in 520ms cubic-bezier(0.22, 0.7, 0.25, 1) both,
        so-shimmer-text 4.5s linear 540ms infinite;
}
@keyframes so-headline-in {
    0%   { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0);    }
}
@keyframes so-shimmer-text {
    0%   { background-position: 220% center; }
    100% { background-position: -220% center; }
}

.so-overlay.is-expanded .so-headline {
    max-height: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Search bar (lives inside the glass card)
 * ────────────────────────────────────────────────────────────────────── */

.so-search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    transition: background 180ms ease, border-color 180ms ease;
}
.so-search-bar:focus-within {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.30);
}

.so-search-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.75);
}

.so-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-body, inherit);
    font-size: 16px;
    color: #fff;
    caret-color: #fff;
    padding: 4px 0;
}
.so-input::placeholder { color: rgba(255, 255, 255, 0.55); }
.so-input::-webkit-search-cancel-button { display: none; }

.so-close {
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.80);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--font-body, inherit);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    line-height: 1;
    transition: background 120ms ease, color 120ms ease;
}
.so-close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Results card — opaque white card that holds the section / grid /
 *  chip / message bodies. Hidden in idle; slides in on expand.
 * ────────────────────────────────────────────────────────────────────── */

.so-results-card {
    /* Almost full viewport on a big monitor (24px margin per side,
       uncapped). The glass aesthetic + the heavier blur keep readability
       fine on a wide card. */
    width: calc(100vw - 48px);
    margin-top: 16px;
    border-radius: 16px;
    /* Translucent surface so the slate backdrop bleeds through and the
       card melts into the page instead of fighting it with a hard white
       block. */
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(28px) saturate(1.2);
    -webkit-backdrop-filter: blur(28px) saturate(1.2);
    box-shadow:
        0 18px 50px rgba(15, 23, 42, 0.20),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.28);
    overflow: hidden;

    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    /* Chrome above (stage padding-top + slim card + gap) takes ~150px;
       220 leaves room for breathing too. */
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    transition:
        opacity   240ms ease 120ms,
        transform 280ms cubic-bezier(0.22, 0.7, 0.25, 1) 120ms;
}
.so-overlay.is-expanded .so-results-card {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* The body container is just a padded wrapper now; the visual card is
 * .so-results-card above. */
.so-results {
    padding: var(--space-5, 16px);
}

/* Transient single-message state (too-short / similar). */
.so-msg {
    padding: 32px 8px;
    text-align: center;
    color: var(--color-label-tertiary, #94a3b8);
    font-family: var(--font-body, inherit);
    font-size: 14px;
}
.so-msg p { margin: 0; }

/* Reduced motion — disable headline shimmer + entry animations. */
@media (prefers-reduced-motion: reduce) {
    .so-headline,
    .so-overlay.so-replay .so-headline,
    .so-overlay.so-replay .so-search-card { animation: none; }
    .so-stage,
    .so-search-card,
    .so-headline,
    .so-results-card { transition: none; }
}

/* ────────────────────────────────────────────────────────────────────────
 *  Sections (Categorías, Productos)
 * ────────────────────────────────────────────────────────────────────── */

.so-section+.so-section {
    margin-top: var(--space-5);
    padding-top: var(--space-5);
    border-top: 1px solid var(--separator-default);
}

.so-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.so-section-heading {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
}

.so-section-title {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-label-secondary);
}

.so-section-count {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-label-tertiary);
    background: var(--surface-secondary);
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
}

.so-section-view-all {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-brand-primary);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.so-section-view-all:hover {
    text-decoration: underline;
}

.so-section-view-all svg {
    width: 14px;
    height: 14px;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Category chips
 * ────────────────────────────────────────────────────────────────────── */

.so-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.so-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-secondary);
    border: 1px solid var(--separator-default);
    border-radius: var(--radius-pill);
    color: var(--color-label-primary);
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    transition:
        background-color var(--dur-fast) var(--ease-soltis),
        border-color var(--dur-fast) var(--ease-soltis),
        color var(--dur-fast) var(--ease-soltis),
        transform var(--dur-fast) var(--ease-soltis);
}

.so-chip:hover {
    background: var(--color-brand-primary-subtle);
    border-color: var(--color-brand-primary);
    color: var(--color-brand-primary);
    transform: translateY(-1px);
}

.so-chip-icon {
    width: 16px;
    height: 16px;
    background-color: var(--color-brand-primary);
    mask: var(--icon) center / contain no-repeat;
    -webkit-mask: var(--icon) center / contain no-repeat;
}

.so-chip-icon-fallback {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-brand-primary);
    color: var(--color-label-on-dark);
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.so-chip-label {
    line-height: 1;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Product grid — denser than category pages since the overlay is
 *  more of a quick-scan UI
 * ────────────────────────────────────────────────────────────────────── */

.so-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
}

.so-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface-primary);
    border: 1px solid var(--separator-default);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition:
        transform var(--dur-fast) var(--ease-soltis),
        border-color var(--dur-fast) var(--ease-soltis),
        box-shadow var(--dur-fast) var(--ease-soltis);
}

.so-card:hover {
    transform: translateY(-2px);
    border-color: var(--color-brand-primary);
    box-shadow: var(--shadow-lg);
}

.so-card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.so-card-media {
    position: relative;
    /* 14/10/2026 (Matías: "la zona asignada a la imagen… un poco menos alta, 20% solamente en la altura"): 5:4 instead of the square. */
    aspect-ratio: 5 / 4;
    width: 100%;
    background: var(--surface-secondary);
    overflow: hidden;
}

.so-card-img {
    /* position:absolute + inset:0 forces the image to fill the square
     * regardless of its natural dimensions. aspect-ratio on the parent
     * alone isn't enough — the <img> is inline by default and its
     * intrinsic dimensions can push the parent if we don't fix it
     * absolutely. object-fit: cover crops to fill; object-position
     * centers the crop so the most-interesting middle stays visible. */
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.so-card-no-image {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-label-quaternary);
}

.so-card-stock-badge {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    padding: 2px var(--space-2);
    background: var(--color-error);
    color: var(--color-label-on-dark);
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: var(--radius-sm);
}

.so-card-body {
    padding: var(--space-3) var(--space-3) var(--space-2);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.so-card-title {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-label-primary);
    margin: 0;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.so-card-sku {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-label-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.so-card-price-row {
    margin-top: var(--space-2);
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.so-card-price {
    font-family: var(--font-body);
    font-weight: 700;
    color: var(--color-label-primary);
    font-size: 14px;
}

.so-card-price-old {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--color-label-tertiary);
    text-decoration: line-through;
}

.so-card-footer {
    padding: 0 var(--space-3) var(--space-3);
    position: relative;
    z-index: 2;
    /* above the stretched link */
}

.so-card-cta {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--color-brand-primary);
    color: var(--color-label-on-dark);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background-color var(--dur-fast) var(--ease-soltis),
        transform var(--dur-fast) var(--ease-soltis);
}

.so-card-cta:hover:not(:disabled):not(.is-disabled) {
    background: var(--color-brand-primary-hover);
    transform: translateY(-1px);
}

.so-card-cta:active:not(:disabled):not(.is-disabled) {
    background: var(--color-brand-primary-active);
    transform: translateY(0);
}

.so-card-cta:disabled,
.so-card-cta.is-disabled {
    background: var(--surface-muted);
    color: var(--color-label-quaternary);
    cursor: not-allowed;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Skeleton (loading state)
 * ────────────────────────────────────────────────────────────────────── */

.so-skeleton-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-2);
    border: 1px solid var(--separator-default);
    border-radius: var(--radius-xl);
}

.so-skeleton-img {
    aspect-ratio: 1;
    background: linear-gradient(90deg,
            var(--surface-muted) 0%,
            var(--surface-secondary) 50%,
            var(--surface-muted) 100%);
    background-size: 200% 100%;
    animation: so-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.so-skeleton-line {
    height: 12px;
    background: linear-gradient(90deg,
            var(--surface-muted) 0%,
            var(--surface-secondary) 50%,
            var(--surface-muted) 100%);
    background-size: 200% 100%;
    animation: so-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.so-skeleton-line--short {
    width: 60%;
}

@keyframes so-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ────────────────────────────────────────────────────────────────────────
 *  Empty / error state
 * ────────────────────────────────────────────────────────────────────── */

.so-empty {
    padding: var(--space-8) var(--space-4);
    text-align: center;
}

.so-empty-icon {
    color: var(--color-label-quaternary);
    margin-bottom: var(--space-3);
}

.so-empty-title {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-label-primary);
    margin: 0 0 var(--space-1);
}

.so-empty-subtitle {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-label-tertiary);
    margin: 0;
}

/* ────────────────────────────────────────────────────────────────────────
 *  Mobile + small tablet
 *
 *  On smaller screens the overlay goes fullscreen with the search bar at
 *  top, then results below. Visual separation (separator line between bar
 *  and results) is kept rather than blending — easier to scan, and the
 *  user clearly sees where the input ends and results begin.
 *
 *  Breakpoint at 768px covers phones in landscape and small tablets in
 *  portrait — the desktop layout's centered floating panel doesn't look
 *  right under ~800px.
 * ────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    /* Phones in portrait: tuck the centered card higher (mobile keyboards
     * eat 40–50% of the viewport when the input takes focus, so a
     * mid-page anchor pushes the headline off-screen). */
    .so-stage {
        padding-top: clamp(16vh, 20vh, 22vh);
    }

    .so-search-card,
    .so-results-card {
        width: calc(100vw - 16px);
        border-radius: 14px;
    }

    .so-headline {
        font-size: 22px;
        margin-bottom: 14px;
    }

    .so-input {
        font-size: 16px;
        /* prevents iOS zoom on focus */
    }

    .so-results {
        padding: var(--space-4, 12px);
    }

    .so-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3, 8px);
    }

    .so-section + .so-section {
        margin-top: var(--space-4, 12px);
        padding-top: var(--space-4, 12px);
    }
}

/* Close control: "Esc" hint on desktop, a finger-sized "Cerrar" on phones. */
.so-close-txt { display: none; }
@media (max-width: 768px) {
    .so-close {
        min-height: 40px;
        padding: 0 14px;
        font-size: 13px;
        letter-spacing: 0;
    }
    .so-close-key { display: none; }
    .so-close-txt { display: inline; }
    .so-input { font-size: 16px; }
}

/* Quantity next to "Agregar" (6/10/2026): salesmen type code + quantity.
   14/10/2026 (Matías: "quedó muy grande el + - y el número y se pierde parte del botón"): a
   smaller stepper, and the button wraps to its own full-width row when the card is too narrow
   for both instead of being clipped. */
.so-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: stretch;
}
.so-card-qty {
    flex: 0 0 60px;
    width: 60px;
    min-width: 0;
    padding: 0 var(--space-2);
    text-align: center;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-label-primary);
    background: var(--surface-primary);
    border: 1.5px solid var(--separator-strong);
    border-radius: var(--radius-md);
    -moz-appearance: textfield;
    appearance: textfield;
}
.so-card-qty::-webkit-outer-spin-button,
.so-card-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.so-card-qty:focus { outline: 2px solid var(--color-brand-primary); outline-offset: 1px; border-color: var(--color-brand-primary); }
.so-card-qty:disabled { opacity: 0.5; }
.so-card-footer .so-card-cta { flex: 1 1 96px; width: auto; min-width: 0; padding-inline: var(--space-2); white-space: nowrap; }
@media (max-width: 734px) { .so-card-qty { font-size: 16px; } }

/* Stepper around the quantity (client request 6/10/2026: +/− as well). */
.so-card-stepper {
    display: flex;
    align-items: stretch;
    flex: 0 0 auto;
    border: 1.5px solid var(--separator-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface-primary);
}
.so-card-stepper:focus-within { border-color: var(--color-brand-primary); }
.so-card-step {
    width: 26px;
    border: 0;
    background: var(--surface-muted);
    color: var(--color-label-primary);
    font: inherit;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.so-card-step:hover:not(:disabled) { background: var(--color-brand-primary); color: var(--color-label-on-dark); }
.so-card-step:disabled { opacity: 0.4; cursor: not-allowed; }
.so-card-stepper .so-card-qty { flex: 0 0 36px; width: 36px; border: 0; border-radius: 0; padding: 0 2px; font-size: 14px; }
.so-card-stepper .so-card-qty:focus { outline: none; }
@media (max-width: 734px) { .so-card-step { width: 32px; } .so-card-stepper .so-card-qty { flex-basis: 40px; width: 40px; font-size: 16px; } }
