/* ============================================================
   PROFILE PAGE – COMPATIBILIDADE E ISOLAMENTO DE CAMADAS
   ============================================================ */

/* ---------- Reset de Conflito com o CSS Principal Base ---------- */

/* Ajusta o comportamento do 'main' global apenas quando for a página de perfil */
main:has(.profile-content),
main.profile-page {
    max-width: 1200px !important;
    margin: 2rem auto !important;
    padding: 0 1rem !important;
    display: block !important; /* Desativa o flex-direction: column do main principal */
}

/* Garante que o menu superior fique sempre à frente de qualquer sobreposição do perfil */
header, 
.header-global,
#header { 
    position: relative !important;
    z-index: 100 !important; /* Valor bem alto para vencer os z-index: 20 do conteúdo */
    pointer-events: auto !important;
}

.profile-page {
    color: #ffffff;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    letter-spacing: -0.1px;
    background: #121212;
}

/* O Conteúdo do perfil sobe fisicamente sobre a base esmaecida do jogo */
.profile-content {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 3rem;
    margin-top: -5rem;   /* Puxa o layout para cima sobre o banner */
    position: relative;
    z-index: 20;         /* Camada alta para ficar totalmente à frente do Vortex */
    pointer-events: none; 
}

.profile-sidebar, 
.stat-card, 
.genre-chart, 
.badge-card, 
.activity-item,
.genre-tag {
    pointer-events: auto;
}

/* ---------- Banner Vortex Cinemático (Camada de Fundo) ---------- */
.vortex-hero-banner {
    position: relative;
    width: 100%;
    height: 45vh;         /* Altura ideal para o jogo respirar em telas grandes */
    min-height: 340px;
    margin: 0;
    background: #121212;  
    overflow: hidden;
    z-index: 1;           
    isolation: isolate;   /* Cria um ecossistema fechado de camadas para evitar conflito de z-index */
}

/* A MÁSCARA: Faz o topo e a base do Vortex entrarem "atrás" do layout escuro */
.vortex-hero-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Gradiente duplo: suaviza o topo com o header e funde a base com o corpo da página */
    background: linear-gradient(to bottom, #121212 0%, transparent 15%, transparent 80%, #121212 100%),
                radial-gradient(circle at center, transparent 40%, #121212 98%);
    pointer-events: none;
    z-index: 3;          /* Fica ACIMA do canvas do jogo (z-index 2), aplicando o efeito de fumo */
}

/* O CONTAINER DO JOGO: Controla o enquadramento e empurra o jogo para baixo */
.vortex-hero-banner .vortex-canvas-container {
    width: 100% !important;
    height: 220% !important;  /* Aumentado para 200% para renderizar o dobro da altura */
    position: absolute;
    top: -70%;                /* Puxa o container bem para cima, focando na metade superior do jogo */
    left: 0;
    opacity: 0.9;
    transition: opacity 0.5s ease;
    pointer-events: auto;
    z-index: 2;               /* Fica rigidamente atrás da máscara (z-index 3) */
    background: #121212;  
    overflow: hidden;
    will-change: transform;
}

/* O Canvas preenche o container perfeitamente sem transformações conflitantes */
.vortex-hero-banner .vortex-canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; 
    transform: none !important;
    position: relative !important;
    z-index: 1 !important;
}

/* ---------- Carrossel 3D (canvas) ---------- */
.css-carousel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    cursor: grab;
}

.css-carousel:active {
    cursor: grabbing;
}

.css-carousel canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Overlay de carregamento do carrossel 3D */
.carousel-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(18, 18, 18, 0.8);
    z-index: 2;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
    letter-spacing: 1px;
    gap: 1rem;
}

/* Overlay do botão no canto inferior direito */
.vortex-carousel-placeholder {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    z-index: 5;
    pointer-events: auto;
}

.vortex-carousel-placeholder .carousel-content {
    /* container mínimo, sem fundo */
}

.vortex-trigger-btn {
    padding: 0.6rem 1.8rem;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.vortex-trigger-btn:hover {
    background: #c23350;
    transform: scale(1.05);
}

/* ---------- Título do banner ---------- */
.vortex-hero-title {
    position: absolute;
    bottom: 6rem;        
    left: max(1rem, calc((100vw - 1200px) / 2 + 1rem));
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.4);
    z-index: 10;
    pointer-events: none;
}

/* Estado de carregamento (spinner) */
.vortex-hero-banner .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
    letter-spacing: 1px;
    gap: 1rem;
}

/* ---------- Sidebar & Identidade ---------- */
.profile-sidebar {
    text-align: left;
}

.profile-sidebar h1 {
    margin: 1.2rem 0 0.2rem !important;
    font-size: 1.6rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.5px !important;
    color: #ffffff !important;
}

.profile-sidebar p {
    color: #72727a;
    font-size: 0.85rem;
    margin: 0;
}

.favorite-genres {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.35rem;
    margin-top: 1rem;
}

.genre-tag {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #a1a1aa;
    transition: all 0.2s ease;
}

.genre-tag:hover {
    background: #ffffff;
    border-color: #ffffff;
    color: #121212;
}

/* ---------- Avatar Holográfico ---------- */
.holographic-avatar {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.03) 100%);
    margin: 0 auto;
    position: relative;
    padding: 3px;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.15), inset 0 0 10px rgba(0, 210, 255, 0.05);
}

.holographic-avatar img,
.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #121212;
    border: 2px solid #121212;
}

.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.3);
}

/* ---------- Partilha de Perfil ---------- */
.profile-share {
    margin: 1rem 0 0.5rem;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    align-items: center;
    position: relative;
}

