@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

body {
    font-family: 'Nunito', 'Arial', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f0f4f8;
    color: #3d4451;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

:root {
    --color-primario: #5867dd;
    --color-secundario: #ffffff;
    --color-terciario: #79829c;
    --color-acento: #34d399;
    --color-oro: #ffc107;
    --color-free: #6b7280;
    --color-texto-header: #ffffff;
    --border-radius-main: 12px;
    --shadow-main: 0 8px 16px rgba(0,0,0,0.05);
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --duolingo-orange: #ff9600;
}

.profile-main { flex-grow: 1; padding-top: 1.5rem; }

.profile-wrapper { max-width: 900px; margin: 0 auto 2rem auto; padding: 0 1rem; display: flex; flex-direction: column; gap: 2rem; }

.profile-header-card { background: linear-gradient(135deg, var(--color-primario) 0%, #798eff 100%); color: white; border-radius: var(--border-radius-main); padding: 2.5rem 2rem; box-shadow: var(--shadow-main); display: flex; align-items: center; gap: 2rem; }
.profile-avatar-container { position: relative; cursor: pointer; }
.profile-avatar { width: 120px; height: 120px; border-radius: 50%; border: 5px solid var(--color-secundario); object-fit: cover; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.profile-avatar-container:hover::after { content: '✏️'; position: absolute; bottom: 5px; right: 5px; background-color: rgba(0,0,0,0.5); color: white; border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.profile-info-details .profile-username {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0 0 0.5rem 0;
    color: var(--color-secundario);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.membership-badge { font-size: 0.8rem; font-weight: 700; padding: 0.3em 0.8em; border-radius: 15px; vertical-align: middle; display: inline-block; }
.badge-pro { background-color: var(--color-oro); color: #42340a; }
.badge-trial { background-color: var(--color-acento); color: #064e3b; }
.badge-free { background-color: var(--color-free); color: white; }
.upgrade-pro-btn { background-color: var(--color-acento); color: white; text-decoration: none; font-size: 0.8rem; padding: 0.4em 1em; border-radius: 15px; margin-left: 0.5rem; transition: background-color 0.2s ease; font-weight: 700; }
.upgrade-pro-btn:hover { background-color: #2cb183; }

.profile-email { font-size: 1rem; color: #e0e7ff; margin: 0 0 0.5rem 0; }
.profile-joindate { font-size: 0.85rem; color: #c0caff; margin: 0; }

.profile-stats-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.5rem; }
.stat-card { background-color: var(--color-secundario); border-radius: var(--border-radius-main); padding: 1.8rem 1.5rem; box-shadow: var(--shadow-main); text-align: center; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.stat-card:hover { transform: translateY(-5px); box-shadow: 0 12px 20px rgba(0,0,0,0.07); }
#streak-stat-card, #books-stat-card { cursor: pointer; }
.stat-card h3 { font-size: 0.9rem; font-weight: 600; color: var(--color-terciario); margin-top: 0; margin-bottom: 0.6rem; text-transform: uppercase; letter-spacing: 0.8px; }
.stat-card .stat-value { font-size: 2.5rem; font-weight: 800; color: var(--color-primario); display: block; line-height: 1; }
.stat-card p { margin-top: 0.2rem; font-size: 1rem; color: var(--text-primary); }

.profile-level-container {
    background-color: var(--color-secundario);
    border-radius: var(--border-radius-main);
    padding: 2rem;
    box-shadow: var(--shadow-main);
}

.level-progress-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.level-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* --- INICIO: NUEVOS ESTILOS PARA EL TEXTO DEL NIVEL --- */
.level-info .current-level {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.level-number-span {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.level-title-span {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primario);
}
/* --- FIN: NUEVOS ESTILOS --- */


.level-info .next-level-goal {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-terciario);
}

.level-progress-bar-container {
    width: 100%;
    height: 16px;
    background-color: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.level-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-acento) 0%, var(--color-primario) 100%);
    border-radius: 8px;
    transition: width 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

.xp-progress-text {
    text-align: right;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.pro-stats-container { background-color: var(--color-secundario); border-radius: var(--border-radius-main); padding: 2rem; box-shadow: var(--shadow-main); }
.pro-stats-header { border-bottom: 1px solid #e2e8f0; padding-bottom: 1rem; margin-bottom: 1.5rem; }
.pro-stats-header h3 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.activity-heatmap-container h4 { font-size: 1.2rem; text-align: center; color: var(--text-secondary); margin-bottom: 1rem; }
.activity-heatmap { display: grid; grid-template-columns: repeat(53, 1fr); grid-auto-rows: 1fr; gap: 4px; }
.heatmap-day { width: 100%; padding-bottom: 100%; background-color: #ebedf0; border-radius: 2px; }
.heatmap-day[data-level='1'] { background-color: #c6e48b; }
.heatmap-day[data-level='2'] { background-color: #7bc96f; }
.heatmap-day[data-level='3'] { background-color: #239a3b; }
.heatmap-day[data-level='4'] { background-color: #196127; }
.heatmap-legend { display: flex; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 1rem; font-size: 0.8rem; color: var(--color-terciario); }
.legend-color { width: 15px; height: 15px; border-radius: 2px; }

.profile-achievements-container { background-color: var(--color-secundario); border-radius: var(--border-radius-main); padding: 2rem; box-shadow: var(--shadow-main); }
.achievements-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 1rem; }
.achievements-header h3 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.achievements-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1.5rem; text-align: center; }
.achievement-item { display: flex; flex-direction: column; align-items: center; padding: 1rem; background-color: #f8fafc; border-radius: 8px; border: 1px solid #eef2f7; transition: transform 0.2s ease; }
.achievement-item:hover{ transform: scale(1.05); }
.badge-icon { width: 70px; height: 70px; object-fit: contain; margin-bottom: 0.75rem;}
.achievement-item .badge-name { font-weight: 700; font-size: 0.9rem; color: var(--text-primary); line-height: 1.3; margin-top: 0.5rem; }
.achievement-item .badge-description { font-size: 0.8rem; color: var(--color-terciario); }
.profile-achievements-container .loading-text { color: var(--color-terciario); font-style: italic; text-align: center; padding: 1rem 0;}

.mastery-badge-icon { width: 70px; height: 70px; border-radius: 50%; margin-bottom: 0.75rem; display: flex; align-items: center; justify-content: center; color: white; font-size: 2.5rem; font-weight: 800; border: 4px solid; }
.mastery-level-bronce { background-color: #cd7f32; border-color: #a06428; }
.mastery-level-plata { background-color: #c0c0c0; border-color: #a0a0a0; }
.mastery-level-oro { background-color: #ffd700; border-color: #c8a900; }

.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); padding-top: 60px; }
.modal-content { background-color: var(--color-secundario); margin: 5% auto; padding: 25px; border: 1px solid #e2e8f0; border-radius: var(--border-radius-main); width: 80%; max-width: 600px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); position: relative; animation: slideDownModal 0.4s ease-out; }
@keyframes slideDownModal { from {top: -100px; opacity: 0;} to {top: 0; opacity: 1;} }
.close-modal-btn { color: var(--color-terciario); position: absolute; top: 15px; right: 25px; font-size: 28px; font-weight: bold; transition: color 0.2s ease; cursor: pointer; }
.close-modal-btn:hover, .close-modal-btn:focus { color: var(--text-primary); }
.modal-content h4 { margin-top: 0; margin-bottom: 1.5rem; font-size: 1.5rem; color: var(--color-primario); text-align: center; }
.avatars-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 1rem; max-height: 400px; overflow-y: auto; padding: 0.5rem; }
.avatar-option img { width: 70px; height: 70px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: border-color 0.2s ease, transform 0.2s ease; object-fit: cover; }
.avatar-option img:hover { border-color: var(--color-acento); transform: scale(1.1); }

.calendar { font-family: 'Nunito', sans-serif; max-width: 350px; margin: auto; }
.calendar-header { display: flex; justify-content: space-between; align-items: center; padding: 10px; text-transform: uppercase; font-weight: 800; color: var(--text-primary); }
.calendar-nav { cursor: pointer; background: transparent; border: none; font-size: 1.5rem; color: var(--color-terciario); }
.calendar-body { padding: 10px; }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--color-terciario); font-weight: 700; margin-bottom: 1rem; }
.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day { display: flex; align-items: center; justify-content: center; height: 36px; text-align: center; font-weight: 700; border-radius: 50%; color: var(--text-secondary); }
.calendar-day.other-month { visibility: hidden; }
.calendar-day.streak-day { background-color: var(--duolingo-orange); color: white; }
.calendar-day.today { border: 2px solid var(--duolingo-orange); }

.library-books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 1.5rem; max-height: 400px; overflow-y: auto; padding: 1rem; }
.library-book-item { text-align: center; }
.library-book-item img { width: 100px; height: 150px; object-fit: cover; border-radius: 8px; box-shadow: var(--shadow-main); }
.library-book-item p { margin-top: 0.5rem; font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

footer { text-align: center; padding: 2rem; font-size: 0.9rem; color: var(--color-terciario); margin-top: auto; }

@media (max-width: 768px) {
    .profile-header-card {
        flex-direction: column;
        text-align: center;
        padding: 2rem 1.5rem;
    }
    .profile-username-line {
        justify-content: center;
        flex-wrap: wrap;
    }
    .profile-stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    .stat-card {
        padding: 1.5rem 1rem;
    }
    .stat-card .stat-value {
        font-size: 2rem;
    }
}

