/* ==========================================================================
   DISEÑO GENERAL Y VARIABLES DE TEMA
   ========================================================================== */

:root {
    /* Tema Oscuro (Por defecto) */
    --bg-primary: #0b0f19;
    --bg-secondary: #131b2e;
    --bg-glass: rgba(19, 27, 46, 0.7);
    --bg-glass-hover: rgba(28, 38, 64, 0.85);
    --border-glass: rgba(255, 255, 255, 0.06);
    --border-glass-focus: rgba(168, 85, 247, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #a855f7 0%, #06b6d4 100%);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --hover-shadow: 0 12px 30px rgba(168, 85, 247, 0.15);
    
    --glow-1: rgba(168, 85, 247, 0.12);
    --glow-2: rgba(6, 182, 212, 0.12);
    --glow-3: rgba(139, 92, 246, 0.1);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --transition-speed: 0.3s;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

body.light-theme {
    /* Tema Claro */
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.75);
    --bg-glass-hover: rgba(255, 255, 255, 0.9);
    --border-glass: rgba(15, 23, 42, 0.08);
    --border-glass-focus: rgba(147, 51, 234, 0.4);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-purple: #9333ea;
    --accent-cyan: #0891b2;
    --accent-gradient: linear-gradient(135deg, #9333ea 0%, #0891b2 100%);
    --card-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    --hover-shadow: 0 12px 30px rgba(147, 51, 234, 0.1);
    
    --glow-1: rgba(168, 85, 247, 0.04);
    --glow-2: rgba(6, 182, 212, 0.04);
    --glow-3: rgba(139, 92, 246, 0.03);
}

/* Reset de estilos */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* ==========================================================================
   ORBES DE BRILLO DE FONDO (Glow Effect)
   ========================================================================== */

.bg-glow-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(130px);
    opacity: 0.8;
    transition: all 1s ease;
    animation: pulseOrbs 12s infinite alternate ease-in-out;
}

.orb-1 {
    top: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background-color: var(--glow-1);
}

.orb-2 {
    bottom: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background-color: var(--glow-2);
    animation-delay: -3s;
}

.orb-3 {
    top: 40%;
    left: 45%;
    width: 350px;
    height: 350px;
    background-color: var(--glow-3);
    animation-delay: -6s;
}

@keyframes pulseOrbs {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(5%, 5%) scale(1.1);
    }
    100% {
        transform: translate(-3%, -2%) scale(0.95);
    }
}

/* ==========================================================================
   CONTENEDOR Y MAQUETACIÓN
   ========================================================================== */

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   ENCABEZADO (Header)
   ========================================================================== */

.main-header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.logo-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

.logo-icon i {
    width: 28px;
    height: 28px;
}

.logo-area h1 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-area .subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 0.1rem;
}

/* Botón Tema */
.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-speed) ease;
}

body.light-theme .btn-icon {
    background: rgba(0, 0, 0, 0.03);
}

.btn-icon:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

body.light-theme .btn-icon:hover {
    background: rgba(0, 0, 0, 0.06);
}

.btn-icon i {
    width: 20px;
    height: 20px;
    transition: transform 0.5s ease;
}

/* Ocultar iconos de tema dinámicamente */
body.dark-theme .sun-icon { display: block; }
body.dark-theme .moon-icon { display: none; }
body.light-theme .sun-icon { display: none; }
body.light-theme .moon-icon { display: block; }

/* Panel de estadísticas */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    border-top: 1px solid var(--border-glass);
    padding-top: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

body.light-theme .stat-card {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.02);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent-purple);
    display: flex;
    justify-content: center;
    align-items: center;
}

.stat-icon.text-cyan {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent-cyan);
}

.stat-icon.text-purple {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.stat-icon i {
    width: 20px;
    height: 20px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==========================================================================
   SECCIÓN DE CONTROLES (Búsqueda y Filtros)
   ========================================================================== */

.controls-section {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Barra de Búsqueda */
.search-bar-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-speed) ease;
    width: 20px;
    height: 20px;
}

#search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
    transition: all var(--transition-speed) ease;
}

body.light-theme #search-input {
    background: rgba(255, 255, 255, 0.8);
}

#search-input:focus {
    border-color: var(--border-glass-focus);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.15);
}

body.light-theme #search-input:focus {
    background: #ffffff;
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.1);
}

#search-input:focus + .search-icon {
    color: var(--accent-purple);
}

.btn-clear {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: none; /* Se mostrará con Javascript cuando haya texto */
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed) ease;
}

.btn-clear:hover {
    color: var(--text-primary);
}

.btn-clear i {
    width: 18px;
    height: 18px;
}

