/* 
 * PortalEduca - Mejoras Visuales
 * Fase 1 & 2: Profundidad, Microinteracciones y Elementos Visuales
 */

/* ===== MEJORAS EN VARIABLES - MÁS PROFUNDIDAD ===== */
:root {
    /* Sombras mejoradas con más niveles */
    --shadow-xs: 0 1px 2px rgba(15, 44, 89, 0.05);
    --shadow-sm: 0 2px 4px rgba(15, 44, 89, 0.08), 0 1px 2px rgba(15, 44, 89, 0.04);
    --shadow-md: 0 4px 8px rgba(15, 44, 89, 0.12), 0 2px 4px rgba(15, 44, 89, 0.08);
    --shadow-lg: 0 8px 16px rgba(15, 44, 89, 0.16), 0 4px 8px rgba(15, 44, 89, 0.12);
    --shadow-xl: 0 12px 24px rgba(15, 44, 89, 0.20), 0 8px 16px rgba(15, 44, 89, 0.16);
    --shadow-2xl: 0 20px 40px rgba(15, 44, 89, 0.24), 0 12px 24px rgba(15, 44, 89, 0.20);

    /* Sombras coloreadas para acentos */
    --shadow-accent: 0 8px 24px rgba(232, 93, 4, 0.20), 0 4px 12px rgba(232, 93, 4, 0.12);
    --shadow-accent-hover: 0 12px 32px rgba(232, 93, 4, 0.28), 0 8px 16px rgba(232, 93, 4, 0.16);

    /* Transiciones más suaves */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===== MEJORAS EN HEADER ===== */
.header {
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.header:hover {
    box-shadow: var(--shadow-md);
}

.logo {
    transition: var(--transition-smooth);
}

.logo:hover {
    transform: scale(1.05);
}

.nav-link {
    position: relative;
    transition: var(--transition-smooth);
    font-weight: 500;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--color-accent);
    transition: var(--transition-smooth);
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-link:hover {
    color: var(--color-accent);
    transform: translateY(-1px);
}

/* ===== MEJORAS EN BOTONES ===== */
.btn-acceder,
.card-button,
.hero-search-button {
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.btn-acceder:hover,
.card-button:hover,
.hero-search-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-accent-hover);
}

.btn-acceder:active,
.card-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Efecto ripple en botones */
.btn-acceder::before,
.card-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-acceder:active::before,
.card-button:active::before {
    width: 300px;
    height: 300px;
}

/* ===== MEJORAS EN CARDS DE NAVEGACIÓN (HOME) ===== */
.nav-card {
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.nav-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.1) 100%);
    opacity: 0;
    transition: var(--transition-smooth);
}

.nav-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-2xl);
}

.nav-card:hover::before {
    opacity: 1;
}

.card-icon-svg {
    transition: var(--transition-bounce);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

.nav-card:hover .card-icon-svg {
    transform: scale(1.15) rotate(5deg);
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.25));
}

/* ===== MEJORAS EN HERO SECTION ===== */
.home-hero,
.courses-hero {
    position: relative;
}

.home-hero::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, transparent, white);
    pointer-events: none;
}

.hero-title {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.02em;
}

.hero-subtitle {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ===== MEJORAS EN ESTADÍSTICAS ===== */
.stat-item {
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-sm);
}

.stat-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    background: rgba(255, 255, 255, 0.15);
}

.stat-number {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-soft));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(232, 93, 4, 0.3));
}

/* ===== MEJORAS EN PÁGINA DE CURSOS ===== */
.course-card {
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-md);
    border: 1px solid transparent;
}

.course-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-accent);
}

.course-image {
    transition: var(--transition-smooth);
}

.course-card:hover .course-image {
    transform: scale(1.1);
}

/* ===== MEJORAS EN FILTROS ===== */
.modern-filters-sidebar {
    box-shadow: var(--shadow-lg);
}

.modern-filter-select,
.hero-search-input {
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-xs);
}

