/* EstilosCurso.css - Versión optimizada para 4 tarjetas por fila */

/* ===== ESTILOS BASE ===== */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-family: Arial, sans-serif !important;
}

body {
    font-family: Arial, sans-serif;
    background: #f0f0f0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    flex: 1;
}

/* ===== CONTENEDOR PRINCIPAL DE CURSOS ===== */
.courses-container {
    width: 100%;
    min-height: 100vh;
    padding: 20px 0;
    box-sizing: border-box;
    overflow-y: auto;
}

/* ===== TARJETAS OPTIMIZADAS PARA 4 POR FILA ===== */
.course-card {
    height: auto; /* Altura automática según contenido */
    min-height: 350px; /* Más altura para títulos largos */
    transition: all 0.3s;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 20px; /* Más espacio entre tarjetas */
    background-color: white;
}

.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0,0,0,0.15);
}

.course-card.selected {
    border: 3px solid #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25), 0 10px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    position: relative;
}

/* ===== CONTENEDOR DE IMAGEN CUADRADO SIN BORDES ===== */
.course-image-container {
    width: 100%;
    aspect-ratio: 1 / 1; /* Cuadrado perfecto */
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Sin borde inferior */
}

/* IMAGEN QUE OCUPA TODO EL ESPACIO SIN PADDING ===== */
.course-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Muestra toda la imagen sin recortar */
    object-position: center;
    display: block;
    transition: transform 0.3s;
    background-color: white;
}

.course-image-container:hover .course-image {
    transform: scale(1.08); /* Zoom más suave */
}

/* ===== CONTENIDO CON ESPACIO PARA TÍTULOS LARGOS ===== */
.course-content {
    padding: 15px 12px 18px; /* Más padding en general */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    box-sizing: border-box;
    min-height: 150px; /* Más espacio mínimo */
}

/* ===== TÍTULOS CON EXPANSIÓN VERTICAL COMPLETA ===== */
.course-title {
    font-size: 0.9rem; /* Un poco más grande */
    font-weight: bold;
    margin: 10px 0; /* Más espacio */
    text-align: center;
    line-height: 1.4; /* Más espacio entre líneas */
    cursor: pointer;
    color: #333;
    transition: color 0.2s;
    display: block;
    white-space: normal; /* Permite saltos de línea */
    word-wrap: break-word; /* Rompe palabras largas */
    word-break: normal; /* Rompe normalmente */
    min-height: 50px; /* Más altura mínima */
    padding: 0 8px; /* Más padding lateral */
    /* Eliminar cualquier limitación de líneas */
    display: block !important;
    -webkit-line-clamp: initial !important;
    -webkit-box-orient: horizontal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    /* Permitir que crezca según contenido */
    height: auto !important;
    max-height: none !important;
}

.course-title:hover {
    color: #0d6efd;
}

/* Clase para títulos muy largos (se aplica con JS) */
.course-title.long-title {
    font-size: 0.85rem; /* Un poco más pequeño */
    line-height: 1.3;
    padding: 5px 6px; /* Menos padding */
}

/* Clase para títulos extremadamente largos */
.course-title.very-long-title {
    font-size: 0.8rem;
    line-height: 1.2;
}

/* Clase para títulos extremadamente largos (scroll interno) */
.course-title.extremely-long {
    max-height: 100px;
    overflow-y: auto;
    padding-right: 5px;
    font-size: 0.78rem;
    line-height: 1.2;
}

/* ===== BOTÓN SIEMPRE EN LA PARTE INFERIOR ===== */
.course-button-container {
    margin-top: auto; /* Empuja el botón hacia abajo */
    padding-top: 15px; /* Más espacio para títulos largos */
}

