/* ── Layout ── */
#app-perfil {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  background: var(--bg);
}

/* ── Top bar ── */
.pf-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
.pf-topbtn {
  width: 36px; height: 36px;
  background: none; border: none;
  color: var(--text); font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background .2s;
}
.pf-topbtn:hover { background: var(--chip-bg); }
.pf-topcenter {
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}
.pf-topcenter i { font-size: 12px; color: var(--muted); }

/* ── Scroll area ── */
#perfil-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pf-content {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 90px;
}

/* ── Header do perfil ── */
#perfil-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 16px;
  position: relative;
}
#perfil-header::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 220px; height: 180px;
  background: radial-gradient(ellipse at top, var(--accent-15) 0%, transparent 70%);
  pointer-events: none;
}
.pf-avatar-wrap {
  position: relative;
  margin-bottom: 14px;
}
.pf-avatar {
  width: 104px; height: 104px; border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 3px var(--red), 0 8px 32px var(--shadow-primary-md);
  transition: box-shadow .3s;
}
.pf-avatar-edit {
  position: absolute; bottom: 2px; right: 2px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--red); color: #fff;
  border: 2.5px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 11px;
  box-shadow: 0 2px 8px var(--shadow-primary-sm);
  transition: transform .2s, box-shadow .2s;
}
.pf-avatar-edit:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 14px var(--shadow-primary-md);
}
.pf-name-row {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.pf-nome {
  font-size: 20px; font-weight: 800; letter-spacing: -0.3px;
}
.pf-verified {
  color: var(--blue); font-size: 15px;
}
.pf-handle {
  font-size: 13px; color: var(--muted); margin-bottom: 10px;
  letter-spacing: 0.2px;
}
.pf-bio {
  font-size: 13px; color: var(--text); text-align: center;
  line-height: 1.6; max-width: 280px; opacity: .85;
}

/* ── Stats ── */
#perfil-stats {
  display: flex;
  justify-content: center;
  margin: 0 20px 4px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.pf-stat {
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  flex: 1; padding: 16px 0;
  position: relative;
  cursor: default;
  transition: background .2s;
}
.pf-stat:hover { background: var(--chip-bg); }
.pf-stat + .pf-stat::before {
  content: '';
  position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 1px; background: var(--border);
}
.pf-stat-num {
  font-size: 19px; font-weight: 800; letter-spacing: -0.5px;
}
.pf-stat-label {
  font-size: 10px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
}

/* ── Ações ── */
#perfil-actions {
  display: flex;
  gap: 8px;
  padding: 16px 20px 8px;
}
.pf-btn {
  flex: 1;
  padding: 9px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .2s;
  text-align: center; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  letter-spacing: 0.2px;
}
.pf-btn:hover { background: var(--chip-hover); }
.pf-btn-primary {
  background: var(--red); color: #fff;
  border-color: var(--red);
  box-shadow: 0 2px 12px var(--shadow-primary-sm);
}
.pf-btn-primary:hover { opacity: .88; }
.pf-btn-icon {
  flex: none;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 15px;
  transition: all .2s;
}
.pf-btn-icon:hover { background: var(--chip-hover); }

/* ── Tabs ── */
.pf-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 57px; z-index: 10;
  margin-top: 8px;
}
.pf-tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 13px 8px;
  background: none; border: none;
  color: var(--muted); font-size: 12px; font-weight: 700;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .2s;
  text-transform: uppercase; letter-spacing: 0.6px;
  font-family: inherit;
}
.pf-tab i { font-size: 14px; }
.pf-tab.active {
  color: var(--text);
  border-bottom-color: var(--red);
}

/* ── Grid ── */
.pf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.pf-grid-item {
  aspect-ratio: 3 / 4;
  background: var(--surface);
  position: relative; overflow: hidden;
  cursor: pointer;
}
.pf-grid-item img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .35s ease;
}
.pf-grid-item:hover img { transform: scale(1.05); }
.pf-grid-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 10px 6px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.68));
  display: flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; color: #fff;
}
.pf-grid-overlay i { font-size: 9px; opacity: .9; }

/* ── Estado vazio ── */
.pf-empty-grid {
  grid-column: 1 / -1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 56px 20px; text-align: center; gap: 6px;
}
.pf-empty-grid i {
  font-size: 36px; color: var(--muted); margin-bottom: 6px; opacity: .45;
}
.pf-empty-grid p { font-size: 14px; color: var(--muted); }

