/* ==========================================
   Página de Perfil Público — Rico aos Poucos
   /perfil/?u={slug}
   ========================================== */

/* style.css define `section { padding: 60px 0 }`. As sections que TÊM padding
   próprio (.profile-hero, .profile-reputation) declaram embaixo. As sem
   padding próprio (.profile-stats — container de grid) zeram explicitamente. */

.profile-page {
  padding: 24px 20px 64px;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ──────── Skeleton / Loading / Estados ──────── */
.profile-loading {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.profile-skeleton-hero,
.profile-skeleton-card {
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-tertiary) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: profile-skeleton 1.4s infinite;
  border-radius: var(--border-radius-lg);
}
.profile-skeleton-hero { height: 180px; }
.profile-skeleton-card { height: 120px; }

@keyframes profile-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.profile-empty,
.profile-error {
  text-align: center;
  padding: 64px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  color: var(--text-secondary);
}
.profile-error { color: var(--bearish); }
.profile-error button,
.profile-empty a {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.profile-error button:hover,
.profile-empty a:hover { background: var(--primary-light); color: #fff; }

/* ──────── Hero (avatar + nome + bio + ações) ──────── */
.profile-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
}
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  object-fit: cover;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}
.profile-avatar-fallback {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  background: var(--primary-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.profile-identity {
  min-width: 0;
}
.profile-name {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
  word-wrap: break-word;
}
.profile-since {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.profile-bio {
  font-size: 0.96rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.profile-bio.empty {
  color: var(--text-muted);
  font-style: italic;
}
.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.profile-btn {
  padding: 8px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
}
.profile-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.profile-btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.profile-btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-color);
}
.profile-btn-secondary:hover { background: var(--bg-tertiary); border-color: var(--primary-light); }
.profile-btn-following {
  background: transparent;
  color: var(--primary-light);
  border-color: var(--primary-light);
}
.profile-btn-following:hover {
  background: rgba(248, 81, 73, 0.08);
  color: var(--bearish);
  border-color: var(--bearish);
}
.profile-btn-following:hover::after { content: ' ✕'; }

/* ──────── Card Reputação ──────── */
.profile-reputation {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: center;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
}
.profile-rep-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  padding: 12px 16px;
  border-radius: var(--border-radius-lg);
  background: var(--bg-tertiary);
  border: 2px solid var(--rep-color, var(--text-muted));
}
.profile-rep-number {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--rep-color, var(--text-muted));
  font-variant-numeric: tabular-nums;
}
.profile-rep-of {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.profile-rep-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--rep-color, var(--text-muted));
  margin-top: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.profile-rep-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile-rep-headline {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.4;
}
.profile-rep-help {
  font-size: 0.84rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  padding: 0;
  border: 1px solid var(--border-color);
}
.profile-rep-help summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 500;
  color: var(--primary-light);
  user-select: none;
  list-style: none;
}
.profile-rep-help summary::-webkit-details-marker { display: none; }
.profile-rep-help summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform .2s;
}
.profile-rep-help[open] summary::before {
  transform: rotate(90deg);
}
.profile-rep-help summary:hover { color: var(--secondary); }
.profile-rep-help-body {
  padding: 0 14px 14px;
  line-height: 1.55;
}
.profile-rep-help-body p { margin: 0 0 8px; }
.profile-rep-help-body ul { margin: 6px 0 8px 20px; padding: 0; }
.profile-rep-help-body li { margin-bottom: 4px; }
.profile-rep-help-body strong { color: var(--text-primary); }

/* ──────── Stats grid ──────── */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 0;
}
.profile-stat {
  padding: 16px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  text-align: center;
}
.profile-stat-num {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.profile-stat-lbl {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}

/* ──────── Tabs ──────── */
.profile-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}
.profile-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  padding: 12px 18px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color .15s;
}
.profile-tab:hover { color: var(--text-primary); }
.profile-tab[aria-selected="true"] {
  color: var(--primary-light);
  font-weight: 700;
}
.profile-tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 3px;
  background: var(--primary-light);
  border-radius: 3px 3px 0 0;
}
.profile-tab-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 6px;
  font-weight: 400;
}

/* ──────── Tab panels & cards ──────── */
.profile-panels { min-height: 240px; }
.profile-panel { display: none; }
.profile-panel.is-active {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
.profile-panel.is-active > .profile-panel-empty,
.profile-panel.is-active > .profile-load-more { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .profile-panel.is-active { grid-template-columns: 1fr; }
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  transition: border-color .15s, transform .15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.profile-card:hover { border-color: var(--primary-light); transform: translateY(-1px); }
.profile-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.profile-card-tag {
  background: var(--bg-tertiary);
  color: var(--primary-light);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}
.profile-card-tag[data-kind="fii"] { color: var(--secondary); }
.profile-card-tag[data-kind="artigo"] { color: var(--bullish); }
.profile-card-tag[data-kind="inline"] { color: var(--accent); }
.profile-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px;
  line-height: 1.35;
}
.profile-card-body {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
  word-wrap: break-word;
}
.profile-card-anchor {
  border-left: 3px solid var(--accent);
  padding: 6px 10px;
  margin: 6px 0 8px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.86rem;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}
.profile-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.profile-card-meta .likes {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--bearish);
  font-weight: 600;
}
.profile-card-cover {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--border-radius);
  margin-bottom: 12px;
}

.profile-card-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.profile-card-status[data-status="published"],
.profile-card-status[data-status="approved"] {
  background: rgba(63, 185, 80, 0.12);
  color: var(--bullish);
}
.profile-card-status[data-status="pending"] {
  background: rgba(240, 193, 75, 0.12);
  color: var(--neutral);
}
.profile-card-status[data-status="rejected"] {
  background: rgba(248, 81, 73, 0.12);
  color: var(--bearish);
}

.profile-load-more {
  display: block;
  margin: 20px auto 0;
  padding: 10px 24px;
  border-radius: 999px;
  background: transparent;
  color: var(--primary-light);
  border: 1px solid var(--primary-light);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.profile-load-more:hover { background: var(--primary-light); color: #fff; }
.profile-load-more[disabled] { opacity: 0.5; cursor: default; }

.profile-panel-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-style: italic;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
}

/* ──────── Modal de edição (is_me) ──────── */
.profile-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.profile-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.profile-modal h2 {
  font-size: 1.2rem;
  margin: 0 0 4px;
  color: var(--text-primary);
}
.profile-modal label {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}
.profile-modal input,
.profile-modal textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.94rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  resize: vertical;
}
.profile-modal input:focus,
.profile-modal textarea:focus {
  outline: none;
  border-color: var(--primary-light);
}
.profile-modal textarea { min-height: 96px; }
.profile-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.profile-modal-error {
  background: rgba(248, 81, 73, 0.12);
  color: var(--bearish);
  padding: 8px 12px;
  border-radius: var(--border-radius);
  font-size: 0.86rem;
}

/* ──────── Mobile ──────── */
@media (max-width: 640px) {
  .profile-page { padding: 16px 12px 48px; gap: 16px; }
  .profile-hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 20px 16px;
  }
  .profile-hero .profile-avatar,
  .profile-hero .profile-avatar-fallback { margin: 0 auto; }
  .profile-actions {
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }
  .profile-reputation {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .profile-rep-score { margin: 0 auto; }
  .profile-rep-body { text-align: left; }
  .profile-name { font-size: 1.35rem; }
  .profile-rep-number { font-size: 2.2rem; }
}
