/*
 * T-Rex Performance · Galería de Clientes
 * Todos los estilos scoped bajo .trex-galeria-wrap para no colisionar con Divi.
 */

.trex-galeria-wrap,
.trex-galeria-wrap *,
.trex-galeria-wrap *::before,
.trex-galeria-wrap *::after {
    box-sizing: border-box;
}

.trex-galeria-wrap {
    --trex-bg: #0a0a0a;
    --trex-bg2: #141414;
    --trex-bg3: #1f1f1f;
    --trex-bg4: #262626;
    --trex-fg: #f2f2f2;
    --trex-muted: #8a8a8a;
    --trex-accent: #c81e1e;
    --trex-accent-hover: #e62727;
    --trex-wa: #25d366;

    background: var(--trex-bg);
    color: var(--trex-fg);
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /* Break out del contenedor angosto de Divi: full width del viewport */
    position: relative;
    width: 100vw;
    max-width: 100vw;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 40px clamp(16px, 4vw, 60px) 40px;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Contenido interior: limitado para legibilidad en monitores gigantes */
.trex-galeria-wrap > .trex-hero,
.trex-galeria-wrap > .trex-filters,
.trex-galeria-wrap > .trex-grid,
.trex-galeria-wrap > .trex-load-more-wrap,
.trex-galeria-wrap > .trex-cta {
    max-width: 1800px;
    margin-left: auto;
    margin-right: auto;
}

/* ========== HERO ========== */
.trex-galeria-wrap .trex-hero {
    text-align: center;
    padding: 40px 0 56px;
    border-bottom: 1px solid var(--trex-bg3);
    margin-bottom: 28px;
}

.trex-galeria-wrap .trex-hero h1 {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: clamp(36px, 6vw, 68px);
    line-height: 1;
    margin: 0 0 14px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--trex-fg);
}

.trex-galeria-wrap .trex-hero h1 .red,
.trex-galeria-wrap .trex-cta h2 .red {
    color: var(--trex-accent);
}

.trex-galeria-wrap .trex-hero-subtitle {
    font-size: clamp(14px, 1.6vw, 17px);
    color: var(--trex-muted);
    font-weight: 500;
    max-width: 640px;
    margin: 0 auto 36px;
    line-height: 1.6;
}

.trex-galeria-wrap .trex-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 720px;
    margin: 0 auto;
}

.trex-galeria-wrap .trex-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 4px;
}

.trex-galeria-wrap .trex-stat-num {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: clamp(32px, 5vw, 52px);
    line-height: 1;
    color: var(--trex-accent);
    letter-spacing: 0.02em;
}

.trex-galeria-wrap .trex-stat-label {
    font-family: 'Oswald', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: var(--trex-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

/* ========== FILTERS ========== */
.trex-galeria-wrap .trex-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 12px;
    margin-bottom: 24px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--trex-bg3) transparent;
}

.trex-galeria-wrap .trex-filters::-webkit-scrollbar {
    height: 4px;
}
.trex-galeria-wrap .trex-filters::-webkit-scrollbar-track {
    background: transparent;
}
.trex-galeria-wrap .trex-filters::-webkit-scrollbar-thumb {
    background: var(--trex-bg3);
    border-radius: 2px;
}

.trex-galeria-wrap .trex-chip {
    flex: 0 0 auto;
    background: var(--trex-bg2);
    color: var(--trex-fg);
    border: 1px solid var(--trex-bg3);
    padding: 9px 16px;
    border-radius: 100px;
    cursor: pointer;
    font-family: 'Oswald', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    line-height: 1;
}

.trex-galeria-wrap .trex-chip:hover {
    border-color: var(--trex-accent);
    color: var(--trex-accent);
}

.trex-galeria-wrap .trex-chip.active {
    background: var(--trex-accent);
    border-color: var(--trex-accent);
    color: #fff;
}

.trex-galeria-wrap .trex-chip-count {
    background: rgba(255, 255, 255, 0.18);
    padding: 2px 7px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

.trex-galeria-wrap .trex-chip:not(.active) .trex-chip-count {
    background: var(--trex-bg3);
    color: var(--trex-muted);
}

/* ========== GRID ========== */
.trex-galeria-wrap .trex-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 32px;
}

@media (min-width: 540px) {
    .trex-galeria-wrap .trex-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}

@media (min-width: 900px) {
    .trex-galeria-wrap .trex-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

@media (min-width: 1280px) {
    .trex-galeria-wrap .trex-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 14px;
    }
}

@media (min-width: 1600px) {
    .trex-galeria-wrap .trex-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 16px;
    }
}

.trex-galeria-wrap .trex-card {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: var(--trex-bg2);
    transition: transform 0.2s ease;
    /* Fallback para navegadores sin aspect-ratio */
    padding-top: 0;
}

@supports not (aspect-ratio: 4/3) {
    .trex-galeria-wrap .trex-card {
        padding-top: 75%;
    }
}

.trex-galeria-wrap .trex-card:hover {
    transform: translateY(-2px);
}

.trex-galeria-wrap .trex-card.trex-hidden {
    display: none;
}

.trex-galeria-wrap .trex-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.trex-galeria-wrap .trex-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.trex-galeria-wrap .trex-card:hover .trex-card-img img {
    transform: scale(1.05);
}