/* ── Menu ── */
.pf-menu-section { margin-top: 28px; }
.pf-menu-title {
  font-size: 11px; font-weight: 700; color: var(--muted);
  padding: 0 20px 10px;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.pf-menu-list {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
}
.pf-menu-item {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 20px;
  background: none; border: none; border-bottom: 1px solid var(--separator);
  color: var(--text); font-size: 15px; cursor: pointer;
  text-align: left; width: 100%;
  transition: background .2s;
  font-family: inherit;
}
.pf-menu-item:last-child { border-bottom: none; }
.pf-menu-item:hover { background: var(--chip-bg); }
.pf-menu-item i:first-child { width: 22px; text-align: center; font-size: 16px; color: var(--muted); }
.pf-menu-chevron { margin-left: auto; color: var(--muted); font-size: 11px; opacity: .55; }
.pf-menu-item.ph-danger { color: #ff453a; }
.pf-menu-item.ph-danger i { color: #ff453a; }

/* ── Nav mobile ── */
#mobile-nav {
  display: flex;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--mobile-nav-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  flex-direction: row; justify-content: space-around; align-items: center;
}
.mob-nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 22px; padding: 4px 12px;
  transition: color .2s; text-decoration: none;
}
.mob-nav-btn.active { color: var(--text); }
.mob-nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; }
.mob-nav-btn.center .action-icon {
  width: 42px; height: 28px; border-radius: 8px;
  background: var(--red); display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
}

/* ── Widescreen ── */
@media (min-width: 768px) {
  #mobile-nav { display: none !important; }
  #app-perfil { flex-direction: row; align-items: stretch; }
  #nav-left {
    display: flex; flex-direction: column;
    width: 240px; flex-shrink: 0;
    padding: 28px 20px;
    border-right: 1px solid var(--border);
    background: var(--nav-solid-bg);
  }
  #nav-left .logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 32px; letter-spacing: 2px;
    color: var(--text); margin-bottom: 36px; line-height: 1;
  }
  #nav-left .logo span { color: var(--red); }
  #nav-left nav { display: flex; flex-direction: column; gap: 4px; }
  #nav-left nav a {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px; border-radius: 12px;
    color: var(--muted); text-decoration: none;
    font-size: 15px; font-weight: 500;
    transition: all .2s; cursor: pointer;
  }
  #nav-left nav a:hover,
  #nav-left nav a.active { background: var(--chip-bg); color: var(--text); }
  #nav-left nav a.active { color: var(--red); }
  #nav-left nav a i { width: 22px; text-align: center; font-size: 17px; }
  .pf-topbar { display: none; }
  .pf-content { padding-top: 20px; }
  .pf-tabs { top: 0; }
}

@media (max-width: 767px) {
  #nav-left { display: none; }
}

/* ── Tela editar perfil (slide-up full page) ── */
#perfil-edit-drawer {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; justify-content: flex-end;
  pointer-events: none;
}
#perfil-edit-drawer.open {
  pointer-events: auto;
}

.drawer-sheet {
  background: var(--bg);
  height: 100dvh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .42s cubic-bezier(0.32, 0.72, 0, 1);
}
#perfil-edit-drawer.open .drawer-sheet {
  transform: translateY(0);
}

/* Nav bar */
.pe-navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
  min-height: 52px;
}
.pe-nav-title {
  font-size: 16px; font-weight: 700; margin: 0;
}
.pe-nav-cancel {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 400;
  color: var(--muted); padding: 8px 12px; border-radius: 8px;
  transition: color .2s;
}
.pe-nav-cancel:hover { color: var(--text); }
.pe-nav-save {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 700;
  color: var(--red); padding: 8px 12px; border-radius: 8px;
  transition: opacity .2s;
}
.pe-nav-save:hover { opacity: .75; }
.pe-nav-save:disabled { opacity: .4; cursor: not-allowed; }

/* Body rolável */
.drawer-body {
  flex: 1; overflow-y: auto;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* Avatar section */
.pe-avatar-section {
  display: flex; flex-direction: column; align-items: center;
  padding: 32px 20px 24px; gap: 10px;
}
.pe-avatar-ring {
  position: relative;
  width: 120px; height: 120px;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(var(--red), #FF6B8A, var(--red));
}
.pe-avatar-preview {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--surface);
}
.pe-avatar-overlay {
  position: absolute; inset: 4px; border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: none; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  opacity: 0;
  transition: opacity .25s ease;
}
.pe-avatar-ring:hover .pe-avatar-overlay,
.pe-avatar-overlay:focus-visible {
  opacity: 1;
}
.pe-avatar-hint {
  font-size: 12px; font-weight: 500; color: var(--muted);
}

/* Sections */
.pe-section {
  margin: 0 20px 24px;
}
.pe-section-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  margin: 0 0 10px;
  letter-spacing: -0.2px;
}

/* Field boxes */
.pe-field-box {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 14px;
}
.pe-field-box:last-child { margin-bottom: 0; }
.pe-field-box label {
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding-left: 2px;
}
.pe-field-box input,
.pe-field-box textarea {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text); font-size: 15px; font-family: inherit;
  padding: 12px 14px;
  width: 100%;
  caret-color: var(--red);
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none;
}
.pe-field-box input::placeholder,
.pe-field-box textarea::placeholder {
  color: var(--muted);
  opacity: .55;
}
.pe-field-box input:focus,
.pe-field-box textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--accent-10);
  background: var(--bg);
}
.pe-field-box textarea {
  resize: none; line-height: 1.55; min-height: 90px;
}

.pe-erro {
  margin: 4px 20px 24px;
  font-size: 13px; color: #ff453a;
  text-align: center; font-weight: 500;
  min-height: 20px;
}
