/* ============================================
   ESTILOS PARA BÚSQUEDA GLOBAL
   ============================================ */

.search-container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    z-index: 1000;
    max-height: 500px;
    overflow-y: auto;
    margin-top: 2px;
}

.search-results {
    padding: 0;
}

.search-section {
    border-bottom: 1px solid var(--gray-200);
}

.search-section:last-child {
    border-bottom: none;
}

.search-section-title {
    padding: 12px 16px 8px;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
}

.search-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background-color: var(--primary-light);
    color: var(--text-color);
    text-decoration: none;
}

.search-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.search-item-icon i {
    font-size: 1.2rem;
}

.search-item-content {
    flex: 1;
    min-width: 0;
}

.search-item-title {
    font-weight: 500;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--text-color);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-item-title mark {
    background-color: var(--accent-color);
    color: var(--white);
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 600;
}

.search-item-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-item-meta .instructor {
    font-weight: 500;
}

.search-item-meta .price {
    color: var(--primary-color);
    font-weight: 600;
}

.search-footer {
    padding: 12px 16px;
    background-color: var(--gray-100);
    border-top: 1px solid var(--gray-200);
}

.search-loading,
.search-error,
.no-results {
    padding: 20px;
}

.search-loading .spinner-border {
    width: 24px;
    height: 24px;
}

.no-results i {
    font-size: 2rem;
    color: var(--gray-400);
}

/* Responsive para búsqueda */
@media (max-width: 768px) {
    .search-container {
        max-width: 100%;
    }

    .search-dropdown {
        max-height: 400px;
    }

    .search-item {
        padding: 10px 12px;
    }

    .search-item-title {
        font-size: 0.9rem;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* ============================================
   ESTILOS PARA MEGA MENÚ DINÁMICO
   ============================================ */

.mega-menu .dropdown-menu {
    animation: fadeInUp 0.3s ease-out;
}

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

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

.mega-menu-item {
    transition: all 0.2s ease;
}

.mega-menu-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mega-menu-icon {
    transition: transform 0.2s ease;
}

.mega-menu-item:hover .mega-menu-icon {
    transform: scale(1.1);
}

.mega-menu-content h5 {
    transition: color 0.2s ease;
}

.mega-menu-item:hover .mega-menu-content h5 {
    color: var(--primary-color);
}

/* Indicador de carga para mega menú */
.mega-menu .spinner-border {
    width: 40px;
    height: 40px;
}

/* Añade este bloque a tu archivo CSS */
.mega-menu-section-title {
    font-size: 1.1rem;
    /* Un poco más grande que el mega-menu-header */
    font-weight: 600;
    color: #333;
    /* Color oscuro para el texto */
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
    /* Una línea separadora sutil */
    margin-bottom: 15px !important;
    /* Espacio debajo del título */
    /* El margin-top se ajusta en el JS (mt-3 y mt-4) */
}

/* Puedes añadir o ajustar estilos para los mega-menu-item si deseas que los de certificados tengan un look ligeramente distinto, aunque he usado el mismo para consistencia */
.mega-menu-item .mega-menu-content p {
    font-size: 0.8rem;
    color: #6c757d;
    /* Color de texto gris para la descripción */
    margin-bottom: 0;
}

/* ============================================
   MODAL DE TODAS LAS CATEGORÍAS
   ============================================ */

.category-card {
    transition: var(--transition);
}

.category-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
}

.category-card .card {
    transition: var(--transition);
    border: 1px solid var(--gray-200);
}

.category-card:hover .card {
    border-color: var(--primary-color);
    box-shadow: var(--box-shadow);
}

.category-icon {
    transition: transform 0.2s ease;
}

.category-card:hover .category-icon {
    transform: scale(1.1);
}

.category-card .card-title {
    color: var(--text-color);
    font-weight: 600;
    margin-bottom: 8px;
    transition: color 0.2s ease;
}

.category-card:hover .card-title {
    color: var(--primary-color);
}

/* ============================================
   MEJORAS PARA NAVEGACIÓN MOBILE
   ============================================ */

@media (max-width: 991.98px) {
    .mega-menu .dropdown-menu {
        position: static !important;
        transform: none !important;
        box-shadow: none;
        border: none;
        margin-top: 0;
        animation: none;
    }

    .mega-menu-right-col {
        border-left: none;
        border-top: 1px solid var(--gray-200);
        padding-left: 0;
        padding-top: 20px;
        margin-top: 20px;
    }

    .mega-menu-item {
        padding: 10px 15px;
        margin-bottom: 5px;
        border-radius: var(--border-radius);
    }

    .mega-menu-header {
        font-size: 0.9rem;
        margin-bottom: 10px;
        padding-bottom: 3px;
    }

    .feature-card {
        margin-bottom: 15px;
        padding: 15px;
    }
}

/* ============================================
   ESTADOS DE CARGA Y ERROR
   ============================================ */

.loading-skeleton {
    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;
    }
}

.error-state {
    color: var(--danger);
    text-align: center;
    padding: 20px;
}

.error-state i {
    font-size: 2rem;
    margin-bottom: 10px;
}

/* ============================================
   SCROLL PERSONALIZADO PARA DROPDOWN
   ============================================ */

.search-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-dropdown::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.search-dropdown::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}

.search-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

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

.mega-menu-item {
    opacity: 0;
    animation: slideInLeft 0.3s ease-out forwards;
}

.mega-menu-item:nth-child(1) {
    animation-delay: 0.1s;
}

.mega-menu-item:nth-child(2) {
    animation-delay: 0.15s;
}

.mega-menu-item:nth-child(3) {
    animation-delay: 0.2s;
}

.mega-menu-item:nth-child(4) {
    animation-delay: 0.25s;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

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

.feature-card {
    opacity: 0;
    animation: slideInRight 0.4s ease-out 0.3s forwards;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

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

.search-item:focus,
.category-card:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.mega-menu-item:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    border-radius: var(--border-radius);
}

/* Reducir animaciones para usuarios que prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {

    .mega-menu .dropdown-menu,
    .mega-menu-item,
    .feature-card,
    .category-card,
    .search-item {
        animation: none;
        transition: none;
    }

    .mega-menu-item:hover,
    .category-card:hover {
        transform: none;
    }
}