/**
 * OS TigerLab — Panel alumno/catálogo: capa premium (Senior)
 * Cargar después de panel.css. Depende de variables :root de panel.css.
 *
 * - Tipografía & color-scheme
 * - Carga estable (skeleton + spinner), menos CLS
 * - Cards con profundidad, focus-visible, micro-interacciones
 * - Entrada escalonada (catálogo + dashboard listo)
 * - Toasts y errores más claros
 */

:root {
    --panel-premium-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --panel-premium-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
    --panel-premium-dur: 0.5s;
    --panel-premium-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --panel-premium-shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.5);
    --panel-premium-ring: 0 0 0 2px var(--accent-sec), 0 0 0 4px rgba(0, 180, 255, 0.15);
}

html {
    color-scheme: dark;
}

[data-theme='light'] {
    color-scheme: light;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ---------- Spinner de carga (estable, no empuja layout) ---------- */
@keyframes panel-premium-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes panel-premium-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes panel-premium-reveal {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes panel-premium-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.student-dashboard-loading {
    min-height: min(70vh, 560px);
    display: flex;
    flex-direction: column;
    gap: var(--space-20);
    justify-content: flex-start;
    contain: layout style;
}

.student-dashboard-loading-copy {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--text);
}

.student-dashboard-loading-copy::before {
    content: '';
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(0, 255, 156, 0.2);
    border-top-color: var(--accent);
    animation: panel-premium-spin 0.75s linear infinite;
}

.student-dashboard-skeleton {
    position: relative;
    overflow: hidden;
    contain: layout style;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(135deg, rgba(28, 28, 30, 0.95) 0%, rgba(18, 18, 20, 0.98) 100%);
    animation: none;
}

.student-dashboard-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 0%,
        rgba(255, 255, 255, 0.06) 45%,
        transparent 90%
    );
    animation: panel-premium-shimmer 1.8s ease-in-out infinite;
    pointer-events: none;
}

/* ---------- Catálogo público: cards refinadas ---------- */
.course-card {
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        border-color var(--transition-fast);
}

@media (hover: hover) {
    .course-card:hover {
        box-shadow: var(--panel-premium-shadow-hover);
        border-color: rgba(0, 255, 156, 0.22);
    }

    .course-card--estrella:hover {
        border-color: rgba(0, 255, 156, 0.55);
    }
}

.course-card:focus-within {
    outline: none;
    border-color: rgba(0, 180, 255, 0.45);
    box-shadow: var(--panel-premium-ring), var(--panel-premium-shadow);
}

.course-image {
    position: relative;
}

.course-image img {
    transition: transform var(--panel-premium-dur) var(--panel-premium-ease);
}

@media (hover: hover) {
    .course-card:hover .course-image img {
        transform: scale(1.04);
    }
}

.btn-course {
    transition:
        transform var(--transition-fast),
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

@media (hover: hover) {
    .btn-course:hover {
        box-shadow: 0 6px 24px rgba(0, 255, 156, 0.2);
    }
}

.btn-course:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 255, 156, 0.25);
}

/* Reveal escalonado catálogo (solo motion OK) */
@media (prefers-reduced-motion: no-preference) {
    .group-container > .group-card {
        animation: panel-premium-reveal var(--panel-premium-dur) var(--panel-premium-ease) both;
    }

    .group-container > .group-card:nth-child(1) {
        animation-delay: 0.04s;
    }
    .group-container > .group-card:nth-child(2) {
        animation-delay: 0.1s;
    }
    .group-container > .group-card:nth-child(3) {
        animation-delay: 0.16s;
    }
    .group-container > .group-card:nth-child(4) {
        animation-delay: 0.22s;
    }
    .group-container > .group-card:nth-child(5) {
        animation-delay: 0.28s;
    }
    .group-container > .group-card:nth-child(6) {
        animation-delay: 0.34s;
    }
    .group-container > .group-card:nth-child(n + 7) {
        animation-delay: 0.4s;
    }

    .course-container .course-card {
        animation: panel-premium-reveal 0.42s var(--panel-premium-ease) both;
    }

    .course-container .course-card:nth-child(1) {
        animation-delay: 0.02s;
    }
    .course-container .course-card:nth-child(2) {
        animation-delay: 0.06s;
    }
    .course-container .course-card:nth-child(3) {
        animation-delay: 0.1s;
    }
    .course-container .course-card:nth-child(4) {
        animation-delay: 0.14s;
    }
    .course-container .course-card:nth-child(5) {
        animation-delay: 0.18s;
    }
    .course-container .course-card:nth-child(6) {
        animation-delay: 0.22s;
    }
    .course-container .course-card:nth-child(7) {
        animation-delay: 0.26s;
    }
    .course-container .course-card:nth-child(8) {
        animation-delay: 0.3s;
    }
    .course-container .course-card:nth-child(n + 9) {
        animation-delay: 0.34s;
    }
}

