/* ═══════════════════════════════════════════════════════════════════════
   MEJORAS MASIVAS UI/UX - TEAMFIX v2.0
   Animaciones, accesibilidad, consistencia visual y experiencia premium
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 1. AVATAR EDITABLE CON UPLOAD ───────────────────────────────────── */
.profile-avatar-upload {
    position: relative;
    cursor: pointer;
}

.profile-avatar-circle {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.profile-avatar-circle:hover {
    transform: scale(1.05);
}

.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 50%;
    pointer-events: none;
}

.profile-avatar-upload:hover .avatar-overlay {
    opacity: 1;
}

.avatar-overlay svg {
    color: white;
    width: 24px;
    height: 24px;
}

.avatar-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.avatar-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Badge de verificación en avatar */
.avatar-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 24px;
    height: 24px;
    background: var(--success);
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ── 2. ANIMACIONES MEJORADAS ────────────────────────────────────────── */

/* Fade in suave para todos los elementos principales */
.fade-in-smooth {
    animation: fadeInSmooth 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* Stagger animation para listas */
.stagger-item {
    opacity: 0;
    animation: staggerFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }
.stagger-item:nth-child(7) { animation-delay: 0.35s; }
.stagger-item:nth-child(8) { animation-delay: 0.4s; }
.stagger-item:nth-child(9) { animation-delay: 0.45s; }
.stagger-item:nth-child(10) { animation-delay: 0.5s; }

/* Hover effects mejorados para cards */
.card-premium {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: left 0.5s;
}

.card-premium:hover::before {
    left: 100%;
}

.card-premium:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

/* Botones con ripple effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ── 3. TEXTOS AJUSTADOS Y RESPONSIVE ────────────────────────────────── */

/* Prevenir desbordamiento de texto */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Ajuste automático de texto en cards */
.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 0.5rem 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.card-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--muted);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ── 4. NOTIFICACIONES MEJORADAS ─────────────────────────────────────── */

.notif-panel {
    animation: slideDownFade 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

@keyframes slideDownFade {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notif-item {
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.2s ease;
}

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

.notif-item:hover {
    background: var(--surface-soft);
    transform: translateX(4px);
}

.notif-item.unread {
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
}

/* Badge de notificaciones animado */
.notif-badge {
    animation: badgeBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badgeBounce {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Toast notifications mejoradas */
.notif-toast {
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* ── 5. CONSISTENCIA DE TEMAS ────────────────────────────────────────── */

/* Asegurar que todos los elementos respeten los temas */
[data-theme="dark"] .profile-header,
[data-theme="dark"] .grade-average-card,
[data-theme="dark"] .grade-distribution,
[data-theme="dark"] .grades-table-container,
[data-theme="dark"] .progress-timeline,
[data-theme="dark"] .team-info {
    background: var(--surface);
    color: var(--text);
}

[data-theme="dark"] .stat-card,
[data-theme="dark"] .member-item,
[data-theme="dark"] .teacher-info {
    background: var(--surface-soft);
    color: var(--text);
}

[data-theme="dark"] .grades-table th {
    background: var(--surface-muted);
    color: var(--text);
}

[data-theme="dark"] .grades-table td {
    border-color: var(--border);
}

/* Transiciones suaves entre temas */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ── 6. SCROLLBAR PERSONALIZADA ──────────────────────────────────────── */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--surface-soft);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    border: 2px solid var(--surface-soft);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
}

/* ── 7. ACCESIBILIDAD MEJORADA ───────────────────────────────────────── */

/* Focus visible mejorado */
*:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Skip link mejorado */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 9999;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* ── 8. LOADING STATES ───────────────────────────────────────────────── */

.skeleton-loader {
    background: linear-gradient(
        90deg,
        var(--skeleton-base) 25%,
        rgba(255, 255, 255, 0.3) 50%,
        var(--skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

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

/* ── 9. MICRO-INTERACCIONES ──────────────────────────────────────────── */

/* Checkmarks animados */
.checkbox-animated {
    position: relative;
    cursor: pointer;
}

.checkbox-animated input[type="checkbox"] {
    opacity: 0;
    position: absolute;
}

.checkbox-animated .checkmark {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-strong);
    border-radius: 4px;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-animated input[type="checkbox"]:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-animated input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    animation: checkmark 0.3s ease;
}

@keyframes checkmark {
    0% {
        height: 0;
    }
    100% {
        height: 10px;
    }
}

/* ── 10. RESPONSIVE MEJORADO ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .profile-avatar-circle {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .profile-info h1 {
        font-size: 1.4rem;
    }
    
    .profile-stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .grades-overview {
        grid-template-columns: 1fr;
    }
    
    .profile-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .profile-tab {
        white-space: nowrap;
        padding: 10px 16px;
    }
}

/* ── 11. GRADIENTES Y EFECTOS PREMIUM ────────────────────────────────── */

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-border {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
}

.gradient-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-lg);
    z-index: -1;
}

/* Glassmorphism effect */
.glass-effect {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .glass-effect {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── 12. TABLAS MEJORADAS ────────────────────────────────────────────── */

.grades-table {
    border-collapse: separate;
    border-spacing: 0;
}

.grades-table tbody tr {
    transition: all 0.2s ease;
}

.grades-table tbody tr:hover {
    background: var(--primary-soft);
    transform: scale(1.01);
}

.grades-table td {
    vertical-align: middle;
}

/* ── 13. BADGES Y CHIPS MEJORADOS ────────────────────────────────────── */

.badge-premium {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

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

/* ── 14. PROGRESS BARS ANIMADAS ──────────────────────────────────────── */

.progress-bar-animated {
    position: relative;
    overflow: hidden;
}

.progress-bar-animated::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ── 15. TOOLTIPS MEJORADOS ──────────────────────────────────────────── */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: var(--text);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
}

[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    border: 5px solid transparent;
    border-top-color: var(--text);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-12px);
}
