/*
 * Tefsen profile-page refinement.
 * Loaded after social-cleanup.css so the profile page has one final, stable layout.
 * Brand gradient is intentionally unchanged: #168ff8 -> #18c9d2 -> #31d991.
 */

html.web-quality.tefsen-web-reference {
  --profile-gradient: linear-gradient(105deg, #168ff8, #18c9d2 55%, #31d991);
}

/* ---------- Header: true circular controls ---------- */
html.web-quality.tefsen-web-reference .topbar-actions .icon-button,
html.web-quality.tefsen-web-reference .topbar-actions .quality-theme-button,
html.web-quality.tefsen-web-reference .topbar-actions .top-avatar {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  max-width: 44px !important;
  max-height: 44px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  display: grid !important;
  place-items: center !important;
  flex: 0 0 44px !important;
}

html.web-quality.tefsen-web-reference .topbar-actions .quality-theme-button {
  overflow: visible !important;
}

html.web-quality.tefsen-web-reference .topbar-actions .top-avatar {
  position: relative !important;
  overflow: hidden !important;
  border: 2px solid transparent !important;
  background:
    linear-gradient(var(--social-panel-2), var(--social-panel-2)) padding-box,
    var(--profile-gradient) border-box !important;
}

html.web-quality.tefsen-web-reference .topbar-actions .top-avatar img {
  position: absolute !important;
  inset: 2px !important;
  width: calc(100% - 4px) !important;
  height: calc(100% - 4px) !important;
  border-radius: 50% !important;
  object-fit: cover !important;
}

html.web-quality.tefsen-web-reference .topbar-actions .top-avatar-fallback {
  width: 100% !important;
  height: 100% !important;
  border-radius: 50% !important;
  display: grid !important;
  place-items: center !important;
}

/* ---------- Profile route: remove the cramped third column ---------- */
html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) {
  --right: 0px;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .rightbar {
  display: none !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .main-area {
  padding-right: 0 !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .content-wrap {
  width: min(100%, 940px) !important;
  padding: 32px 32px 110px !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .profile-dashboard-label {
  display: none !important;
}

/* ---------- Main profile card ---------- */
html.web-quality.tefsen-web-reference .profile-dashboard-card {
  width: min(100%, 820px) !important;
  margin: 0 auto 30px !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 28px !important;
  border: 1px solid var(--social-line) !important;
  background: var(--social-panel) !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .16) !important;
}

html.web-quality.tefsen-web-reference[data-web-theme="light"] .profile-dashboard-card {
  box-shadow: 0 18px 50px rgba(29, 71, 72, .09) !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-cover {
  height: 148px !important;
  border-radius: 0 !important;
  background:
    radial-gradient(circle at 14% 45%, rgba(255,255,255,.16), transparent 20rem),
    var(--profile-gradient) !important;
  position: relative !important;
  overflow: hidden !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 25%, rgba(0,18,21,.18)),
    radial-gradient(circle at 80% 10%, rgba(255,255,255,.15), transparent 18rem);
}

html.web-quality.tefsen-web-reference[data-web-theme="light"] .profile-dashboard-card .profile-cover::after {
  background:
    linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.18)),
    radial-gradient(circle at 80% 10%, rgba(255,255,255,.28), transparent 18rem);
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-main {
  padding: 0 34px 30px !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline {
  margin-top: -54px !important;
  min-height: 112px !important;
  display: flex !important;
  align-items: flex-end !important;
  justify-content: space-between !important;
  gap: 20px !important;
  position: relative !important;
  z-index: 2 !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline > div:first-child {
  width: 116px !important;
  height: 116px !important;
  padding: 4px !important;
  border-radius: 50% !important;
  display: grid !important;
  place-items: center !important;
  background: var(--profile-gradient) !important;
  box-shadow: 0 14px 36px rgba(0,0,0,.24) !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline .avatar.lg {
  width: 108px !important;
  height: 108px !important;
  min-width: 108px !important;
  min-height: 108px !important;
  border-radius: 50% !important;
  border: 4px solid var(--social-panel) !important;
  background: var(--social-panel-2) !important;
  overflow: hidden !important;
  box-shadow: none !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline .avatar.lg img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 50% !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline > div:last-child {
  padding-bottom: 8px !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline .btn,
html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-actions .btn {
  min-height: 44px !important;
  padding: 0 18px !important;
  border-radius: 999px !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  box-shadow: none !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card [data-edit-profile],
html.web-quality.tefsen-web-reference .profile-dashboard-card .btn-secondary {
  background: var(--social-panel-2) !important;
  color: var(--social-text) !important;
  border: 1px solid var(--social-line) !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-actions {
  display: flex !important;
  align-items: center !important;
  gap: 9px !important;
}

/* ---------- Identity block ---------- */
html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-info {
  padding: 10px 0 0 !important;
  text-align: left !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-info h1 {
  margin: 0 0 3px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  color: var(--social-text) !important;
  font-size: clamp(28px, 3.2vw, 38px) !important;
  line-height: 1.1 !important;
  letter-spacing: -.035em !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-info .handle {
  display: block !important;
  margin-top: 2px !important;
  color: var(--social-muted) !important;
  font-size: 14px !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-info p {
  max-width: 640px !important;
  margin: 16px 0 13px !important;
  color: color-mix(in srgb, var(--social-text) 78%, var(--social-muted)) !important;
  font-size: 15px !important;
  line-height: 1.65 !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .role-pill {
  min-height: 26px !important;
  padding: 0 10px !important;
  border-radius: 999px !important;
  font-size: 10px !important;
  font-weight: 850 !important;
  letter-spacing: .03em !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .quality-joined {
  margin-top: 12px !important;
  color: var(--social-muted) !important;
  font-size: 12px !important;
}

/* ---------- Stats: one clean row instead of floating text ---------- */
html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats {
  width: 100% !important;
  margin: 28px 0 0 !important;
  padding: 18px 0 0 !important;
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 0 !important;
  border-top: 1px solid var(--social-line) !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats > span {
  min-width: 0 !important;
  min-height: 66px !important;
  padding: 8px 10px !important;
  display: grid !important;
  align-content: center !important;
  justify-items: center !important;
  gap: 3px !important;
  border-radius: 0 !important;
  background: transparent !important;
  border: 0 !important;
  color: var(--social-muted) !important;
  position: relative !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats > span + span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 13px;
  bottom: 13px;
  width: 1px;
  background: var(--social-line);
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats b {
  color: var(--social-text) !important;
  font-size: 23px !important;
  line-height: 1 !important;
  font-weight: 850 !important;
}

html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats small {
  color: var(--social-muted) !important;
  font-size: 10.5px !important;
  font-weight: 650 !important;
  white-space: nowrap !important;
}

/* ---------- Achievements ---------- */
html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .academic-achievements,
html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .quality-questions-title,
html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .profile-tabs,
html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .feed-list {
  width: min(100%, 820px) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .academic-achievements {
  margin-top: 0 !important;
  margin-bottom: 30px !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .academic-achievements h2,
html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .quality-questions-title h2 {
  margin: 0 0 14px !important;
  color: var(--social-text) !important;
  font-size: 21px !important;
  line-height: 1.2 !important;
  letter-spacing: -.02em !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .achievement-row {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .achievement-chip {
  min-height: 42px !important;
  padding: 0 15px !important;
  border-radius: 999px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  background: var(--social-panel) !important;
  color: var(--social-muted) !important;
  border: 1px solid var(--social-line) !important;
  font-size: 12px !important;
  font-weight: 750 !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .achievement-chip.active {
  color: var(--social-text) !important;
  border: 1px solid transparent !important;
  background:
    linear-gradient(var(--social-panel), var(--social-panel)) padding-box,
    var(--profile-gradient) border-box !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .quality-questions-title {
  margin-top: 4px !important;
  margin-bottom: 12px !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .profile-tabs {
  border-bottom: 1px solid var(--social-line) !important;
  margin-bottom: 14px !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .profile-tabs .feed-tab {
  width: auto !important;
  min-width: 92px !important;
  color: var(--social-text) !important;
}

/* ---------- Profile feed cards ---------- */
html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .feed-list {
  gap: 14px !important;
}

html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .feed-list .empty-state {
  min-height: 180px !important;
  padding: 34px !important;
  border-radius: 20px !important;
  background: var(--social-panel) !important;
  border: 1px solid var(--social-line) !important;
  color: var(--social-muted) !important;
}

/* ---------- Light theme precision ---------- */
html.web-quality.tefsen-web-reference[data-web-theme="light"] .profile-dashboard-card .profile-info p {
  color: #405d60 !important;
}

html.web-quality.tefsen-web-reference[data-web-theme="light"] .profile-dashboard-card [data-edit-profile],
html.web-quality.tefsen-web-reference[data-web-theme="light"] .profile-dashboard-card .btn-secondary {
  background: #f2f8f7 !important;
}

/* ---------- Tablet ---------- */
@media (max-width: 960px) {
  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .content-wrap {
    width: min(100%, 860px) !important;
    padding: 24px 22px 105px !important;
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
  html.web-quality.tefsen-web-reference .topbar-actions .icon-button,
  html.web-quality.tefsen-web-reference .topbar-actions .quality-theme-button,
  html.web-quality.tefsen-web-reference .topbar-actions .top-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    flex-basis: 40px !important;
  }

  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .content-wrap {
    width: 100% !important;
    padding: 14px 12px 96px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card {
    width: 100% !important;
    border-radius: 24px !important;
    margin-bottom: 24px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-cover {
    height: 120px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-main {
    padding: 0 18px 22px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline {
    margin-top: -45px !important;
    min-height: 98px !important;
    gap: 12px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline > div:first-child {
    width: 98px !important;
    height: 98px !important;
    padding: 3px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline .avatar.lg {
    width: 92px !important;
    height: 92px !important;
    min-width: 92px !important;
    min-height: 92px !important;
    border-width: 3px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-topline .btn,
  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-actions .btn {
    min-height: 40px !important;
    padding: 0 14px !important;
    font-size: 12px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-info {
    padding-top: 8px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-info h1 {
    font-size: 28px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-info p {
    margin-top: 13px !important;
    font-size: 14px !important;
  }

  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats {
    margin-top: 22px !important;
    padding-top: 14px !important;
    grid-template-columns: repeat(5, minmax(64px, 1fr)) !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }
  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats::-webkit-scrollbar { display: none; }
  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats > span { padding: 7px 6px !important; }
  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats b { font-size: 20px !important; }
  html.web-quality.tefsen-web-reference .profile-dashboard-card .profile-stats small { font-size: 9px !important; }

  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .academic-achievements,
  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .quality-questions-title,
  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .profile-tabs,
  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .feed-list {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .achievement-row {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    padding-bottom: 3px !important;
    scrollbar-width: none;
  }
  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .achievement-row::-webkit-scrollbar { display: none; }
  html.web-quality.tefsen-web-reference:has(.profile-dashboard-card) .achievement-chip { flex: 0 0 auto !important; }
}
