/* ==============================
   PROFILE
   ============================== */

/* Nav avatar image */
.nav-avatar-img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Cover gradient banner */
.profile-cover {
  height: 180px;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 55%, #06B6D4 100%);
}

/* Wrapper that pulls card up over cover */
.profile-card-wrap {
  max-width: 680px;
  margin: -60px auto 0;
  padding: 0 1rem 3rem;
}

/* Main white card */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: visible;
}

/* Top section: avatar + action button */
.profile-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 1.5rem 0;
  margin-top: -44px;
}

/* Avatar */
.profile-avatar-box {
  flex-shrink: 0;
}
.profile-av-img {
  width: 100px; height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-md);
  display: block;
}
.profile-av-placeholder {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  font-size: 2.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-md);
  user-select: none;
}

/* Action buttons */
.profile-card-actions {
  padding-bottom: .5rem;
}
.pf-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem 1.1rem;
  border-radius: var(--radius-full);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.pf-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pf-btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.pf-btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-dark);
}
.pf-btn-outline:hover { background: var(--bg); }
.pf-btn-following {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-dark);
}
.pf-btn-following:hover { border-color: var(--danger); color: var(--danger); }

/* Name, bio, since */
.profile-card-meta {
  padding: 1rem 1.5rem 1.25rem;
}
.pf-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 .15rem;
  line-height: 1.2;
}
.pf-uname {
  font-size: .85rem;
  color: var(--text-muted);
  margin: 0 0 .75rem;
}
.pf-bio {
  font-size: .92rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0 0 .6rem;
  white-space: pre-line;
}
.pf-bio-add {
  font-size: .85rem;
  color: var(--primary);
  display: block;
  margin-bottom: .6rem;
}
.pf-since {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  color: var(--text-muted);
}

/* Stats row */
.pf-stats {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
}
.pf-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem .5rem;
  cursor: default;
  transition: background .15s;
}
.pf-stat:hover { background: var(--bg); }
.pf-stat-n {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.pf-stat-l {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .2rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}
.pf-stat-div {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}

/* Clickable stat link */
a.pf-stat-link {
  text-decoration: none;
  color: inherit;
}
a.pf-stat-link:hover { background: var(--bg); }
a.pf-stat-link:hover .pf-stat-n { color: var(--primary); }

/* ==============================
   USER CARDS (search / lists)
   ============================== */

/* Page title */
.page-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 1.25rem;
}

/* User card list */
.ucard-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* Individual user card */
.ucard {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.ucard:hover { box-shadow: var(--shadow-md); }

.ucard-avatar-link { flex-shrink: 0; }
.ucard-av-img {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
}
.ucard-av-placeholder {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.ucard-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.ucard-name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ucard-name:hover { color: var(--primary); }
.ucard-username {
  font-size: .78rem;
  color: var(--text-muted);
}
.ucard-bio {
  font-size: .82rem;
  color: var(--text-muted);
  margin: .15rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ucard-meta {
  font-size: .75rem;
  color: var(--text-light);
  margin-top: .1rem;
}

/* User list page header */
.ulist-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.ulist-back {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.ulist-back:hover { color: var(--primary); }
.ulist-tabs {
  display: flex;
  gap: .25rem;
  background: var(--bg);
  padding: .25rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}
.ulist-tab {
  padding: .35rem .9rem;
  border-radius: var(--radius-full);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all .15s;
}
.ulist-tab.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.ulist-tab:hover:not(.active) { color: var(--text); }

/* Search form */
.search-form {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}
.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: .875rem;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  padding: .65rem 2.5rem .65rem 2.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--primary); }
.search-clear {
  position: absolute;
  right: .875rem;
  color: var(--text-muted);
  font-size: .85rem;
  text-decoration: none;
  padding: .25rem;
  line-height: 1;
}
.search-clear:hover { color: var(--danger); }
.search-count {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

@media (max-width: 520px) {
  .ucard { padding: .875rem 1rem; }
  .ucard-av-img, .ucard-av-placeholder { width: 44px; height: 44px; font-size: 1.2rem; }
  .search-form { flex-direction: column; }
  .ulist-header { gap: .75rem; }
}

/* ---- Profile Edit Form ---- */
.avatar-upload-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: border-color .15s;
}
.avatar-upload-wrap:hover { border-color: var(--primary); }
.avatar-preview {
  width: 96px; height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary-light);
}
.avatar-preview-placeholder {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  font-size: 2.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-upload-label {
  cursor: pointer;
  color: var(--primary);
  font-size: .875rem;
  font-weight: 600;
}
input[type="file"]#id_avatar { display: none; }
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Responsive */
@media (max-width: 520px) {
  .profile-cover { height: 130px; }
  .profile-card-wrap { margin-top: -50px; }
  .profile-card-top { margin-top: -38px; }
  .profile-av-img,
  .profile-av-placeholder { width: 80px; height: 80px; font-size: 2rem; }
  .pf-name { font-size: 1.15rem; }
  .pf-stat-n { font-size: 1.1rem; }
  .form-row-2 { grid-template-columns: 1fr; }
}

