/**
 * MercadoAgro - Catálogo Minimalista Estilo Apple Store
 * assets/css/ma-anuncios.css
 */

:root {
    --ma-ap-border: #d2d2d7;
    --ma-ap-border-subtle: #e5e5ea;
    --ma-ap-text: #1d1d1f;
    --ma-ap-sub: #86868b;
}

/* CONTENEDOR GLOBAL */
.ma-apple-catalog {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 10px 80px 10px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: var(--ma-ap-text);
    background: transparent !important;
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (min-width: 768px) {
    .ma-apple-catalog {
        padding: 0 20px 80px 20px;
    }
}

/* ENCABEZADO DE PÁGINA DINÁMICO (ESTILO APPLE MINIMALISTA) */
.ma-apple-page-header {
    margin-bottom: 28px;
    padding-top: 4px;
}

.ma-apple-page-kicker {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px 0;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.ma-apple-page-title {
    font-size: clamp(34px, 5.5vw, 48px);
    font-weight: 800;
    color: #000000;
    margin: 0;
    line-height: 1.08;
    letter-spacing: -0.03em;
    transition: opacity 0.15s ease;
}

/* 1. BARRA DE FILTROS EN REPOSO */
.ma-apple-bar-anchor {
    position: relative;
    width: 100%;
    margin-bottom: 24px;
}

.ma-apple-sticky-bar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0;
    background: transparent;
    border: none !important;
    box-shadow: none !important;
    box-sizing: border-box;
    transition: background 0.3s ease, border-radius 0.2s ease;
}

/* ESTADO SCROLL: OSCURO PROFUNDO CON DESENFOQUE LIGERO (10px) Y CERO SOMBRA */
.ma-apple-sticky-bar.is-stuck {
    position: fixed;
    top: 10px; /* Misma altura compacta superior que Apple */
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 1140px;
    height: 48px;
    padding: 0 16px;
    background: rgba(18, 20, 24, 0.85) !important;
    backdrop-filter: blur(24px) saturate(190%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(190%) !important;
    border-radius: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.18), 0 12px 32px rgba(0, 0, 0, 0.45) !important;
    z-index: 9999;
}

@media (min-width: 768px) {
    .ma-apple-sticky-bar.is-stuck {
        width: calc(100% - 40px);
        padding: 0 20px;
    }
}

.ma-apple-sticky-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ma-apple-sticky-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 12px;
}

/* VISIBILIDAD MÓVIL VS ESCRITORIO */
.ma-apple-mobile-only {
    display: block !important;
}

.ma-apple-desktop-only {
    display: none !important;
}

@media (min-width: 768px) {
    .ma-apple-mobile-only {
        display: none !important;
    }
    .ma-apple-desktop-only {
        display: flex !important;
    }
}