.modern-filter-select:focus,
.hero-search-input:focus {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-color: var(--color-accent);
}

/* ===== MEJORAS EN FOOTER ===== */
.footer {
    background: linear-gradient(135deg, var(--color-primary-deep) 0%, var(--color-primary-medium) 100%);
    box-shadow: 0 -4px 16px rgba(15, 44, 89, 0.12);
}

.footer-link {
    transition: var(--transition-smooth);
    position: relative;
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-accent);
    transition: var(--transition-smooth);
}

.footer-link:hover::after {
    width: 100%;
}

.footer-link:hover {
    transform: translateX(4px);
    color: var(--color-accent-soft);
}

.footer-icon {
    transition: var(--transition-bounce);
}

.footer-link:hover .footer-icon {
    transform: scale(1.2) rotate(10deg);
}

/* ===== ANIMACIONES MEJORADAS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Aplicar animaciones */
.nav-card,
.course-card,
.stat-item {
    animation: fadeInUp 0.6s ease-out both;
}

.nav-card:nth-child(1) {
    animation-delay: 0.1s;
}

.nav-card:nth-child(2) {
    animation-delay: 0.2s;
}

.nav-card:nth-child(3) {
    animation-delay: 0.3s;
}

/* ===== MEJORAS EN FORMS ===== */
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    transition: var(--transition-smooth);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.1), var(--shadow-md);
    border-color: var(--color-accent);
}

/* ===== MEJORAS EN SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--color-primary-medium), var(--color-accent));
    border-radius: 10px;
    border: 2px solid var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-soft));
}

/* ===== MEJORAS PARA TEMA OSCURO ===== */
[data-theme="dark"] .header {
    background: rgba(15, 23, 42, 0.95);
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .nav-card,
[data-theme="dark"] .course-card {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

[data-theme="dark"] .stat-item:hover {
    background: rgba(100, 116, 139, 0.2);
}

/* ===== UTILIDADES ADICIONALES ===== */
.gradient-text {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-soft));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glow-effect {
    box-shadow: 0 0 20px rgba(232, 93, 4, 0.3);
}

.pulse-animation {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

/* ===== RESPONSIVE IMPROVEMENTS ===== */
@media (max-width: 768px) {
    .nav-card:hover {
        transform: translateY(-4px) scale(1.01);
    }

    .course-card:hover {
        transform: translateY(-4px);
    }
}

/* ===== MEJORAS ASISTENTE ANYTHINGLLM (WIDGET CHAT) ===== */

/* --- BOTÓN FLOTANTE (LAUNCHER) --- */
/* Añade un efecto de latido suave al botón cuando está inactivo */
#anything-llm-chat-button {
    box-shadow: var(--shadow-accent), 0 0 0 0 rgba(232, 93, 4, 0.4) !important;
    animation: anythingllm-pulse 2.5s infinite var(--transition-bounce) !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
    z-index: 99999 !important;
}

#anything-llm-chat-button:hover {
    transform: translateY(-4px) scale(1.05) !important;
    box-shadow: var(--shadow-accent-hover), 0 0 0 10px rgba(232, 93, 4, 0) !important;
    animation: none !important;
}

@keyframes anythingllm-pulse {
    0% {
        box-shadow: var(--shadow-accent), 0 0 0 0 rgba(232, 93, 4, 0.5);
    }

    70% {
        box-shadow: var(--shadow-accent), 0 0 0 12px rgba(232, 93, 4, 0);
    }

    100% {
        box-shadow: var(--shadow-accent), 0 0 0 0 rgba(232, 93, 4, 0);
    }
}

