/* Base Reset & Variables */
:root {
    --bg-dark: #0f0f13;
    --panel-bg: rgba(25, 25, 30, 0.4);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent: #ffcc00;
    --accent-hover: #ffaa00;
    --blur-amount: 20px;
    --transition: 0.3s ease;

    /* Configurable variables from DB */
    --custom-bg-1: #1a1a2e;
    --custom-bg-2: #16213e;
    --custom-bg-img: url('');
    /* Default empty */
    --profile-bg-1: #111113;
    --profile-bg-2: #1e1e24;

    /* Layout */
    --profile-width: 600px;
    --right-panel-width: 650px;

    /* Dynamic Layout Config */
    --avatar-size: 150px;
    --avatar-pos-x: 40px;
    --avatar-pos-bottom: -50px;
    --bg-mask-stop: 30%;
    /* Default to 30% fade start */
    --bg-image-height: 50vh;
    /* Height of the background image regardless of fade */
    --bg-overlay-opacity: 0.5;
    /* Default overlay darkness */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-dark);
    line-height: 1.6;
    overflow: hidden;
    /* Eliminar scroll principal de la web */
    height: 100vh;
}

/* Background Gradient Layer */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: radial-gradient(circle at 50% 0%, var(--custom-bg-1) 0%, var(--custom-bg-2) 100%);
}

/* Background Image Layer (Customizable fade out & blur) */
.bg-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
}

.bg-image-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    /* Altura máxima del lienzo para que no corte abruptamente */
    background-image: var(--custom-bg-img);
    background-size: 100% var(--bg-image-height, 50vh);
    /* Estira o contrae solo hasta esta altura */
    background-repeat: no-repeat;
    background-position: center top;

    /* El degradado sólido negro hasta tu máscara, luego funde a transparente hasta donde acaba tu imagen */
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black var(--bg-mask-stop, 30%), transparent var(--bg-image-height, 50vh), transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, black var(--bg-mask-stop, 30%), transparent var(--bg-image-height, 50vh), transparent 100%);

    opacity: 0.9;
}

.bg-image-blur {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);

    /* Blur invertido: Nace transparente y empieza a aplicarse sólido desde el fin del fade */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, transparent var(--bg-mask-stop, 30%), black var(--bg-image-height, 50vh), black 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, transparent var(--bg-mask-stop, 30%), black var(--bg-image-height, 50vh), black 100%);
}

.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: black;
    opacity: var(--bg-overlay-opacity, 0.5);
    z-index: -1;
    pointer-events: none;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Layout Container */
.dashboard-container {
    display: flex;
    flex-direction: column;
    max-width: calc(var(--profile-width) + var(--right-panel-width) + 60px);
    margin: 80px auto 0 auto;
    /* Sin margen debajo para que pueda llegar al fondo absoluto */
    padding: 0 40px;
    gap: 50px;
    justify-content: center;
    min-height: calc(100vh - 80px);
    /* 80px del margin-top */
}

@media (min-width: 900px) {
    .dashboard-container {
        flex-direction: row;
        align-items: stretch;
        /* Permite que ambos paneles lleguen hasta abajo si es necesario, o que al menos el profile panel ocupe mas */
    }
}

/* --- Left Panel: Profile --- */
.profile-panel {
    width: 100%;
    max-width: var(--profile-width);
    background: linear-gradient(to bottom, var(--profile-bg-1), var(--profile-bg-2));
    border: 1px solid var(--panel-border);
    border-bottom: none;
    /* Quitamos borde inferior para que se fusione con el final de la pantalla */
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    flex-shrink: 0;

    display: flex;
    flex-direction: column;

    /* Forzamos a que siempre llegue hasta abajo del todo */
    min-height: calc(100vh - 80px);
    align-self: stretch;
}

.profile-banner-container {
    position: relative;
    width: 100%;
    /* Eliminar altura fija para que se adapte 100% a la imagen de forma natural */
}

.profile-banner {
    width: 100%;
    height: auto;
    display: block;
}

.profile-avatar-container {
    position: absolute;
    bottom: var(--avatar-pos-bottom, -50px);
    left: var(--avatar-pos-x, 40px);
    padding: 0;
    z-index: 10;
}

.profile-avatar {
    width: var(--avatar-size, 120px);
    height: var(--avatar-size, 120px);
    border-radius: 50%;
    object-fit: cover;
    border: 6px solid #111113;
    /* Match panel bg */
}