/* ---------- Dashboard alumno cuando el contenido está listo ---------- */
body.panel-dashboard-ready .student-dashboard-content {
    animation: panel-premium-fade-in 0.45s var(--panel-premium-ease) both;
}

body.panel-dashboard-ready .student-dashboard-header {
    animation: panel-premium-reveal 0.55s var(--panel-premium-ease) both;
}

body.panel-dashboard-ready .student-dashboard-tabs {
    animation: panel-premium-reveal 0.5s var(--panel-premium-ease) 0.06s both;
}

@media (prefers-reduced-motion: reduce) {
    body.panel-dashboard-ready .student-dashboard-content,
    body.panel-dashboard-ready .student-dashboard-header,
    body.panel-dashboard-ready .student-dashboard-tabs {
        animation: none;
    }
}

.student-dashboard-card {
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        border-color var(--transition-fast);
}

.student-dashboard-card:focus-within {
    outline: none;
    border-color: rgba(0, 180, 255, 0.4);
    box-shadow: var(--panel-premium-ring);
}

@media (hover: hover) {
    .student-dashboard-card:hover {
        box-shadow: var(--panel-premium-shadow);
        border-color: rgba(255, 255, 255, 0.14);
    }
}

.student-dashboard-rec-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s var(--panel-premium-ease);
}

@media (hover: hover) {
    .student-dashboard-rec-card:hover {
        border-color: rgba(0, 255, 156, 0.2);
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
        transform: translateY(-2px);
    }
}

.student-dashboard-activity-list li {
    transition: background 0.15s ease;
}

.student-dashboard-activity-list li:hover {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

[data-theme='light'] .student-dashboard-activity-list li:hover {
    background: rgba(0, 0, 0, 0.045);
}

/* ---------- Error & toast (feedback claro) ---------- */
.student-dashboard-error {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    border-radius: var(--radius);
    border-left: 4px solid #f87171;
}

.student-dashboard-error::before {
    content: '!';
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(248, 113, 113, 0.2);
    color: #fecaca;
    font-weight: 800;
    font-size: 0.875rem;
    display: grid;
    place-items: center;
    line-height: 1;
}

.student-dashboard-toast {
    border-radius: 12px;
    padding: 14px 22px;
    max-width: min(420px, calc(100vw - 32px));
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(0, 255, 156, 0.28);
}

/* ---------- Tabs: indicador activo ---------- */
.student-dashboard-tab {
    position: relative;
    transition:
        color 0.2s ease,
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease;
}

.student-dashboard-tab.active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-sec));
    opacity: 0.95;
}

@media (max-width: 720px) {
    .student-dashboard-tab.active::after {
        bottom: 2px;
        width: 24px;
    }
}

.student-dashboard-tab:active {
    transform: scale(0.98);
}

/* ---------- Secciones con ritmo visual ---------- */
.student-dashboard-section-title {
    letter-spacing: -0.02em;
}

.student-dashboard-section + .student-dashboard-section {
    margin-top: var(--space-8);
}

/* ---------- Tema claro: capas que usaban grises fijos ---------- */
[data-theme='light'] .student-dashboard-skeleton {
    background: linear-gradient(135deg, rgba(250, 250, 252, 0.98) 0%, rgba(235, 236, 240, 0.99) 100%);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme='light'] .student-dashboard-skeleton::after {
    background: linear-gradient(
        105deg,
        transparent 0%,
        rgba(0, 0, 0, 0.04) 45%,
        transparent 90%
    );
}