/* --- VENTANA / CONTENEDOR DE CHAT (DESKTOP) --- */
#anything-llm-chat {
    width: 320px !important;
    /* Ancho ajustado al rectángulo verde */
    max-width: 320px !important;
    height: 480px !important;
    /* Alto ajustado al rectángulo verde */
    max-height: 480px !important;
    min-height: unset !important;
    /* Desactivar mínimo genérico */
    bottom: 20px !important;
    /* Pegado abajo */
    right: 20px !important;
    /* Pegado a la derecha */
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-2xl) !important;
    border: 1px solid var(--border-color) !important;
    z-index: 998 !important;
    background: var(--bg-primary) !important;
    overflow: hidden !important;
    /* Animación de entrada estilo zoom-in suave */
    animation: scaleInChat 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) both !important;
    transform-origin: bottom right !important;
}

/* Forzar tamaño de letra interno de iframe si permite (generalmente restringido, pero por consistencia) */
#anything-llm-chat iframe,
#anything-llm-chat * {
    font-size: 0.85rem !important;
    /* Achicar fuente un 15% */
}

@keyframes scaleInChat {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

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

/* Modificar logo en cabecera del chat */
#anything-llm-chat .allm-flex.allm-w-full.allm-items-center.allm-justify-start.allm-gap-x-2 img {
    width: 100% !important;
    max-width: 110px !important;
    /* Ajustando a la caja pequeña */
    height: auto !important;
    max-height: 28px !important;
    object-fit: contain !important;
}

/* --- TEMA OSCURO PARA EL WIDGET --- */
[data-theme="dark"] #anything-llm-chat {
    background: rgba(15, 23, 42, 0.98) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(12px) !important;
    /* Efecto glassmorfismo sutil */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
}

/* Forzar imagen redonda clara de fondo al logo oscuro */
/* Selector ultra-específico que sobrepasa a los propios de AnythingLLM */
[data-theme="dark"] #anything-llm-chat div.allm-flex.allm-w-full img[src*="favicon"] {
    background-color: #ffffff !important;
    border-radius: 8px !important;
    /* Cuadrado redondeado simple */
    padding: 4px !important;
    /* Almohadilla para que se vea el blanco */
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3) !important;
}

[data-theme="dark"] #anything-llm-chat-button {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(232, 93, 4, 0.3) !important;
}

/* --- VENTANA / CONTENEDOR DE CHAT (MOBILE BOTTOM SHEET Y BOTON) --- */
@media screen and (max-width: 768px) {

    /* Forzar visibilidad absoluta del launcher en mobile usando body local para mayor especificidad */
    body #anything-llm-chat-button,
    html body #anything-llm-chat-button {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        position: fixed !important;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
        right: 15px !important;
        width: 45px !important;
        /* Chico, acorde a mobile */
        height: 45px !important;
        z-index: 99999 !important;
        /* Siempre garantizado arriba */
        border-radius: 50% !important;
        pointer-events: auto !important;
    }

    body #anything-llm-chat-button img {
        width: 25px !important;
        /* Icono chico interno*/
        height: 25px !important;
        display: block !important;
    }

    /* Caja de chat en mobile */
    body #anything-llm-chat {
        /* Tamaño modal, un poco más chico que la pantalla para notar que es popup */
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        height: calc(85dvh - 20px) !important;
        max-height: calc(85dvh - 20px) !important;
        min-height: unset !important;
        bottom: 10px !important;
        right: 10px !important;
        margin: 0 !important;

        /* Estilos de bordes y profundidad en movil */
        border-radius: var(--radius-xl) !important;
        border: 1px solid var(--border-color) !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
        transform-origin: bottom right !important;
        z-index: 99999 !important;

        /* Uso de safe area insets (iOS/Android modernos) */
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }

    /* Reforzar visibilidad absoluta del botón "cerrar" (X) y el menú superior en movil */
    body #anything-llm-chat .allm-w-full.allm-flex.allm-items-center.allm-justify-between,
    body #anything-llm-chat .allm-flex.allm-w-full.allm-items-center.allm-justify-end button,
    body #anything-llm-chat button[aria-label*="Cerrar"],
    body #anything-llm-chat button[aria-label*="Close"] {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    body #anything-llm-chat button svg {
        width: 28px !important;
        height: 28px !important;
    }

    [data-theme="dark"] body #anything-llm-chat {
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
    }
}