/* BOTÓN "FILTROS" EN MÓVIL (PÍLDORA LIMPIA SIN ÍCONOS) */
.ma-apple-mobile-filter-btn {
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff;
    border: 1px solid var(--ma-ap-border);
    border-radius: 999px;
    height: 30px;
    line-height: 28px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 400;
    font-family: inherit;
    color: var(--ma-ap-text);
    cursor: pointer;
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.ma-apple-sticky-bar.is-stuck .ma-apple-mobile-filter-btn {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* PÍLDORAS DE ESCRITORIO */
.ma-apple-filter-pill-select-wrap {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.ma-apple-pill-select {
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff;
    border: 1px solid var(--ma-ap-border);
    border-radius: 999px;
    height: 30px;
    line-height: 28px;
    padding: 0 24px 0 14px;
    font-size: 13px;
    font-weight: 400;
    font-family: inherit;
    color: var(--ma-ap-text);
    text-align: center;
    text-align-last: center;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='%2386868b' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.ma-apple-sticky-bar.is-stuck .ma-apple-pill-select {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='%23ffffff' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.ma-apple-sticky-bar.is-stuck .ma-apple-pill-select option {
    background: #1d1d1f;
    color: #ffffff;
}

/* BOTÓN LIMPIAR */
.ma-apple-clear-pill {
    padding: 0 8px;
    height: 30px;
    line-height: 30px;
    background: transparent;
    border: none;
    font-size: 12px;
    font-family: inherit;
    color: var(--ma-ap-sub);
    cursor: pointer;
    text-decoration: underline;
}
.ma-apple-sticky-bar.is-stuck .ma-apple-clear-pill {
    color: rgba(255, 255, 255, 0.7);
}

/* ORDENAR POR */
.ma-apple-sort-wrap {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    font-size: 12px;
    font-family: inherit;
    color: var(--ma-ap-sub);
}

.ma-apple-sort-label {
    margin-right: 4px;
    font-size: 12px;
    font-family: inherit;
    color: var(--ma-ap-sub);
    white-space: nowrap;
}

.ma-apple-sort-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: var(--ma-ap-text);
    padding: 2px 16px 2px 2px;
    cursor: pointer;
    outline: none;
    white-space: nowrap;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='%2386868b' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
}

.ma-apple-sort-select option {
    font-family: inherit;
    font-size: 13px;
    background: #ffffff;
    color: #1d1d1f;
}

.ma-apple-sticky-bar.is-stuck .ma-apple-sort-label {
    color: rgba(255, 255, 255, 0.7);
}

.ma-apple-sticky-bar.is-stuck .ma-apple-sort-select {
    color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='%23ffffff' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.ma-apple-sticky-bar.is-stuck .ma-apple-sort-select option {
    background: #1d1d1f;
    color: #ffffff;
}

/* 2. VENTANA MODAL / BOTTOM SHEET DE FILTROS EN MÓVIL (ESTILO APPLE DARK) */
.ma-apple-modal-wrapper {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
}

.ma-apple-modal-wrapper.is-open {
    display: block;
}

.ma-apple-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ma-apple-modal-wrapper.is-open .ma-apple-modal-backdrop {
    opacity: 1;
}

.ma-apple-modal-card {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(18, 20, 24, 0.85) !important;
    backdrop-filter: blur(24px) saturate(190%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(190%) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.14) !important;
    box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.18), 0 -16px 45px rgba(0, 0, 0, 0.5) !important;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 20px 20px 32px 20px;
    max-height: 82vh;
    overflow-y: auto;
    color: #ffffff;
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.ma-apple-modal-wrapper.is-open .ma-apple-modal-card {
    transform: translateY(0);
}

.ma-apple-modal-top {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 12px;
}

/* BOTÓN CERRAR REDONDO ESTILO APPLE */
.ma-apple-modal-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background 0.2s ease;
}

.ma-apple-modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* LISTA DE FILTROS ACORDEÓN TIPO APPLE */
.ma-apple-accordion-list {
    display: flex;
    flex-direction: column;
}

.ma-apple-accordion-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ma-apple-accordion-header {
    width: 100%;
    padding: 16px 0;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    color: #ffffff;
    cursor: pointer;
    text-align: left;
}

.ma-apple-accordion-chevron {
    width: 12px;
    height: 12px;
    stroke: #86868b;
    transition: transform 0.2s ease;
}

.ma-apple-accordion-item.is-active .ma-apple-accordion-chevron {
    transform: rotate(180deg);
}

.ma-apple-accordion-content {
    display: none;
    padding-bottom: 16px;
}

.ma-apple-accordion-item.is-active .ma-apple-accordion-content {
    display: block;
}

.ma-apple-modal-select {
    width: 100%;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #ffffff;
    padding: 0 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.ma-apple-modal-select option {
    background: #1d1d1f;
    color: #ffffff;
}

/* ACCIONES MODAL */
.ma-apple-modal-actions {
    margin-top: 24px;
    display: flex;
    gap: 10px;
}

.ma-apple-modal-apply {
    flex: 2;
    height: 42px;
    border-radius: 999px;
    background: #ffffff;
    color: #000000;
    border: none;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.ma-apple-modal-clear {
    flex: 1;
    height: 42px;
    border-radius: 999px;
    background: transparent;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 14px;
    font-weight: 400;
    font-family: inherit;
    cursor: pointer;
}

/* 3. RESULTADOS */
.ma-apple-results-bar {
    padding: 0 0 16px 0;
    font-size: 13px;
    color: var(--ma-ap-sub);
}

/* 4. CUADRÍCULA DE ANUNCIOS */
.ma-apple-grid-wrap {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.ma-apple-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    background: transparent;
    border-top: 1px solid var(--ma-ap-border-subtle);
    border-left: 1px solid var(--ma-ap-border-subtle);
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .ma-apple-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* CELDA DEL ANUNCIO */
.ma-apple-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    padding: 20px 8px 18px 8px;
    border-right: 1px solid var(--ma-ap-border-subtle);
    border-bottom: 1px solid var(--ma-ap-border-subtle);
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
    background: transparent !important;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
}

@media (min-width: 768px) {
    .ma-apple-card {
        padding: 32px 16px 28px 16px;
    }
}

.ma-apple-card-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: inherit;
    width: 100%;
    flex: 1;
    cursor: pointer;
}

.ma-apple-card-action {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.ma-apple-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 980px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    box-sizing: border-box;
    transition: all 0.2s ease;
    cursor: pointer;
}

.ma-apple-btn-direct-wa {
    background: #ffffff !important;
    color: #111518 !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: none !important;
}

.ma-apple-btn-direct-wa:hover {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    transform: translateY(-1px);
    box-shadow: none !important;
    color: #111518 !important;
}

.ma-apple-btn-view-card {
    background: transparent !important;
    color: var(--ma-ap-sub) !important;
    border: 1px solid var(--ma-ap-border-subtle) !important;
}

.ma-apple-btn-view-card:hover {
    background: var(--ma-ap-bg-soft) !important;
    color: var(--ma-ap-text) !important;
    border-color: var(--ma-ap-border) !important;
}

/* MARCO REDONDEADO PARA FOTO / VIDEO CON FONDO GRIS SUAVE #f5f5f7 */
.ma-apple-media-frame {
    position: relative;
    width: 100%;
    max-width: 220px;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    background: #f5f5f7;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-sizing: border-box;
    padding: 6px;
}

@media (min-width: 768px) {
    .ma-apple-media-frame {
        max-width: 240px;
        border-radius: 18px;
        margin-bottom: 20px;
        padding: 8px;
    }
}

/* FOTOS COMPLETAS (object-fit: contain) CON BORDES REDONDEADOS */
.ma-apple-media-img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain !important;
    display: block;
    border-radius: 10px;
    transition: opacity 0.35s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 768px) {
    .ma-apple-media-img {
        border-radius: 12px;
    }
}

.ma-apple-media-img.ma-secondary-img {
    position: absolute;
    inset: 6px;
    opacity: 0;
    pointer-events: none;
}

@media (min-width: 768px) {
    .ma-apple-media-img.ma-secondary-img {
        inset: 8px;
    }
}

.ma-apple-card:hover .ma-apple-media-img.ma-primary-img {
    transform: scale(1.03);
}

.ma-apple-card:hover .ma-apple-media-img.ma-secondary-img {
    opacity: 1;
    transform: scale(1.03);
}

.ma-apple-no-img {
    font-size: 11px;
    color: var(--ma-ap-sub);
    font-weight: 500;
}

/* TÍTULO DEL ANUNCIO (MÁXIMO 2 LÍNEAS) */
.ma-apple-card-title {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--ma-ap-text);
    margin: 0 0 6px 0;
    width: 100%;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 35px;
    word-break: break-word;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .ma-apple-card-title {
        font-size: 15px;
        min-height: 42px;
        max-width: 260px;
        margin-bottom: 8px;
    }
}

/* PRECIO CENTRADO */
.ma-apple-card-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--ma-ap-text);
    margin: 0 0 6px 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .ma-apple-card-price {
        font-size: 15px;
        margin-bottom: 8px;
    }
}

/* UBICACIÓN CON PIN GRIS CLARO */
.ma-apple-card-location {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 400;
    color: var(--ma-ap-sub);
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .ma-apple-card-location {
        font-size: 12px;
        max-width: 240px;
    }
}

.ma-apple-pin-icon {
    width: 11px;
    height: 11px;
    fill: #86868b;
    flex-shrink: 0;
}

/* 5. PAGINACIÓN EN PÍLDORA OVALADA */
.ma-apple-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 48px 0 16px 0;
}

.ma-apple-page-btn {
    padding: 6px 16px;
    border-radius: 999px;
    background: transparent;
    border: 1px solid var(--ma-ap-border);
    color: var(--ma-ap-text);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.ma-apple-page-btn.is-current {
    background: #1d1d1f;
    color: #ffffff;
    border-color: #1d1d1f;
    font-weight: 500;
}

.ma-apple-page-btn:hover:not(.is-current) {
    background: rgba(0, 0, 0, 0.04);
}

/* ESTADO CARGANDO */
.ma-apple-grid-wrap.is-loading {
    opacity: 0.4;
    pointer-events: none;
}

/* SIN RESULTADOS */
.ma-apple-empty {
    grid-column: 1 / -1;
    padding: 60px 20px;
    text-align: center;
    color: var(--ma-ap-sub);
}
.ma-apple-empty-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--ma-ap-text);
    margin-bottom: 6px;
}