[data-theme='light'] .student-dashboard-loading-copy::before {
    border-color: rgba(0, 180, 120, 0.25);
    border-top-color: var(--accent);
}

[data-theme='light'] .student-dashboard-toast {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 200, 130, 0.35);
}

/* ---------- Cabecera panel: vidrio legible ---------- */
.panel-header {
    backdrop-filter: blur(14px) saturate(1.15);
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
    background: color-mix(in oklab, var(--bg-elevated) 86%, transparent);
}

[data-theme='light'] .panel-header {
    background: color-mix(in oklab, var(--bg-elevated) 92%, transparent);
}

.panel-nav a:focus-visible {
    outline: 2px solid var(--accent-sec);
    outline-offset: 4px;
    border-radius: 4px;
}

/* ---------- Avatar y métricas ---------- */
.student-dashboard-avatar {
    box-shadow:
        0 0 0 2px color-mix(in oklab, var(--bg) 75%, transparent),
        0 0 0 4px rgba(0, 255, 156, 0.22);
}

[data-theme='light'] .student-dashboard-avatar {
    box-shadow:
        0 0 0 2px var(--bg),
        0 0 0 4px rgba(0, 180, 120, 0.2);
}

.student-dashboard-metric {
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s var(--panel-premium-ease);
}

@media (hover: hover) {
    .student-dashboard-metric:hover {
        border-color: rgba(0, 255, 156, 0.22);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
        transform: translateY(-1px);
    }
}

/* ---------- Tabs: carril en móvil + contenedor ---------- */
.student-dashboard-tabs {
    gap: 6px;
    padding: 6px 4px var(--space-16);
    margin-left: -4px;
    margin-right: -4px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    border-bottom: var(--border-default);
}

[data-theme='light'] .student-dashboard-tabs {
    background: rgba(0, 0, 0, 0.04);
}

@media (max-width: 640px) {
    .student-dashboard-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
        mask-image: linear-gradient(90deg, #000 92%, transparent 100%);
    }

    .student-dashboard-tabs::-webkit-scrollbar {
        display: none;
    }

    .student-dashboard-tab {
        scroll-snap-align: start;
        flex-shrink: 0;
    }
}

.student-dashboard-tab:focus-visible {
    outline-offset: 3px;
}

/* ---------- Dashboard listo: stagger en grids internos ---------- */
@media (prefers-reduced-motion: no-preference) {
    body.panel-dashboard-ready .student-dashboard-mycourses-grid > .student-dashboard-card {
        animation: panel-premium-reveal 0.44s var(--panel-premium-ease) both;
    }

    body.panel-dashboard-ready .student-dashboard-mycourses-grid > .student-dashboard-card:nth-child(1) {
        animation-delay: 0.04s;
    }
    body.panel-dashboard-ready .student-dashboard-mycourses-grid > .student-dashboard-card:nth-child(2) {
        animation-delay: 0.08s;
    }
    body.panel-dashboard-ready .student-dashboard-mycourses-grid > .student-dashboard-card:nth-child(3) {
        animation-delay: 0.12s;
    }
    body.panel-dashboard-ready .student-dashboard-mycourses-grid > .student-dashboard-card:nth-child(4) {
        animation-delay: 0.16s;
    }
    body.panel-dashboard-ready .student-dashboard-mycourses-grid > .student-dashboard-card:nth-child(5) {
        animation-delay: 0.2s;
    }
    body.panel-dashboard-ready .student-dashboard-mycourses-grid > .student-dashboard-card:nth-child(n + 6) {
        animation-delay: 0.24s;
    }

    body.panel-dashboard-ready .student-dashboard-recommended-grid > .student-dashboard-rec-card {
        animation: panel-premium-reveal 0.4s var(--panel-premium-ease) both;
    }

    body.panel-dashboard-ready .student-dashboard-recommended-grid > .student-dashboard-rec-card:nth-child(1) {
        animation-delay: 0.05s;
    }
    body.panel-dashboard-ready .student-dashboard-recommended-grid > .student-dashboard-rec-card:nth-child(2) {
        animation-delay: 0.1s;
    }
    body.panel-dashboard-ready .student-dashboard-recommended-grid > .student-dashboard-rec-card:nth-child(3) {
        animation-delay: 0.14s;
    }
    body.panel-dashboard-ready .student-dashboard-recommended-grid > .student-dashboard-rec-card:nth-child(4) {
        animation-delay: 0.18s;
    }
    body.panel-dashboard-ready .student-dashboard-recommended-grid > .student-dashboard-rec-card:nth-child(n + 5) {
        animation-delay: 0.22s;
    }

    body.panel-dashboard-ready .student-dashboard-continue-card:not(.empty) {
        animation: panel-premium-reveal 0.48s var(--panel-premium-ease) 0.02s both;
    }
}