/* Filtros por Categoría */
.filter-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-categories {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-speed) ease;
}

body.light-theme .pill {
    background: rgba(0, 0, 0, 0.02);
}

.pill:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    transform: translateY(-1px);
}

body.light-theme .pill:hover {
    background: rgba(0, 0, 0, 0.05);
}

.pill.active {
    background: var(--accent-gradient);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.pill-count {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 700;
}

.pill.active .pill-count {
    background: rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   SECCIÓN DE CONTENIDO (Ejercicios)
   ========================================================================== */

.main-content {
    min-height: 300px;
}

/* Loader */
.loader-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 4rem 0;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-glass);
    border-top: 4px solid var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Grid de Categorías */
.exercises-grid {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* Categoría (Bloque Temático) */
.category-block {
    animation: fadeInUp 0.5s ease forwards;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-glass);
}

.category-title-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-icon {
    color: var(--accent-purple);
    display: flex;
    align-items: center;
}

.category-icon i {
    width: 24px;
    height: 24px;
}

.category-title-area h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.category-meta-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
}

body.light-theme .category-meta-count {
    background: rgba(0, 0, 0, 0.03);
}

/* Contenedor de subcarpetas */
.subfolders-container {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.subfolder-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.subfolder-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
    border-left: 2px solid var(--accent-cyan);
    margin-bottom: 0.25rem;
}

.subfolder-arrow-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    opacity: 0.7;
}

.subfolder-icon {
    display: flex;
    align-items: center;
    color: var(--accent-cyan);
}

.subfolder-icon i {
    width: 18px;
    height: 18px;
}

.subfolder-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-heading);
    letter-spacing: -0.2px;
}

/* Grid de tarjetas dentro de una categoría */
.cards-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* Tarjeta de Ejercicio */
.exercise-card {
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 150px;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.exercise-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-gradient);
    opacity: 0.6;
    transition: opacity var(--transition-speed) ease;
}

.exercise-card:hover {
    transform: translateY(-4px);
    background: var(--bg-glass-hover);
    border-color: rgba(168, 85, 247, 0.25);
    box-shadow: var(--hover-shadow);
}

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

.card-top {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.exercise-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    transition: color var(--transition-speed) ease;
}

.exercise-card:hover .exercise-title {
    color: #ffffff;
}

body.light-theme .exercise-card:hover .exercise-title {
    color: var(--accent-purple);
}

.exercise-filename {
    font-size: 0.8rem;
    font-family: monospace;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.exercise-filename i {
    width: 12px;
    height: 12px;
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

body.light-theme .card-bottom {
    border-top-color: rgba(0, 0, 0, 0.02);
}

.exercise-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.meta-item i {
    width: 12px;
    height: 12px;
}

.open-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    transition: all var(--transition-speed) ease;
}

body.light-theme .open-badge {
    background: rgba(0, 0, 0, 0.03);
}

.exercise-card:hover .open-badge {
    background: var(--accent-gradient);
    color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3);
}

/* ==========================================================================
   SIN RESULTADOS (Empty Search)
   ========================================================================== */

.no-results-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1.5rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    text-align: center;
    max-width: 500px;
    margin: 2rem auto 0;
    animation: fadeInUp 0.4s ease forwards;
}

.no-results-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.no-results-container h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.no-results-container p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: #ffffff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
    transition: all var(--transition-speed) ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(168, 85, 247, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ==========================================================================
   PIE DE PÁGINA (Footer)
   ========================================================================== */

.main-footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-top: 1px solid var(--border-glass);
    margin-top: 2rem;
}

.footer-note {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.footer-note code {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--accent-cyan);
}

body.light-theme .footer-note code {
    background: rgba(0, 0, 0, 0.03);
}

/* ==========================================================================
   ANIMACIONES Y RESPONSIVE
   ========================================================================== */

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

/* Ajustes Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
        gap: 1.5rem;
    }
    
    .main-header {
        padding: 1.5rem;
        gap: 1.5rem;
    }
    
    .logo-area {
        gap: 1rem;
    }
    
    .logo-icon {
        width: 48px;
        height: 48px;
    }
    
    .logo-icon i {
        width: 24px;
        height: 24px;
    }
    
    .logo-area h1 {
        font-size: 1.5rem;
    }
    
    .stats-panel {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .filter-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .filter-categories {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        flex-wrap: nowrap;
        scrollbar-width: none; /* Firefox */
    }
    
    .filter-categories::-webkit-scrollbar {
        display: none; /* Safari and Chrome */
    }
    
    .pill {
        flex-shrink: 0;
    }
    
    .cards-layout {
        grid-template-columns: 1fr;
    }
}
