/* ================================================================
   PROFILE PAGE — PREMIUM DARK DESIGN
   ================================================================ */

:root {
  --bg:          #080b12;
  --surface:     #0f1420;
  --card:        #141927;
  --card-hover:  #1a2133;
  --border:      rgba(255,255,255,0.07);
  --text-1:      #f0f4ff;
  --text-2:      #8b95b0;
  --text-3:      #4e576a;
  --accent:      #4f8aff;
  --accent-glow: rgba(79,138,255,0.25);
  --success:     #22d3a0;
  --warn:        #f59e0b;
  --streak:      #fb923c;
  --token:       #a78bfa;
  --radius-lg:   20px;
  --radius-md:   14px;
  --radius-sm:   8px;
  --font:        'Inter', sans-serif;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.45);
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 0 0 60px;
}

/* ── App Shell ─────────────────────────────────── */
.profile-app {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Header ────────────────────────────────────── */
.profile-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(8,11,18,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.back-btn svg { width: 16px; height: 16px; }
.back-btn:hover { color: var(--text-1); background: var(--card); }

.profile-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.user-select-styled {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  max-width: 140px;
}
.user-select-styled:focus { border-color: var(--accent); }

/* ── Loading / Error ───────────────────────────── */
.loading-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--text-2);
  font-size: 14px;
}

.loader-ring {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-icon { font-size: 36px; }
.retry-btn {
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.retry-btn:hover { opacity: 0.85; }

.hidden { display: none !important; }

/* ── Main Content ──────────────────────────────── */
.profile-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

/* ── User Hero ─────────────────────────────────── */
.user-hero {
  background: linear-gradient(135deg, #111827 0%, #0f1e2e 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.user-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(79,138,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.avatar-wrap {
  position: relative;
  width: 80px; height: 80px;
}

.avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f8aff, #22d3a0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
  position: relative;
  z-index: 1;
}

.avatar-glow {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79,138,255,0.3) 0%, transparent 70%);
  animation: pulse-glow 2.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.user-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.level-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(79,138,255,0.15);
  color: #60a5fa;
  border: 1px solid rgba(79,138,255,0.3);
}

.streak-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(251,146,60,0.15);
  color: var(--streak);
  border: 1px solid rgba(251,146,60,0.3);
}

/* XP bar */
.xp-section {
  width: 100%;
  max-width: 360px;
}

.xp-label {
  display: flex;
  align-items: baseline;
  gap: 4px;
  justify-content: center;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-2);
}
.xp-label span:first-child { font-size: 20px; font-weight: 700; color: var(--text-1); }
.xp-sep { color: var(--text-3); }
.xp-unit { font-size: 12px; color: var(--text-3); margin-left: 2px; }

.xp-track {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f8aff, #22d3a0);
  border-radius: 4px;
  width: 0%;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(79,138,255,0.5);
}

.xp-sublabel {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
}
#next-level-name { color: var(--success); }

/* ── Stats Grid ────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}

.stat-card:hover {
  border-color: rgba(255,255,255,0.14);
  transform: translateY(-2px);
}

.stat-card--streak {
  background: linear-gradient(135deg, rgba(251,146,60,0.08) 0%, var(--card) 60%);
  border-color: rgba(251,146,60,0.2);
}
.stat-card--streak:hover { border-color: rgba(251,146,60,0.35); }
.stat-card--streak::after { background: linear-gradient(90deg, transparent, rgba(251,146,60,0.3), transparent); }

.stat-icon {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.2));
}

.streak-flame {
  animation: flicker 1.5s ease-in-out infinite alternate;
}
@keyframes flicker {
  from { filter: drop-shadow(0 0 4px rgba(251,146,60,0.5)); }
  to   { filter: drop-shadow(0 0 12px rgba(251,146,60,0.9)); }
}

.stat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--text-1);
}

.stat-label {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: auto;
}

/* ── Activity Chart ────────────────────────────── */
.activity-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  box-shadow: var(--shadow-card);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.section-sub {
  font-size: 12px;
  color: var(--text-3);
}

.activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 80px;
}

.bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #4f8aff 0%, #2563eb 100%);
  min-height: 4px;
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: default;
}

.bar.bar--empty {
  background: rgba(255,255,255,0.06);
}

.bar-date {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
}

.bar-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e2a40;
  color: var(--text-1);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  border: 1px solid var(--border);
}

.bar-wrap:hover .bar-tooltip { opacity: 1; }

/* ── Account Info ──────────────────────────────── */
.account-info-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 0;
  box-shadow: var(--shadow-card);
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }

.info-label {
  color: var(--text-2);
  font-weight: 500;
}

.info-value {
  color: var(--text-1);
  font-weight: 500;
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 22px; }
}
