/* ========================================
   🏋️ ROUTINE CARDS v4.0
   Tarjetas de rutina clickeables y animadas
   ======================================== */

/* ========================================
   1. ESTILOS BASE DE TARJETAS DE RUTINA
   ======================================== */

.routine-card {
    cursor: pointer;
    transition: all var(--transition-base, 250ms);
    position: relative;
    overflow: hidden;
}

/* Estado hover */
.routine-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl, 0 16px 32px rgba(0, 0, 0, 0.6));
    border-color: var(--accent-primary, #00d4ff);
}

/* Estado active (al hacer clic) */
.routine-card:active {
    transform: translateY(-1px);
    transition: all 100ms;
}

/* ========================================
   2. EFECTOS VISUALES
   ======================================== */

/* Efecto de brillo sutil al hover */
.routine-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.05) 0%, transparent 100%);
    opacity: 0;
    transition: opacity var(--transition-base, 250ms);
    pointer-events: none;
    border-radius: inherit;
    z-index: 0;
}

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

/* Asegurar que el contenido esté por encima del overlay */
.routine-card > * {
    position: relative;
    z-index: 1;
}

/* ========================================
   3. ANIMACIONES DE ENTRADA
   ======================================== */

/* Animación escalonada para múltiples tarjetas */
.routine-card:nth-child(1) {
    animation: fadeInUp 0.5s ease-out 0.1s backwards;
}

.routine-card:nth-child(2) {
    animation: fadeInUp 0.5s ease-out 0.2s backwards;
}

.routine-card:nth-child(3) {
    animation: fadeInUp 0.5s ease-out 0.3s backwards;
}

.routine-card:nth-child(4) {
    animation: fadeInUp 0.5s ease-out 0.4s backwards;
}

.routine-card:nth-child(5) {
    animation: fadeInUp 0.5s ease-out 0.5s backwards;
}

.routine-card:nth-child(6) {
    animation: fadeInUp 0.5s ease-out 0.6s backwards;
}

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

/* ========================================
   4. INDICADORES VISUALES DE CLICKEABLE
   ======================================== */

/* Subrayado animado en el título */
.routine-card .card-title {
    position: relative;
    display: inline-block;
    transition: color var(--transition-fast, 150ms);
}

.routine-card:hover .card-title {
    color: var(--accent-primary, #00d4ff);
}

.routine-card:hover .card-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-primary, #00d4ff);
    animation: underlineExpand 0.3s ease-out;
}

@keyframes underlineExpand {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

/* Icono de "ver más" que aparece al hover */
.routine-card::after {
    content: '\f35d'; /* Font Awesome arrow-circle-right */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: var(--accent-primary, #00d4ff);
    opacity: 0;
    transform: translateX(10px);
    transition: all var(--transition-base, 250ms);
    z-index: 2;
}

.routine-card:hover::after {
    opacity: 0.5;
    transform: translateX(0);
}

/* ========================================
   5. BADGES DENTRO DE TARJETAS
   ======================================== */

.routine-card .badge {
    transition: all var(--transition-fast, 150ms);
}

.routine-card:hover .badge {
    transform: scale(1.05);
}

/* ========================================
   6. PROGRESS BAR EN TARJETAS
   ======================================== */

.routine-card .progress-bar {
    transition: all var(--transition-base, 250ms);
}

.routine-card:hover .progress-bar {
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.routine-card .progress-fill {
    transition: width var(--transition-slow, 350ms);
}

/* ========================================
   7. VARIANTES DE TARJETAS DE RUTINA
   ======================================== */

/* Tarjeta activa/hoy */
.routine-card.card-success:hover {
    border-color: var(--accent-success, #00ff88);
}

.routine-card.card-success::before {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.05) 0%, transparent 100%);
}

.routine-card.card-success:hover .card-title {
    color: var(--accent-success, #00ff88);
}

.routine-card.card-success:hover .card-title::after {
    background: var(--accent-success, #00ff88);
}

/* Tarjeta con acento azul */
.routine-card.card-accent:hover {
    box-shadow: 0 8px 24px rgba(0, 212, 255, 0.3);
}

/* ========================================
   8. ESTADOS ESPECIALES
   ======================================== */

/* Tarjeta deshabilitada */
.routine-card.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.routine-card.disabled:hover {
    transform: none;
    border-color: var(--border-primary, #333333);
}

.routine-card.disabled::before,
.routine-card.disabled::after {
    display: none;
}

/* Tarjeta en loading */
.routine-card.loading {
    pointer-events: none;
    position: relative;
}

.routine-card.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background-primary, #0a0a0a);
    opacity: 0.8;
    z-index: 10;
}

.routine-card.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--surface-hover, #333333);
    border-top-color: var(--accent-primary, #00d4ff);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 11;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   9. RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    /* En móvil, reducir el transform para no causar overflow */
    .routine-card:hover {
        transform: translateY(-2px);
    }
    
    /* Remover el icono de "ver más" en móvil */
    .routine-card::after {
        display: none;
    }
    
    /* Hacer el título más visible sin hover en móvil */
    .routine-card .card-title {
        color: var(--text-primary, #ffffff);
    }
}

/* ========================================
   10. ACCESIBILIDAD
   ======================================== */

/* Focus visible para navegación por teclado */
.routine-card:focus {
    outline: 2px solid var(--accent-primary, #00d4ff);
    outline-offset: 2px;
}

.routine-card:focus-visible {
    outline: 2px solid var(--accent-primary, #00d4ff);
    outline-offset: 2px;
}

/* Reducir movimiento para usuarios con preferencias de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .routine-card,
    .routine-card::before,
    .routine-card::after,
    .routine-card .card-title::after {
        animation: none !important;
        transition: none !important;
    }
    
    .routine-card:hover {
        transform: none;
    }
}

/* ========================================
   11. EFECTOS ADICIONALES (OPCIONALES)
   ======================================== */

/* Efecto de pulso en tarjetas nuevas */
.routine-card.new {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(0, 212, 255, 0);
    }
}

/* Efecto de shake para llamar la atención */
.routine-card.attention {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* ========================================
   12. GRID DE RUTINAS
   ======================================== */

/* Grid específico para tarjetas de rutina */
.routines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg, 1.5rem);
    margin-top: var(--spacing-xl, 2rem);
}

@media (max-width: 768px) {
    .routines-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md, 1rem);
    }
}

/* ========================================
   13. SKELETON LOADER PARA RUTINAS
   ======================================== */

.routine-card-skeleton {
    background: var(--surface-primary, #1e1e1e);
    border: 1px solid var(--border-primary, #333333);
    border-radius: var(--radius-lg, 0.75rem);
    padding: var(--spacing-lg, 1.5rem);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.routine-card-skeleton .skeleton-line {
    height: 1rem;
    background: linear-gradient(
        90deg,
        var(--surface-secondary, #2a2a2a) 0%,
        var(--surface-hover, #333333) 50%,
        var(--surface-secondary, #2a2a2a) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm, 0.375rem);
    margin-bottom: var(--spacing-sm, 0.5rem);
}

.routine-card-skeleton .skeleton-line:last-child {
    margin-bottom: 0;
    width: 60%;
}

@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}
