/* assets/css/cards.css */

/* ============================================
   CARDS - ESTILOS GENERALES
   ============================================ */

.card {
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: white;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

/* ============================================
   IMÁGENES DE CARDS - 16:10 PANORÁMICO
   ============================================ */

.card-img-top {
    width: 100%;
    height: 250px; /* Altura exacta para ratio 16:10 */
    object-fit: cover;
    object-position: center center;
    background: #f0f0f0;
    display: block;
}

/* Asegurar que el contenedor de la imagen no tenga padding extra */
.card .card-img-top {
    margin: 0;
    padding: 0;
    border: none;
}

/* Evitar que la imagen se deforme durante la carga */
.card-img-top[src=""] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Variantes de altura de imagen */
.card-img-short .card-img-top {
    height: 200px;
}

.card-img-medium .card-img-top {
    height: 250px; /* Default */
}

.card-img-tall .card-img-top {
    height: 300px;
}

/* ============================================
   CONTENIDO DE CARDS
   ============================================ */

.card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.card-title {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    
    /* Limitar a 2 líneas con puntos suspensivos */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8rem;
    line-height: 1.4;
}

.card-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.card-text.text-muted {
    font-size: 0.9rem;
    color: #718096;
}

.card-text.text-secondary {
    /* Limitar descripción a 3 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   CARDS DE ANUNCIOS Y NOTICIAS
   ============================================ */

.card-anuncio,
.card-noticia {
    cursor: pointer;
    transition: all 0.3s ease;
}

.card-anuncio:hover,
.card-noticia:hover {
    transform: translateY(-8px);
}

/* Badge de fecha */
.card-date-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(13, 71, 161, 0.9);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 1;
}

/* ============================================
   CARDS PARA GALERÍA
   ============================================ */

.card-gallery {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.card-gallery .card-img-top {
    height: 280px; /* Más alto para galería */
    transition: transform 0.5s ease;
}

.card-gallery:hover .card-img-top {
    transform: scale(1.1);
}

.card-gallery .card-img-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 20px;
    transition: padding 0.3s ease;
}

.card-gallery:hover .card-img-overlay {
    padding: 25px;
}

/* ============================================
   CARDS HORIZONTALES
   ============================================ */

.card-horizontal {
    flex-direction: row;
}

.card-horizontal .card-img-top {
    height: auto;
    width: 250px;
    min-height: 100%;
    border-radius: 12px 0 0 12px;
}

.card-horizontal .card-body {
    flex: 1;
}

/* ============================================
   BOTONES EN CARDS
   ============================================ */

.card .btn-primary {
    background-color: var(--primary-color);
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    margin-top: auto; /* Empuja el botón al final */
}

.card .btn-primary:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ============================================
   ENLACES EN CARDS
   ============================================ */

a.text-decoration-none .card {
    color: inherit;
}

a.text-decoration-none .card:hover .card-title {
    color: var(--secondary-color);
}

/* ============================================
   ESTADOS ESPECIALES
   ============================================ */

.card.card-destacado {
    border: 2px solid var(--accent-color);
    position: relative;
}

.card.card-destacado::before {
    content: '⭐ Destacado';
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--accent-color);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 1;
}

.card.card-nuevo {
    position: relative;
}

.card.card-nuevo::before {
    content: '🆕 Nuevo';
    position: absolute;
    top: 10px;
    left: 10px;
    background: #10b981;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 1;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 992px) {
    .card-img-top {
        height: 220px;
    }
}

@media (max-width: 768px) {
    .card-img-top {
        height: 200px;
        object-fit: contain; /* CAMBIADO: Mostrar imagen completa en móvil */
        background: #f8f9fa;
        padding: 10px; /* Agregar padding para separar del borde */
    }

    .card-body {
        padding: 1.25rem;
    }

    .card-title {
        font-size: 1rem;
        min-height: 2.4rem;
    }

    .card-text {
        font-size: 0.9rem;
    }

    /* Cards horizontales en móvil se vuelven verticales */
    .card-horizontal {
        flex-direction: column;
    }

    .card-horizontal .card-img-top {
        width: 100%;
        height: 200px;
        border-radius: 12px 12px 0 0;
        object-fit: contain;
    }

    .card-gallery .card-img-top {
        height: 220px;
        object-fit: cover; /* Galería sigue con cover */
    }
}

@media (max-width: 576px) {
    .card-img-top {
        height: 180px;
        object-fit: contain; /* CAMBIADO: contain en móvil pequeño */
        background: #f8f9fa;
        padding: 8px;
    }

    .card-body {
        padding: 1rem;
    }

    .card-gallery .card-img-top {
        height: 180px;
        object-fit: cover;
    }
}

/* ============================================
   FIX: Asegurar que no haya overflow
   ============================================ */

.card,
.card * {
    box-sizing: border-box;
}

/* Asegurar que la card tiene el tamaño correcto */
.col-md-4 .card,
.col-lg-4 .card,
.col-sm-6 .card {
    max-width: 100%;
}

/* Prevenir problemas de alineación */
.row.g-4 {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.row.g-4 > * {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* ============================================
   SKELETON LOADING
   ============================================ */

.card-skeleton {
    animation: pulse 1.5s ease-in-out infinite;
}

.card-skeleton .card-img-top {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.card-skeleton .card-body > * {
    background: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 10px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}