.trex-galeria-wrap .trex-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.88) 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 10px 12px 12px;
    pointer-events: none;
}

.trex-galeria-wrap .trex-card-modelo {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

@media (min-width: 900px) {
    .trex-galeria-wrap .trex-card-modelo {
        font-size: 14px;
    }
}

.trex-galeria-wrap .trex-card-producto {
    font-family: 'Oswald', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: var(--trex-accent);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

@media (min-width: 900px) {
    .trex-galeria-wrap .trex-card-producto {
        font-size: 11px;
    }
}

/* ========== LOAD MORE ========== */
.trex-galeria-wrap .trex-load-more-wrap {
    text-align: center;
    padding: 20px 0 40px;
}

.trex-galeria-wrap .trex-load-more {
    background: transparent;
    color: var(--trex-fg);
    border: 2px solid var(--trex-accent);
    padding: 14px 32px;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    line-height: 1.2;
}

.trex-galeria-wrap .trex-load-more:hover:not(:disabled) {
    background: var(--trex-accent);
    color: #fff;
}

.trex-galeria-wrap .trex-load-more:disabled {
    opacity: 0.5;
    cursor: wait;
}

.trex-galeria-wrap .trex-load-more-count {
    font-size: 10px;
    letter-spacing: 0.08em;
    opacity: 0.7;
    font-weight: 500;
}

/* ========== CTA ========== */
.trex-galeria-wrap .trex-cta {
    text-align: center;
    padding: 56px 20px 48px;
    border-top: 1px solid var(--trex-bg3);
    margin-top: 24px;
    background: radial-gradient(circle at 50% 100%, rgba(200, 30, 30, 0.14), transparent 70%);
}

.trex-galeria-wrap .trex-cta h2 {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: clamp(26px, 4vw, 40px);
    margin: 0 0 10px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.1;
    color: var(--trex-fg);
}

.trex-galeria-wrap .trex-cta p {
    color: var(--trex-muted);
    font-size: 15px;
    font-weight: 500;
    margin: 0 0 24px;
}

.trex-galeria-wrap .trex-btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--trex-wa);
    color: #fff !important;
    text-decoration: none !important;
    padding: 15px 30px;
    border-radius: 4px;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: background 0.15s ease, transform 0.15s ease;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.28);
    line-height: 1;
}

.trex-galeria-wrap .trex-btn-whatsapp:hover {
    background: #20bd5a;
    transform: translateY(-1px);
    color: #fff !important;
}

.trex-galeria-wrap .trex-btn-whatsapp svg {
    flex-shrink: 0;
}

/* ========== LIGHTBOX ========== */
/* Fuera del scope .trex-galeria-wrap para poder ir en body */
.trex-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.97);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
}

.trex-lightbox.trex-open {
    display: flex;
    animation: trexFade 0.18s ease-out;
}

@keyframes trexFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.trex-lightbox .trex-lb-stage {
    max-width: 95vw;
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.trex-lightbox .trex-lb-stage img {
    max-width: 100%;
    max-height: 88vh;
    display: block;
    border-radius: 4px;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.trex-lightbox .trex-lb-close,
.trex-lightbox .trex-lb-prev,
.trex-lightbox .trex-lb-next {
    position: absolute;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    font-family: 'Oswald', sans-serif;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    user-select: none;
    padding: 0;
}

.trex-lightbox .trex-lb-close {
    top: 16px;
    right: 16px;
    width: 46px;
    height: 46px;
    border-radius: 23px;
    font-size: 26px;
    font-weight: 400;
}

.trex-lightbox .trex-lb-prev,
.trex-lightbox .trex-lb-next {
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 70px;
    border-radius: 4px;
    font-size: 44px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.trex-lightbox .trex-lb-prev { left: 16px; }
.trex-lightbox .trex-lb-next { right: 16px; }

.trex-lightbox .trex-lb-close:hover,
.trex-lightbox .trex-lb-prev:hover,
.trex-lightbox .trex-lb-next:hover {
    background: var(--trex-accent, #c81e1e);
    border-color: var(--trex-accent, #c81e1e);
}
.trex-lightbox .trex-lb-prev:hover,
.trex-lightbox .trex-lb-next:hover {
    transform: translateY(-50%) scale(1.04);
}

.trex-lightbox .trex-lb-prev:disabled,
.trex-lightbox .trex-lb-next:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    transform: translateY(-50%);
}

.trex-lightbox .trex-lb-caption {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(85vw, 720px);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
}

.trex-lightbox .trex-lb-caption:empty {
    display: none;
}

.trex-lightbox .trex-lb-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Oswald', sans-serif;
    color: #fff;
    font-size: 12px;
    letter-spacing: 0.14em;
    opacity: 0.75;
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 10px;
    border-radius: 3px;
}

@media (max-width: 640px) {
    .trex-lightbox .trex-lb-prev,
    .trex-lightbox .trex-lb-next {
        width: 42px;
        height: 58px;
        font-size: 34px;
    }
    .trex-lightbox .trex-lb-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
    .trex-lightbox .trex-lb-caption {
        bottom: 44px;
        font-size: 12px;
        padding: 8px 14px;
    }
}

/* Body scroll lock cuando lightbox abierto */
body.trex-lb-open {
    overflow: hidden;
}
