/*
 * Course Flip Cards Pro - Estilos Frontend
 * Efecto flip 3D para tarjetas de cursos
 */

/* ========================================
   GRID DE CURSOS
   ======================================== */

.cfcp-courses-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
    padding: 20px 0;
    max-width: 1400px;
    margin: 0 auto;
}

.cfcp-no-courses {
    text-align: center;
    padding: 40px 20px;
    font-size: 18px;
    color: #666;
}

/* ========================================
   CONTENEDOR DE TARJETA FLIP
   ======================================== */

.course-flip-container {
    perspective: 1000px;
    width: 100%;
    height: 400px;
    cursor: pointer;
    position: relative;
}

.course-flipper {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s ease-in-out;
}

/* FORZAR estado por defecto - SIN rotación */
.cfcp-courses-grid .course-flip-container .course-flipper,
.course-flip-container .course-flipper {
    transform: rotateY(0deg) !important;
    animation: none !important;
}

/* SOLO girar cuando se hace hover */
.cfcp-courses-grid .course-flip-container:hover .course-flipper,
.course-flip-container:hover .course-flipper {
    transform: rotateY(180deg) !important;
}

/* Asegurar que las imágenes no roten */
.course-flip-container img,
.course-front img,
.course-back img,
.course-image img {
    transform: none !important;
    animation: none !important;
}

/* ========================================
   CARAS DE LA TARJETA
   ======================================== */

.course-front,
.course-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.course-flip-container:hover .course-front,
.course-flip-container:hover .course-back {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

/* ========================================
   CARA FRONTAL
   ======================================== */

.course-front {
    background: #fff;
    display: flex;
    flex-direction: column;
}

.course-image {
    width: 100%;
    height: 70%;
    overflow: hidden;
    position: relative;
}

.course-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.course-flip-container:hover .course-image img {
    transform: scale(1.05);
}

.course-front-overlay {
    height: 30%;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.course-front .course-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-align: center;
    line-height: 1.4;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ========================================
   CARA TRASERA
   ======================================== */

.course-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 30px;
    position: relative;
}

.course-back-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 15px;
}

.course-title-back {
    margin: 0 0 10px 0;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
}

.course-price {
    text-align: center;
    margin-bottom: 10px;
}

.price-amount {
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========================================
   META INFORMACIÓN
   ======================================== */

.course-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.course-date,
.course-location {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.course-date svg,
.course-location svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.course-description {
    flex: 1;
    overflow: hidden;
}

.course-description p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    opacity: 0.95;
}

/* ========================================
   BOTÓN VER MÁS
   ======================================== */

.course-button {
    margin-top: auto;
}

.btn-ver-mas {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.btn-ver-mas:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.btn-ver-mas svg {
    transition: transform 0.3s ease;
}

.btn-ver-mas:hover svg {
    transform: translateX(4px);
}

/* ========================================
   BOTÓN MÓVIL (oculto en desktop)
   ======================================== */

.mobile-flip-back {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.mobile-flip-back:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.mobile-flip-back svg {
    color: #fff;
}

/* ========================================
   ANIMACIÓN DE ENTRADA
   ======================================== */

.course-flip-container {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.6s ease forwards;
}

.course-flip-container:nth-child(1) { animation-delay: 0.1s; }
.course-flip-container:nth-child(2) { animation-delay: 0.2s; }
.course-flip-container:nth-child(3) { animation-delay: 0.3s; }
.course-flip-container:nth-child(4) { animation-delay: 0.4s; }
.course-flip-container:nth-child(5) { animation-delay: 0.5s; }
.course-flip-container:nth-child(6) { animation-delay: 0.6s; }
.course-flip-container:nth-child(7) { animation-delay: 0.7s; }
.course-flip-container:nth-child(8) { animation-delay: 0.8s; }

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

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */

@media (max-width: 1024px) {
    .cfcp-courses-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    
    .course-flip-container {
        height: 380px;
    }
    
    .course-front .course-title {
        font-size: 16px;
    }
    
    .course-title-back {
        font-size: 18px;
    }
    
    .price-amount {
        font-size: 28px;
    }
}

/* ========================================
   RESPONSIVE - TABLET PEQUEÑO
   ======================================== */

@media (max-width: 768px) {
    .cfcp-courses-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 15px;
    }
    
    .course-flip-container {
        height: 350px;
    }
}

/* ========================================
   RESPONSIVE - MÓVIL
   ======================================== */

@media (max-width: 640px) {
    .cfcp-courses-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .course-flip-container {
        height: 400px;
    }
    
    /* Cambiar hover por click en móvil */
    .course-flip-container:hover .course-flipper {
        transform: none;
    }
    
    .course-flip-container.flipped .course-flipper {
        transform: rotateY(180deg);
    }
    
    /* Mostrar botón de volver en móvil */
    .mobile-flip-back {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .course-back {
        padding: 25px;
    }
    
    .course-title-back {
        font-size: 18px;
        padding-right: 40px;
    }
    
    .course-meta {
        gap: 8px;
    }
    
    .course-description p {
        font-size: 13px;
    }
}

/* ========================================
   ACCESIBILIDAD
   ======================================== */

.course-flip-container:focus-within {
    outline: 3px solid #667eea;
    outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .course-flipper {
        transition: none;
    }
    
    .course-flip-container {
        animation: none;
        opacity: 1;
        transform: none;
    }
    
    .course-image img {
        transition: none;
    }
}

/* ========================================
   LOADING STATES
   ======================================== */

.course-image img[loading="lazy"] {
    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;
    }
}
