/* ==========================================
   FEED MOBILE-FIRST - TAKE A MAP
   Diseño responsive con gradientes suaves
   ========================================== */

:root {
    /* Colores Take a Map */
    --feed-primary: #4B2883;
    --feed-secondary: #0075BF;
    --feed-accent: #6B46C1;

    /* Gradientes suaves para categorías */
    --gradient-promotion: linear-gradient(135deg,
            rgba(75, 40, 131, 0.08) 0%,
            rgba(107, 70, 193, 0.05) 100%);
    --gradient-discount: linear-gradient(135deg,
            rgba(0, 117, 191, 0.08) 0%,
            rgba(0, 90, 143, 0.05) 100%);
    --gradient-announcement: linear-gradient(135deg,
            rgba(107, 70, 193, 0.06) 0%,
            rgba(0, 117, 191, 0.04) 100%);
    --gradient-card-hover: linear-gradient(135deg,
            rgba(75, 40, 131, 0.03) 0%,
            rgba(0, 117, 191, 0.02) 100%);

    /* Shadows suaves */
    --shadow-soft: 0 2px 12px rgba(75, 40, 131, 0.08);
    --shadow-medium: 0 4px 20px rgba(75, 40, 131, 0.12);
    --shadow-hover: 0 8px 30px rgba(0, 117, 191, 0.15);
}

/* ==========================================
   CONTAINER PRINCIPAL
   ========================================== */

#feed-section {
    padding: 0;
    margin: 0;
}

.feed-container {
    max-width: 100%;
    padding: 16px 12px 12px;
}

/* ==========================================
   HEADER DEL FEED
   ========================================== */

.feed-header {
    padding: 16px 12px;
    padding-top: 80px;
    /* Separación del header principal */
    background: linear-gradient(135deg, #4B2883 0%, #6B46C1 100%);
    margin-bottom: 0;
}

.feed-header h1 {
    color: white;
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ==========================================
   BÚSQUEDA Y FILTROS MOBILE
   ========================================== */

.search-filter-mobile {
    position: sticky;
    top: 0;
    z-index: 20;
    background: white;
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-bar-mobile {
    margin-bottom: 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-bar-mobile input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 2px solid rgba(75, 40, 131, 0.1);
    border-radius: 12px;
    font-size: 16px;
    /* Evita zoom en iOS */
    background: var(--gradient-card-hover);
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%234B2883' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
    background-size: 20px;
}

.search-bar-mobile input:focus {
    outline: none;
    border-color: var(--feed-primary);
    background-color: white;
    box-shadow: 0 0 0 4px rgba(75, 40, 131, 0.08);
}

.search-bar-mobile input::placeholder {
    color: rgba(75, 40, 131, 0.4);
}

/* Filtros horizontales scrolleables */

.filter-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    border-radius: 18px;
    border: 2px solid rgba(75, 40, 131, 0.1);
    background: white;
    color: var(--feed-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    user-select: none;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
}

/* Ajuste: botón Todos en la columna 1, resto al lado en mobile */
.filters-horizontal-scroll {
    display: flex;
    gap: 8px;
    padding-bottom: 4px;
    flex-wrap: wrap;
}

.filter-chip:active {
    transform: scale(0.96);
}

.filter-chip.active {
    background: linear-gradient(135deg, #4B2883 0%, #6B46C1 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(75, 40, 131, 0.25);
}

.chip-icon {
    font-size: 14px;
    line-height: 1;
}

.filter-todos {
    flex: 0 0 auto;
}

/* ==========================================
   GRID DE POSTS - INSTAGRAM STYLE
   ========================================== */

.posts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 columnas en mobile estilo Instagram */
    gap: 4px;
    padding: 4px;
    margin-top: 16px;
}

/* ==========================================
   CARDS DE POST - INSTAGRAM STYLE
   ========================================== */

.post-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    /* Cuadrado perfecto como Instagram */
    overflow: hidden;
    cursor: pointer;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    background: linear-gradient(135deg,
            rgba(75, 40, 131, 0.1) 0%,
            rgba(0, 117, 191, 0.1) 100%);
}

.post-card:active {
    opacity: 0.9;
}

/* Imagen del post - ocupa todo el contenedor */
.post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

/* Overlay con gradiente oscuro en la parte inferior */
.post-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top,
            rgba(0, 0, 0, 0.7) 0%,
            rgba(0, 0, 0, 0.4) 50%,
            transparent 100%);
    padding: 12px 8px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.3s ease;
}