.course-button {
    width: 100%;
    padding: 8px 0;
    font-weight: bold;
    font-size: 0.8rem;
    background: linear-gradient(to bottom, #EAF2F0, #c4d9d1);
    color: #2c3e50;
    border: 1px solid #b8d0c7;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.course-button:hover {
    background: linear-gradient(to bottom, #d4e4df, #b0ccc2);
    color: #1a252f;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

/* ===== ESTILOS PARA FILAS DE CURSOS ===== */
.course-row {
    position: relative;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
}

/* Clase especial para fila con modal abierto */
.course-row.row-with-modal {
    min-height: 400px;
    position: relative;
    z-index: 9999;
}

/* ===== EFECTO DE FONDO DESENFOCADO CUANDO EL MODAL ESTÁ ABIERTO ===== */
body.modal-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9998;
    pointer-events: none;
}

body.modal-open {
    overflow: hidden;
}

/* Deshabilitar todas las tarjetas excepto la seleccionada */
body.modal-open .course-card:not(.selected) {
    opacity: 0.4;
    pointer-events: none;
    filter: blur(3px);
    transition: all 0.3s ease;
}

/* Mantener visible y enfocada la tarjeta seleccionada */
.course-card.selected {
    position: relative;
    z-index: 9999;
    border: 3px solid #0d6efd;
    box-shadow: 0 0 15px rgba(13, 110, 253, 0.5);
    transform: scale(1.02);
    transition: all 0.3s ease;
}

/* ===== ESTILOS PARA MODALES ===== */
.contextual-modal {
    position: absolute !important;
    z-index: 10000 !important;
    background-color: white !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
    border: 1px solid #ddd !important;
    max-width: 400px !important;
    width: 85% !important;
    padding: 0 !important;
    margin: 0 !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

/* Modal de información con z-index más alto */
#infoModal {
    z-index: 10001 !important;
}

.contextual-modal .modal-content {
    border: none !important;
    border-radius: 8px !important;
}

.contextual-modal .modal-header {
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6 !important;
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
    padding: 12px 15px !important;
    position: relative;
}

.contextual-modal .modal-header .btn-close {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    padding: 6px !important;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat !important;
    border: 0 !important;
    border-radius: 0.25rem !important;
    opacity: 0.5 !important;
    width: 1em !important;
    height: 1em !important;
    font-size: 1.2rem !important;
}

.contextual-modal .modal-header .btn-close:hover {
    opacity: 0.75 !important;
}

.contextual-modal .modal-body {
    padding: 12px !important;
    font-size: 0.9rem;
}

.contextual-modal .modal-footer {
    border-top: 1px solid #dee2e6 !important;
    padding: 10px 12px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
}

/* Info icon */
.info-icon {
    cursor: pointer;
    color: #0d6efd;
    margin-left: 8px;
    font-size: 0.9rem;
}

.info-icon:hover {
    color: #0b5ed7;
}

/* Radio button styles */
.payment-option {
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
}

.payment-option:hover {
    background-color: #f8f9fa;
    border-color: #0d6efd;
}

.payment-option input[type="radio"] {
    margin-right: 8px;
}

.payment-option label {
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 0;
    flex-grow: 1;
}

/* ===== BOTONES DE MODALES ===== */
.modal-btn {
    padding: 6px 16px;
    border-radius: 5px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85rem;
    min-width: 90px;
    text-align: center;
}

.modal-btn-secondary {
    background: linear-gradient(to bottom, #f8f9fa, #e2e6ea);
    color: #495057;
    border: 1px solid #ced4da;
}

.modal-btn-secondary:hover {
    background: linear-gradient(to bottom, #e2e6ea, #dae0e5);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.modal-btn-primary {
    background: linear-gradient(to bottom, #EAF2F0, #c4d9d1);
    color: #2c3e50;
    border: 1px solid #b8d0c7;
    font-weight: bold;
}

.modal-btn-primary:hover {
    background: linear-gradient(to bottom, #d4e4df, #b0ccc2);
    color: #1a252f;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* ===== AJUSTES RESPONSIVE ESPECÍFICOS ===== */

/* Pantallas grandes (4 tarjetas por fila) */
@media (min-width: 992px) {
    .col-md-3 {
        width: 25%; /* 4 tarjetas por fila */
    }
    
    .course-title {
        font-size: 0.9rem;
        min-height: 60px; /* Más espacio para títulos largos */
        /* Sin límite de líneas, mostrar completo */
        display: block;
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
    }
}

/* Tablets (3 tarjetas por fila) */
@media (min-width: 768px) and (max-width: 991px) {
    .col-md-3 {
        width: 33.333%; /* 3 tarjetas por fila */
    }
    
    .course-title {
        font-size: 0.85rem;
        min-height: 70px; /* Aún más espacio en tablets */
        line-height: 1.3;
    }
}

/* Tablets pequeñas (2 tarjetas por fila) */
@media (min-width: 576px) and (max-width: 767px) {
    .col-sm-6 {
        width: 50%; /* 2 tarjetas por fila */
    }
    
    .course-image-container {
        aspect-ratio: 4/3; /* Más rectangular en tablets */
    }
    
    .course-title {
        font-size: 0.85rem;
        min-height: 80px; /* Más altura para títulos largos */
        line-height: 1.3;
        padding: 0 10px;
    }
}

/* Móviles (1 tarjeta por fila) */
@media (max-width: 575px) {
    .col-12 {
        width: 100%;
    }
    
    .course-image-container {
        aspect-ratio: 16/9; /* Panorámico en móviles */
        height: 180px;
    }
    
    .course-title {
        font-size: 0.9rem;
        min-height: auto; /* Altura automática */
        line-height: 1.4;
        padding: 0 15px;
        /* Permitir crecimiento completo */
        height: auto;
        max-height: none;
        white-space: normal;
    }
    
    .course-card {
        margin-bottom: 20px;
    }
}

/* Mobile adjustments for modals */
@media (max-width: 576px) {
    .contextual-modal {
        width: 90% !important;
        max-width: 350px !important;
    }
    
    .contextual-modal .modal-footer {
        flex-direction: column;
    }
    
    .contextual-modal .modal-footer button {
        width: 100%;
        margin-bottom: 6px;
    }
    
    .modal-btn {
        width: 100%;
        padding: 8px;
    }
}

/* Clase para esconder modal */
.modal-hidden {
    display: none !important;
}

.modal-visible {
    display: block !important;
}

/* Asegurar que el modal de información tenga el mismo tamaño */
.info-modal-size {
    max-width: 400px !important;
    width: 85% !important;
}

/* ===== AJUSTES PARA TARJETAS DE IGUAL ALTURA ===== */
@media (min-width: 768px) {
    .course-card {
        height: 100%;
    }
}

/* ===== EVITAR OVERFLOW HORIZONTAL ===== */
* {
    max-width: 100%;
    box-sizing: border-box;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* ===== ESTILOS RESPONSIVE GENERALES ===== */
@media (max-width: 767px) {
    .container {
        width: 100%;
        padding: 10px;
    }
    
    .courses-container {
        padding: 10px 0;
    }
}

/* ===== ESTILOS PARA CENTRAR LA ÚLTIMA FILA ===== */
.center-last-row {
    justify-content: center;
}

/* ===== ESTILOS PARA SCROLL VERTICAL SUAVE ===== */
html {
    scroll-behavior: smooth;
}

/* ===== ESTILOS PARA CURSOS SIN IMAGEN ===== */
.course-no-image {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
    height: 100%;
}

/* Para pantallas de escritorio grandes */
@media (min-width: 1200px) {
    .course-image-container {
        aspect-ratio: 1 / 1; /* Mantener cuadrado */
    }
}

/* Para pantallas muy grandes */
@media (min-width: 1400px) {
    .course-image-container {
        aspect-ratio: 1 / 1;
    }
}

/* Efecto de transición suave para todo */
* {
    transition: all 0.3s ease;
}

/* ===== SCROLL INVISIBLE PERO FUNCIONAL ===== */
.contenedor-pagina-scroll::-webkit-scrollbar {
    width: 0px;
    height: 0px;
    background: transparent;
}

.contenedor-pagina-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.contenedor-pagina-scroll::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 0px;
}

.contenedor-pagina-scroll::-webkit-scrollbar-thumb:hover {
    background: transparent;
}

.contenedor-pagina-scroll {
    scrollbar-width: none;
}

.contenedor-pagina-scroll {
    -ms-overflow-style: none;
}

body::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

body {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.contenedor-pagina-scroll {
    -webkit-overflow-scrolling: touch;
}

/* ===== CLASES ESPECIALES PARA AJUSTES DE IMÁGENES ===== */
.course-image.portrait {
    width: auto;
    height: 100%;
}

.course-image.landscape {
    width: 100%;
    height: auto;
}

/* ===== AJUSTES ESPECÍFICOS PARA MEJOR VISUALIZACIÓN ===== */
/* Asegurar que las imágenes se vean bien en todos los dispositivos */
.course-image-container img {
    max-width: 100%;
    max-height: 100%;
}

/* Para cuando las imágenes son exactamente cuadradas */
.course-image[src*=".jpg"]:not([class*="portrait"]):not([class*="landscape"]) {
    object-fit: contain;
}

/* ===== CLASES ESPECIALES PARA TÍTULOS LARGOS ===== */
.course-card:has(.very-long-title) {
    min-height: 370px;
}

.course-card:has(.long-title) {
    min-height: 350px;
}

.course-card:has(.extremely-long) {
    min-height: 400px;
}

/* Ajustar botón para mantener posición */
.course-card:has(.long-title) .course-button-container,
.course-card:has(.very-long-title) .course-button-container,
.course-card:has(.extremely-long) .course-button-container {
    margin-top: 15px;
    padding-top: 15px;
}

/* Scroll personalizado para títulos extremadamente largos */
.course-title.extremely-long::-webkit-scrollbar {
    width: 4px;
}

.course-title.extremely-long::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.course-title.extremely-long::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.course-title.extremely-long::-webkit-scrollbar-thumb:hover {
    background: #555;
}