/* ============================================================
   TELA DE SELEÇÃO E CRIAÇÃO DE PERFIL
   ============================================================ */
#profileSelectScreen, #profileCreateScreen {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: profileFadeIn 0.4s ease;
}

@keyframes profileFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Fundo dinâmico */
.profile-bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    will-change: opacity;
    pointer-events: none;
}

.profile-create-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(229,9,20,0.1) 0%, transparent 70%);
    z-index: 1;
    pointer-events: none;
}

/* ============================================================
   TELA "MEU PERFIL" (GERENCIAR PERFIL)
   ============================================================ */
.pm-screen {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    animation: profileFadeIn 0.3s ease;
}

.pm-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    background: #0a0a0a;
    position: sticky;
    top: 0;
    z-index: 10;
}

.pm-header h2 {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
    color: #fff;
}

.pm-back-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.pm-body {
    flex: 1;
    padding: 24px 20px 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Avatar da tela de gerenciar */
.pm-avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 28px;
}

.pm-avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a2a2a 0%, #151515 100%);
    border: 3px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0,0,0,0.7);
    margin-bottom: 14px;
    font-size: 44px;
    color: rgba(255,255,255,0.3);
}

.pm-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.pm-avatar-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 18px;
    border-radius: 22px;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}

.pm-avatar-btn:active { background: rgba(255,255,255,0.14); }

/* Campos do formulário */
.pm-field {
    width: 100%;
    max-width: 420px;
    margin-bottom: 16px;
}

.pm-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #8c8c8c;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pm-field input {
    width: 100%;
    box-sizing: border-box;
    background: #1c1c1c;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    padding: 14px 16px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}

.pm-field input:focus { border-color: #E50914; }

.pm-field input:disabled {
    color: #666;
    background: #141414;
    cursor: not-allowed;
}

/* Prefixo @ */
.pm-input-prefix {
    display: flex;
    align-items: center;
    background: #1c1c1c;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding-left: 14px;
    transition: border-color 0.15s;
}

.pm-input-prefix:focus-within { border-color: #E50914; }
.pm-input-prefix span { color: #666; font-size: 15px; font-weight: 700; }
.pm-input-prefix input {
    border: none !important;
    background: transparent !important;
    padding-left: 4px;
}

/* Botões de Ação */
.pm-actions {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.pm-btn-save {
    width: 100%;
    background: #E50914;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    padding: 14px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.1s;
}

.pm-btn-save:active { background: #c40812; transform: scale(0.98); }
.pm-btn-save:disabled { opacity: 0.6; cursor: not-allowed; }

.pm-btn-logout {
    width: 100%;
    background: none;
    color: #f87171;
    font-weight: 700;
    font-size: 14px;
    padding: 14px;
    border: 1px solid rgba(248,113,113,0.4);
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s;
}

.pm-btn-logout:active { background: rgba(248,113,113,0.1); }

.pm-error {
    color: #e87c03;
    font-size: 13px;
    min-height: 18px;
    text-align: center;
    width: 100%;
    max-width: 420px;
    margin-top: 8px;
}

/* Avatar Picker (Escolher avatar) */
.pm-avatar-picker {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    animation: profileSlideUp 0.3s ease;
}

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

.pm-avatar-picker-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.pm-avatar-picker-header h2 { font-size: 18px; font-weight: 800; margin: 0; color: #fff; }

.pm-avatar-picker-close {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.pm-avatar-picker-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ============================================================
   TELA DE CRIAR PERFIL (Profile Create)
   ============================================================ */
.profile-create-content {
    position: relative;
    z-index: 3;
    flex: 1;
    padding: 20px 28px 60px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.profile-create-field {
    width: 100%;
    max-width: 420px;
    margin-bottom: 16px;
}

.profile-create-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #8c8c8c;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-create-field input {
    width: 100%;
    box-sizing: border-box;
    background: #1c1c1c;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    padding: 14px 16px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}

.profile-create-field input:focus { border-color: #E50914; }

.profile-create-input-prefix {
    display: flex;
    align-items: center;
    background: #1c1c1c;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding-left: 14px;
    transition: border-color 0.15s;
}

.profile-create-input-prefix:focus-within { border-color: #E50914; }
.profile-create-input-prefix span { color: #666; font-size: 15px; font-weight: 700; }
.profile-create-input-prefix input {
    border: none !important;
    background: transparent !important;
    padding-left: 4px;
}

.profile-create-error {
    color: #e87c03;
    font-size: 13px;
    min-height: 18px;
    text-align: center;
    width: 100%;
    max-width: 420px;
    margin-bottom: 8px;
}

.profile-create-btn {
    width: 100%;
    max-width: 420px;
    background: #E50914;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    padding: 15px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 8px;
    font-family: inherit;
    transition: background 0.15s, transform 0.1s;
}

.profile-create-btn:active { transform: scale(0.98); background: #c40812; }
.profile-create-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.profile-create-btn-sec {
    background: none;
    border: none;
    color: #999;
    font-size: 14px;
    margin-top: 16px;
    cursor: pointer;
    padding: 8px;
    font-family: inherit;
    text-decoration: underline;
}

/* Picker de avatar da tela de criar */
.profile-avatar-picker {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    animation: profileSlideUp 0.3s ease;
}

.profile-avatar-picker-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.profile-avatar-picker-header h2 { font-size: 18px; font-weight: 800; margin: 0; color: #fff; }

.profile-avatar-picker-close {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.profile-avatar-picker-body { flex: 1; overflow-y: auto; padding: 20px; }

.avatar-category { margin-bottom: 28px; }
.avatar-category h3 { font-size: 13px; font-weight: 800; color: #aaa; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 12px; }

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 12px;
}

.avatar-item {
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    background: #1a1a1a;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s ease, border-color 0.2s;
}

.avatar-item:active { transform: scale(0.92); }
.avatar-item.selected { border-color: #E50914; transform: scale(0.96); }
.avatar-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-picker-loading,
.avatar-picker-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
    color: #888;
    gap: 12px;
}

.avatar-picker-loading .vp-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.12);
    border-top-color: #E50914;
    animation: vcSpin 0.9s linear infinite;
}

.avatar-picker-error i { font-size: 40px; color: #E50914; }
.avatar-picker-error button {
    margin-top: 12px;
    padding: 10px 24px;
    background: #E50914;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

/* Botão de logout específico */
.pm-btn-logout {
    width: 100%;
    background: rgba(229,9,20,0.1);
    color: #E50914;
    border: 1px solid rgba(229,9,20,0.3);
    padding: 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s;
}
.pm-btn-logout:active { background: rgba(229,9,20,0.2); }

/* ============================================================
   ⚡ AJUSTES DA GRADE DE PERFIS (NOVO) ⚡
   ============================================================ */
.profile-item > div:first-child,
.profile-add-btn > div:first-child {
    border-radius: 50% !important; /* Força o avatar e o botão de adicionar a serem redondos */
    overflow: visible !important; /* Permite que a moldura vaze um pouco para fora */
}

/* Garante que a imagem do avatar dentro do perfil seja redonda */
.profile-item img[style*="object-fit: cover"] {
    border-radius: 50%;
}

/* Responsividade para telas pequenas */
@media (max-width: 400px) {
    .profile-item > div:first-child {
        width: 85px !important;
        height: 85px !important;
    }
    .profile-add-btn > div:first-child {
        width: 85px !important;
        height: 85px !important;
    }
    .profile-item span, .profile-add-btn span {
        font-size: 12px !important;
    }
}