/* Logo del sponsor en overlay */
.post-overlay .sponsor-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    flex-shrink: 0;
}

/* Nombre del sponsor en overlay */
.post-overlay .sponsor-name {
    font-size: 11px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Badge de tipo en esquina superior derecha */
.post-type-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

/* Badges por tipo */
.badge-promotion {
    background: rgba(255, 87, 34, 0.9);
    color: white;
}

.badge-discount {
    background: rgba(76, 175, 80, 0.9);
    color: white;
}

.badge-announcement {
    background: rgba(33, 150, 243, 0.9);
    color: white;
}

/* Skeleton loading */
.post-image.loading {
    background: linear-gradient(90deg,
            rgba(75, 40, 131, 0.1) 0%,
            rgba(107, 70, 193, 0.15) 50%,
            rgba(75, 40, 131, 0.1) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

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

/* Estilos obsoletos - mantener para compatibilidad con modal */
.post-content {
    padding: 16px;
}

.post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.sponsor-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(75, 40, 131, 0.1);
    flex-shrink: 0;
}

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

.sponsor-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--feed-primary);
    margin-bottom: 2px;
}

.post-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.post-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--feed-primary);
    margin-bottom: 8px;
}

.post-description {
    font-size: 14px;
    line-height: 1.5;
    color: #64748b;
    margin-bottom: 12px;
}

.post-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #94a3b8;
    padding-top: 12px;
    border-top: 1px solid rgba(75, 40, 131, 0.06);
}

.post-date,
.post-views {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================
   MODAL MOBILE - BOTTOM SHEET (INSTAGRAM STYLE)
   ========================================== */

.post-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
}

.post-modal.active {
    display: block;
}

/* Backdrop */
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    animation: fadeIn 0.3s ease;
}

/* Bottom Sheet */
.modal-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 24px 24px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
    animation: slideUpMobile 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Handle para drag */
.modal-handle {
    width: 48px;
    height: 4px;
    background: rgba(75, 40, 131, 0.2);
    border-radius: 2px;
    margin: 12px auto 8px;
}

.modal-header {
    padding: 0 20px 16px;
    border-bottom: 1px solid rgba(75, 40, 131, 0.08);
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--feed-primary);
    margin-bottom: 12px;
    line-height: 1.3;
}

.modal-sponsor-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.modal-sponsor-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(75, 40, 131, 0.15);
}

.modal-sponsor-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--feed-secondary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.modal-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.modal-content-text {
    font-size: 15px;
    line-height: 1.7;
    color: #475569;
    margin-bottom: 20px;
    white-space: pre-wrap;
}

.modal-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px;
    background: linear-gradient(135deg,
            rgba(75, 40, 131, 0.04) 0%,
            rgba(0, 117, 191, 0.04) 100%);
    border-radius: 12px;
    font-size: 13px;
    color: #64748b;
    border: 1px solid rgba(75, 40, 131, 0.08);
}

.modal-metadata span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #64748b;
    transition: all 0.2s;
    z-index: 10;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.15);
    transform: scale(1.1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUpMobile {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==========================================
   LOADING STATES - SKELETONS
   ========================================== */

.skeleton-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    padding: 16px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(75, 40, 131, 0.08);
}

.skeleton-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(90deg,
            rgba(75, 40, 131, 0.05) 0%,
            rgba(107, 70, 193, 0.08) 50%,
            rgba(75, 40, 131, 0.05) 100%);
    background-size: 200% 100%;
    border-radius: 12px;
    margin-bottom: 12px;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 16px;
    background: linear-gradient(90deg,
            rgba(75, 40, 131, 0.05) 0%,
            rgba(107, 70, 193, 0.08) 50%,
            rgba(75, 40, 131, 0.05) 100%);
    background-size: 200% 100%;
    border-radius: 8px;
    margin: 8px 0;
    animation: shimmer 1.5s infinite;
}