/* ---------- Imagen en card curso (misma familia que catálogo) ---------- */
.student-dashboard-card-img {
    transition: transform var(--panel-premium-dur) var(--panel-premium-ease);
}

@media (hover: hover) {
    .student-dashboard-card:hover .student-dashboard-card-img {
        transform: scale(1.03);
    }
}

/* ---------- Continuar aprendiendo + CTA destacados ---------- */
.student-dashboard-continue-card {
    transition:
        box-shadow 0.25s var(--panel-premium-ease),
        border-color 0.2s ease;
}

@media (hover: hover) {
    .student-dashboard-continue-card:not(.empty):hover {
        box-shadow: var(--panel-premium-shadow);
        border-color: rgba(0, 255, 156, 0.18);
    }
}

.student-dashboard-onboarding {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.student-dashboard-post-purchase {
    box-shadow: 0 10px 36px rgba(0, 255, 156, 0.1);
}

.student-dashboard-rec-card:focus-within {
    outline: none;
    border-color: rgba(0, 180, 255, 0.42);
    box-shadow: var(--panel-premium-ring);
}

.student-dashboard-btn-continue,
.student-dashboard-btn-outline,
.student-dashboard-btn-catalog {
    transition:
        transform 0.18s var(--panel-premium-ease),
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

@media (hover: hover) {
    .student-dashboard-btn-continue:hover,
    .student-dashboard-btn-catalog:hover {
        transform: translateY(-1px);
    }

    .student-dashboard-btn-outline:hover {
        transform: translateY(-1px);
    }
}

.student-dashboard-btn-continue:active,
.student-dashboard-btn-outline:active,
.student-dashboard-btn-catalog:active {
    transform: translateY(0);
}

/* ---------- Búsqueda y filtros ---------- */
.student-dashboard-search {
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.student-dashboard-search:focus {
    box-shadow: 0 0 0 3px rgba(0, 255, 156, 0.14);
}

[data-theme='light'] .student-dashboard-search:focus {
    box-shadow: 0 0 0 3px rgba(0, 180, 120, 0.12);
}

.student-dashboard-filter-btn {
    transition:
        transform 0.15s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        background 0.2s ease;
}

.student-dashboard-filter-btn:active {
    transform: scale(0.98);
}

/* ---------- Barra de progreso más “viva” ---------- */
.student-dashboard-progress-bar {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
}

.student-dashboard-progress-fill {
    box-shadow: 0 0 14px rgba(0, 255, 156, 0.28);
}

[data-theme='light'] .student-dashboard-progress-fill {
    box-shadow: 0 0 10px rgba(0, 180, 100, 0.22);
}

/* ---------- Progress bar pulso sutil al cargar ---------- */
body.panel-dashboard-ready .student-dashboard-progress-fill {
    animation: panel-premium-progress-pop 0.6s var(--panel-premium-ease) both;
}

@keyframes panel-premium-progress-pop {
    from {
        filter: brightness(1.35);
    }
    to {
        filter: brightness(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.panel-dashboard-ready .student-dashboard-progress-fill {
        animation: none;
    }

    body.panel-dashboard-ready .student-dashboard-mycourses-grid > .student-dashboard-card,
    body.panel-dashboard-ready .student-dashboard-recommended-grid > .student-dashboard-rec-card,
    body.panel-dashboard-ready .student-dashboard-continue-card {
        animation: none !important;
    }

    .student-dashboard-skeleton::after {
        animation: none;
    }

    .student-dashboard-loading-copy::before {
        animation: none;
        border-color: var(--accent);
        opacity: 0.5;
    }

    .group-container > .group-card,
    .course-container .course-card {
        animation: none !important;
    }
}