.profile-info {
    padding: 70px 40px 30px 40px;
    text-align: left;
    flex: 1;
    /* Coge todo el espacio restante despues del banner */
    overflow-y: auto;
    /* Scroll independiente si hay mucho contenido */

    /* Scrollbar minimalista para que quede estético */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.profile-name {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 8px;
    line-height: 1;
}

.profile-bio {
    font-size: 0.95rem;
    color: #e0e0e0;
    margin-bottom: 25px;
    /* Más espacio hasta los iconos o botones */
    display: inline-block;
    vertical-align: middle;
    /* Bio en la misma linea o debajo */
    margin-right: 15px;
}

.profile-social-icons {
    display: flex;
    justify-content: flex-start;
    /* Alineado a la izquierda */
    gap: 12px;
    margin-bottom: 25px;
}

.profile-social-icons img {
    width: 20px;
    height: 20px;
    cursor: pointer;
    transition: transform var(--transition);
    border-radius: 50%;
    /* Ensuring small icons look like badges */
}

.profile-social-icons img:hover {
    transform: scale(1.2);
}

.profile-badges {
    display: inline-flex;
    gap: 10px;
    vertical-align: middle;
    margin-bottom: 25px;
    /* Separacion de la bio con lo de abajo */
}

.badge {
    background: transparent;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.badge-arc {
    border-color: rgba(255, 204, 0, 0.5);
}

.badge-arc i {
    color: var(--accent);
}

/* --- About Me Section --- */
.profile-about {
    margin-top: 30px;
    text-align: left;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.about-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.about-title::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 4px;
    background: var(--accent);
    border-radius: 4px;
}

.about-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-line;
}

/* --- Right Panel: Content --- */
.content-panel {
    width: 100%;
    max-width: var(--right-panel-width);
    flex-shrink: 0;

    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    /* Height equal to the left panel margin layout */
    padding-bottom: 20px;
}

.content-tabs {
    display: flex;
    gap: 25px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0;
    flex-shrink: 0;
    /* Ensures tabs never shrink when scrolling */
}

/* Sections Container allows independent scrolling of content */
.sections-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-right: 10px;
    /* Evitar que la scrollbar pise divs internos */

    /* Scrollbar minimalista */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition);
    position: relative;
    padding: 0 0 15px 0;
}

.tab-btn:hover {
    color: #e0e0e0;
}

.tab-btn.active {
    color: var(--text-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--text-primary);
    border-radius: 3px 3px 0 0;
}

.content-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
    /* Evitar que se pierda el glassmorphism durante la animación */
    will-change: transform, opacity;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.section-header h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-secondary);
    display: none;
    /* Hide if not needed, relying on tabs */
}

/* --- List Styling (Novedades & Creditos) --- */
.novedades-list,
.creditos-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.list-item {
    display: flex;
    align-items: flex-start;
    /* Superior en vez de centrado para textos largos */
    gap: 15px;
    padding: 15px;
    background: rgba(25, 25, 30, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    transition: background var(--transition);
    cursor: pointer;
    overflow: hidden;

    /* Forza el motor de render a mantener el filtro de fondo activado */
    transform: translateZ(0);
    backface-visibility: hidden;
}

.list-item:hover {
    background: rgba(25, 25, 30, 0.9);
}

.item-icon {
    width: 70px;
    height: 100px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.item-content {
    flex-grow: 1;
    min-width: 0;
    /* Crucial for word-wrap inside flexbox */
}

.item-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.item-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.creditos-list .list-item {
    cursor: pointer;
}

.creditos-list .item-icon {
    border-radius: 50%;
    width: 60px;
    height: 60px;
}


/* --- Anotaciones Grid --- */
.anotaciones-grid {
    display: flex;
    flex-direction: column;
    /* Cambiado a una sola columna */
    gap: 15px;
}

.anotacion-card {
    background: rgba(25, 25, 30, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
    position: relative;
    transition: background var(--transition);
}

.anotacion-card:hover {
    background: rgba(25, 25, 30, 0.7);
}

.anotacion-text {
    font-size: 1rem;
    font-style: italic;
    color: var(--text-primary);
    margin-bottom: 15px;
    word-wrap: break-word;
    /* Soluciona desborde en textos largos */
    overflow-wrap: break-word;
    white-space: pre-line;
    /* Mantener saltos de linea originales */
}

.anotacion-author-area {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
}

.author-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.author-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}


/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    transform: translateY(20px) scale(0.95);
    transition: transform var(--transition);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background var(--transition);
}

.modal-close:hover {
    background: rgba(255, 0, 0, 0.6);
}

.modal-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 20px 20px 0 0;
}

.modal-body {
    padding: 25px;
}

.modal-title {
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: var(--accent);
}

.modal-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.modal-desc a {
    color: var(--accent);
    text-decoration: none;
}

.modal-desc a:hover {
    text-decoration: underline;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}