/* ==========================================
   ESTADOS VACÍOS Y ERROR
   ========================================== */

.empty-state,
.error-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 24px;
}

.empty-state p,
.error-state p {
    font-size: 16px;
    color: #64748b;
    margin-bottom: 16px;
}

.error-state button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #4B2883 0%, #6B46C1 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.error-state button:hover {
    box-shadow: 0 4px 12px rgba(75, 40, 131, 0.25);
}

/* ==========================================
   ANIMACIONES
   ========================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out both;
}

/* ==========================================
   TABLET (≥ 640px)
   ========================================== */

@media (min-width: 640px) {
    .feed-container {
        padding: 8px;
    }

    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 6px;
    }

    .search-filter-mobile {
        padding: 16px;
        border-radius: 16px;
        margin: 0 8px 12px;
    }

    .filters-horizontal-scroll {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .filter-chip {
        padding: 8px 12px;
        border-radius: 20px;
        flex: 0 0 auto;
    }

    .modal-sheet {
        left: 50%;
        transform: translateX(-50%);
        max-width: 600px;
        border-radius: 24px;
    }

    /* Hover effect en tablet */
    .post-card:hover .post-image {
        transform: scale(1.05);
    }

    .post-card:hover .post-overlay {
        opacity: 1;
    }
}

/* ==========================================
   DESKTOP (≥ 1024px)
   ========================================== */

@media (min-width: 1024px) {
    .feed-container {
        max-width: 1280px;
        margin: 0 auto;
        padding: 48px 32px 32px;
    }

    .search-filter-mobile {
        top: 0;
        margin-bottom: 20px;
    }

    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
        padding: 12px 8px 20px;
    }

    /* Hover effects en desktop */
    .post-card:hover .post-image {
        transform: scale(1.08);
    }

    .post-card:hover .post-overlay {
        background: linear-gradient(to top,
                rgba(0, 0, 0, 0.85) 0%,
                rgba(0, 0, 0, 0.6) 60%,
                transparent 100%);
    }

    .post-card:active {
        opacity: 1;
        transform: scale(0.98);
    }

    /* Modal centrado en desktop */
    .modal-sheet {
        top: 50%;
        bottom: auto;
        left: 50%;
        transform: translate(-50%, -50%);
        max-width: 1100px;
        max-height: 85vh;
        height: 85vh;
        border-radius: 24px;
        overflow: hidden;
        animation: slideUpDesktop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .modal-body {
        display: grid;
        grid-template-columns: 1.1fr 0.9fr;
        grid-template-rows: minmax(0, 1fr) auto;
        gap: 20px;
        align-items: start;
        padding: 24px 28px 28px;
        flex: 1;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .modal-image-container {
        grid-column: 1;
        grid-row: 1 / 3;
        height: 100%;
        align-self: stretch;
        overflow: hidden;
        position: relative;
    }

    .modal-image {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: cover;
        margin-bottom: 0;
    }

    .modal-content-text {
        grid-column: 2;
        grid-row: 1;
        margin-bottom: 16px;
        overflow-y: auto;
        max-height: none;
        padding-right: 10px;
        min-height: 0;
        max-height: 100%;
    }

    .modal-metadata {
        grid-column: 2;
        grid-row: 2;
        margin-top: 8px;
    }

    .modal-handle {
        display: none;
    }

    @keyframes slideUpDesktop {
        from {
            transform: translate(-50%, -50%) scale(0.9);
            opacity: 0;
        }

        to {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
        }
    }
}

/* ==========================================
   XL (≥ 1536px)
   ========================================== */

@media (min-width: 1536px) {
    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .feed-container {
        max-width: 1400px;
    }
}