.profile-share input {
    background: #121214;
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #a1a1aa;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    width: 220px;
}

.profile-share button {
    background: #ffffff;
    color: #121212;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: background 0.2s;
    position: relative;
}

.profile-share button:hover {
    background: #e4e4e7;
}

/* Tooltip de "Copiado!" */
.profile-share button.copied::after {
    content: "Copiado!";
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #27272a;
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* ---------- Painel de Estatísticas ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: #121214;
    border-radius: 8px;
    padding: 1.5rem 1.2rem;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.stat-card h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: #72727a;
    margin: 0 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-card strong {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffffff;
}

/* Gráfico de Géneros */
.genre-chart {
    margin-top: 1.5rem;
    background: #121214;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.genre-chart h4 {
    margin: 0 0 1.2rem;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
}

.genre-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.genre-label {
    width: 90px;
    font-size: 0.8rem;
    color: #a1a1aa;
}

.bar-track {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.bar-fill {
    height: 100%;
    background: #ffffff;
    border-radius: 2px;
}

.genre-count {
    width: 25px;
    font-size: 0.75rem;
    color: #72727a;
    text-align: right;
}

/* ---------- Medalhas (Badges) ---------- */
.badges-section h2,
.activity-feed h2 {
    margin: 2.5rem 0 1.2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.1px;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
}

.badge-card {
    background: #121214;
    border-radius: 8px;
    padding: 1.2rem 0.8rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: all 0.2s ease;
}

.badge-card:hover {
    border-color: rgba(255, 195, 40, 0.3);
    transform: translateY(-2px);
}

.badge-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.6rem;
    width: 28px;
    height: 28px;
    color: #ffc328;
}

.badge-card strong {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
    color: #fff;
}

.badge-card small {
    color: #72727a;
    font-size: 0.7rem;
}

.badge-card time {
    display: block;
    font-size: 0.65rem;
    color: #3f3f46;
    margin-top: 0.4rem;
}

/* ---------- Feed de Atividade Recente ---------- */
.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.activity-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: #a1a1aa;
    flex-shrink: 0;
}

.activity-item p {
    margin: 0;
    font-size: 0.85rem;
    color: #d4d4d8;
}

.activity-item time {
    font-size: 0.75rem;
    color: #52525b;
    margin-left: auto;
}

/* ---------- Regras Globais de Segurança do Canvas ---------- */
body > canvas {
    position: absolute !important;
    top: 0;
    left: 0;
    opacity: 0;
    pointer-events: none;
    z-index: -9999;
}

.vortex-canvas-container > canvas {
    position: relative !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 1 !important;
}

/* ---------- Spinner de Carregamento ---------- */
.spinner {
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

.spinner .path {
    stroke: rgba(255, 255, 255, 0.4);
    stroke-linecap: round;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* ---------- Responsividade (Mobile) ---------- */
@media (max-width: 768px) {
    /* 1. QUEBRA O ISOLAMENTO DO BANNER NO MOBILE */
    .vortex-hero-banner {
        height: 240px !important; 
        position: relative !important;
        z-index: 1 !important; 
        isolation: auto !important;
    }

    /* 2. FORÇA O CONTAINER DO SITE INTEIRO A FICAR NA FRENTE DO CORPO DO BANNER */
    main:has(.profile-content),
    main.profile-page {
        padding: 0 1rem !important;
        margin: 0 auto !important;
        position: relative !important;
        z-index: 10 !important; 
    }

    .vortex-hero-banner .vortex-canvas-container {
        height: 180% !important; 
        top: -25%; 
        z-index: 2 !important;
        background: #121212 !important;
        overflow: hidden !important;
        will-change: transform !important;
        opacity: 0.9;
    }

    .vortex-hero-banner::after {
        background: linear-gradient(to bottom, #121212 0%, transparent 12%, transparent 85%, #121212 100%);
        z-index: 3 !important;
    }

    /* 3. AJUSTE DO CONTEÚDO PARA SUBIR COM SEGURANÇA SOBRE O BANNER */
    .profile-content {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 2rem;
        margin-top: -4rem;
        text-align: center;
        position: relative !important;
        z-index: 20 !important;
    }

    .profile-sidebar {
        text-align: center;
    }

    .profile-share {
        justify-content: center;
        display: none;
    }

    .favorite-genres {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        text-align: center;
    }
    
    .vortex-hero-banner .vortex-canvas-container canvas {
        object-fit: cover !important; 
    }

    .vortex-hero-title {
        display: none;      
    }

    /* --- Carrossel 3D no mobile (idêntico ao Vortex) --- */
    .css-carousel {
        height: 100% !important;
		top: -15%;
        z-index: 2 !important;
        background: #121212 !important;
        overflow: hidden !important;
        will-change: transform !important;
        opacity: 0.9;
    }

    .css-carousel canvas {
        object-fit: cover !important;
        width: 100% !important;
        height: 100% !important;
    }

    /* Botão no mobile permanece no canto inferior direito */
    .vortex-carousel-placeholder {
        bottom: 1rem;
        right: 1rem;
    }

    .vortex-trigger-btn {
        padding: 0.5rem 1.4rem;
        font-size: 0.8rem;
    }

    /* Overlay de carregamento no mobile */
    .carousel-loading-overlay {
        font-size: 0.75rem;
        gap: 0.5rem;
    }
}

/* Limpeza de classes legadas obsoletas */
.profile-vortex, .vortex-track, .vortex-item, .vortex-item-info {
    display: none;
}