
/* =====================================================
   CODY ACADEMY — PROFILE PAGE
   Professional Profile Styles | RTL | Responsive
   File: css/profile.css
===================================================== */

/* ---------- Profile variables ---------- */

:root {
  --profile-cyan: #6be8ff;
  --profile-purple: #a99aff;
  --profile-gold: #ffd48a;
  --profile-green: #76e9c0;

  --profile-panel: rgba(19, 31, 58, .94);
  --profile-border: rgba(148, 184, 255, .15);
  --profile-muted: #aabbd5;
}

/* ---------- General layout ---------- */

.profile-page {
  width: 100%;
  max-width: 1180px;
  min-width: 0;
  margin-inline: auto;
  padding: 0 0 36px;
}

.profile-page,
.profile-page * {
  box-sizing: border-box;
}

.profile-topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.profile-heading-copy {
  flex: 1;
  min-width: 0;
}

.profile-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--profile-cyan);
  font-size: .78rem;
  font-weight: 800;
}

.profile-kicker-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--profile-green);
  box-shadow: 0 0 12px rgba(118, 233, 192, .65);
}

.profile-page-title {
  margin: 0;
  color: #f5f8ff;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 900;
  line-height: 1.5;
}

.profile-page-description {
  margin: 5px 0 0;
  color: var(--profile-muted);
  font-size: .86rem;
  line-height: 1.9;
}

/* ---------- Top actions ---------- */

.profile-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.profile-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 9px 16px;
  color: #eaf7ff;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid var(--profile-border);
  border-radius: 13px;
  background: rgba(255, 255, 255, .055);
  transition: .2s ease;
}

.profile-action:hover {
  transform: translateY(-2px);
  border-color: var(--profile-cyan);
}

.profile-action.primary {
  color: #061521;
  background: linear-gradient(110deg, #6be8ff, #8bbcff);
  border-color: transparent;
}

/* ---------- Menu ---------- */

.profile-menu {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
}

.profile-menu-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #eaf7ff;
  font-size: 1.45rem;
  border: 1px solid var(--profile-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, .055);
  cursor: pointer;
  transition: .2s ease;
}

.profile-menu-button:hover {
  border-color: var(--profile-cyan);
  transform: translateY(-2px);
}

.profile-menu-content {
  position: absolute;
  top: 51px;
  inset-inline-end: 0;
  display: none;
  min-width: 190px;
  padding: 7px;
  border: 1px solid var(--profile-border);
  border-radius: 14px;
  background: #172542;
  box-shadow: 0 14px 38px rgba(0, 0, 0, .28);
}

.profile-menu.open .profile-menu-content {
  display: block;
}

.profile-menu-content a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: #eaf7ff;
  font-size: .84rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 9px;
}

.profile-menu-content a:hover {
  background: rgba(107, 232, 255, .1);
}

/* ---------- Main profile card ---------- */

.profile-header-card {
  position: relative !important;
  isolation: isolate;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  margin: 0 0 26px;
  padding: 30px 22px 26px;
  overflow: hidden;
  text-align: center;

  border: 1px solid rgba(107, 232, 255, .18);
  border-radius: 25px;

  /* خلفية كحلية متدرجة بدل الأسود الثقيل */
  background:
    radial-gradient(
      ellipse at 50% 0%,
      rgba(107, 232, 255, .16),
      transparent 58%
    ),
    linear-gradient(
      145deg,
      #192b4d 0%,
      #14213d 55%,
      #101a32 100%
    ) !important;

  box-shadow:
    0 18px 55px rgba(0, 0, 0, .16),
    inset 0 1px 0 rgba(255, 255, 255, .035);
}

/* إلغاء الزخارف التي قد تبدو كطبقة سوداء */

.profile-header-card::before,
.profile-header-card::after {
  content: none !important;
  display: none !important;
}

/* ---------- Avatar ---------- */

.avatar-container {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 190px;
  height: 210px;
  margin: 0 auto 4px;
  overflow: visible;
}

.avatar-container .anime-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.avatar-container .anime-character {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transform: scale(.88);
  transform-origin: 50% 90%;
}

.avatar-container .anime-avatar-svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 180px;
  object-fit: contain;
  overflow: visible;
}

.avatar-edit-hint {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  color: var(--profile-cyan);
  font-size: .78rem;
  font-weight: 800;
}

/* ---------- User name: prevent overlap ---------- */

.profile-name {
  position: relative !important;
  z-index: 10 !important;
  display: block;
  width: min(100%, 700px);
  min-height: 1.55em;
  margin: 0 auto 8px;
  padding: 3px 10px;

  color: #ffffff !important;
  font-family: "Cairo", sans-serif;
  font-size: clamp(1.45rem, 4vw, 2rem);
  font-weight: 900;
  line-height: 1.65;

  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;

  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .18);
}

.profile-subtitle {
  position: relative;
  z-index: 3;
  margin: 0 auto 15px;
  color: #b8c8df;
  font-size: .86rem;
  line-height: 1.9;
}

/* ---------- Level ---------- */

.profile-title {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 20px;
  padding: 8px 16px;

  color: var(--profile-gold);
  font-size: .86rem;
  font-weight: 900;

  border: 1px solid rgba(255, 212, 138, .22);
  border-radius: 30px;
  background: rgba(255, 212, 138, .08);
}

.level-progress-wrapper {
  position: relative;
  z-index: 2;
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 16px;

  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 17px;
  background: rgba(8, 17, 35, .35);
}

.level-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
  color: #c1cde0;
  font-size: .8rem;
  font-weight: 800;
}

.xp-number {
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--profile-cyan);
  white-space: nowrap;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 20px;
  background: rgba(255, 255, 255, .12);
}

.progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #47cfff, #8c8aff);
  box-shadow: 0 0 15px rgba(107, 232, 255, .4);
  transition: width .55s ease;
}

.next-level-note {
  margin: 9px 0 0;
  color: #aebed6;
  font-size: .73rem;
  line-height: 1.8;
}

/* ---------- Section headings ---------- */

.profile-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 27px 2px 14px;
}

.profile-section-heading h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: #f5f8ff;
  font-size: 1.08rem;
  font-weight: 900;
}

.profile-section-heading h3 i {
  color: var(--profile-cyan);
  font-size: 1.25rem;
}

.section-caption {
  color: #91a4c2;
  font-size: .74rem;
}

/* ---------- Statistics ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 25px;
}

.stat-box {
  position: relative;
  min-width: 0;
  padding: 20px 13px;
  overflow: hidden;
  text-align: center;

  border: 1px solid var(--profile-border);
  border-radius: 18px;
  background: var(--profile-panel);

  transition: transform .2s ease, border-color .2s ease;
}

.stat-box:hover {
  transform: translateY(-3px);
  border-color: rgba(107, 232, 255, .38);
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto 11px;

  color: var(--stat-color, var(--profile-cyan));
  font-size: 1.5rem;

  border-radius: 14px;
  background: rgba(107, 232, 255, .09);
}

.projects-stat-icon {
  color: #c4b5fd;
  background: rgba(139, 92, 246, .17);
  border: 1px solid rgba(167, 139, 250, .2);
}

.stat-box h4 {
  margin: 0 0 7px;
  color: #aebed6;
  font-size: .77rem;
  font-weight: 700;
}

.stat-box .value {
  color: #ffffff;
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* ---------- Badges ---------- */

.badges-section {
  padding: 21px;
  border: 1px solid var(--profile-border);
  border-radius: 20px;
  background: var(--profile-panel);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.badge-item {
  min-width: 0;
  padding: 17px 9px;
  text-align: center;

  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 15px;
  background: rgba(255, 255, 255, .035);
}

.badge-item i {
  display: block;
  margin-bottom: 8px;
  color: #9baac2;
  font-size: 1.8rem;
}

.badge-item span {
  display: block;
  color: #eaf1ff;
  font-size: .76rem;
  font-weight: 800;
}

.badge-state {
  display: block;
  margin-top: 5px;
  color: #9aaac2;
  font-size: .66rem;
  line-height: 1.6;
}

.badge-system-note {
  margin: 15px 0 0;
  color: #aebed6;
  font-size: .74rem;
  line-height: 1.9;
  text-align: center;
}

/* ---------- Logout ---------- */

.profile-logout-section {
  display: flex;
  justify-content: center;
  margin-top: 25px;
  padding: 18px 0 8px;
  border-top: 1px solid var(--profile-border);
}

.profile-logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 45px;
  padding: 10px 23px;

  color: #ffaaaa;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 800;

  border: 1px solid rgba(255, 120, 120, .25);
  border-radius: 13px;
  background: rgba(255, 100, 100, .07);

  cursor: pointer;
  transition: .2s ease;
}

.profile-logout-button:hover {
  background: rgba(255, 100, 100, .14);
  border-color: #ff8585;
  transform: translateY(-2px);
}

.profile-logout-button[aria-busy="true"] {
  opacity: .65;
  cursor: wait;
  pointer-events: none;
}

/* ---------- Mobile navigation ---------- */

.mobile-nav {
  display: none;
}

@media (max-width: 820px) {
  .mobile-nav {
    position: fixed;
    z-index: 999;
    inset-inline: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));

    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 8px 5px;

    border: 1px solid var(--profile-border);
    border-radius: 18px;
    background: rgba(12, 21, 42, .97);
    box-shadow: 0 10px 35px rgba(0, 0, 0, .3);
    backdrop-filter: blur(18px);
  }

  .mobile-nav a {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;

    color: #a5b1ca;
    font-size: .63rem;
    font-weight: 800;
    text-decoration: none;
    border-radius: 11px;
  }

  .mobile-nav a i {
    font-size: 1.22rem;
  }

  .mobile-nav a.active {
    color: var(--profile-cyan);
    background: rgba(107, 232, 255, .1);
  }

  .space-main {
    padding-bottom: 105px !important;
  }

  .stats-grid,
  .badges-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  .profile-topbar {
    gap: 10px;
  }

  .profile-page-description {
    font-size: .79rem;
  }

  .profile-header-card {
    padding: 24px 13px 20px;
  }

  .avatar-container {
    width: 160px;
    height: 180px;
  }

  .avatar-container .anime-character {
    transform: scale(.78);
  }

  .avatar-container .anime-avatar-svg {
    max-width: 158px;
  }

  .profile-name {
    font-size: clamp(1.35rem, 6vw, 1.7rem);
  }

  .profile-subtitle {
    font-size: .79rem;
  }

  .level-progress-wrapper {
    padding: 13px;
  }

  .level-labels {
    font-size: .7rem;
  }

  .stats-grid {
    gap: 9px;
  }

  .stat-box {
    padding: 15px 8px;
  }

  .stat-box .value {
    font-size: 1.4rem;
  }

  .stat-box h4 {
    font-size: .7rem;
  }

  .badges-section {
    padding: 14px;
  }

  .badge-item {
    padding: 14px 6px;
  }

  .badge-item span {
    font-size: .7rem;
  }

  .profile-top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .profile-action {
    padding: 9px 7px;
    font-size: .73rem;
  }

  .profile-section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 380px) {
  .mobile-nav {
    inset-inline: 6px;
    padding-inline: 3px;
  }

  .mobile-nav a {
    font-size: .57rem;
  }

  .mobile-nav a i {
    font-size: 1.1rem;
  }

  .badges-grid {
    gap: 7px;
  }

  .badge-item {
    padding: 12px 4px;
  }

  .profile-top-actions {
    gap: 7px;
  }
}

/* ---------- Light theme ---------- */

html[data-theme="light"] .profile-header-card {
  background:
    radial-gradient(
      ellipse at 50% 0%,
      rgba(7, 140, 174, .1),
      transparent 56%
    ),
    linear-gradient(145deg, #ffffff, #edf4fc) !important;
  border-color: rgba(49, 65, 105, .13);
}

html[data-theme="light"] .profile-page-title,
html[data-theme="light"] .profile-name,
html[data-theme="light"] .stat-box .value,
html[data-theme="light"] .badge-item span,
html[data-theme="light"] .profile-section-heading h3 {
  color: #18213a !important;
}

html[data-theme="light"] .profile-page-description,
html[data-theme="light"] .profile-subtitle,
html[data-theme="light"] .next-level-note,
html[data-theme="light"] .level-labels,
html[data-theme="light"] .stat-box h4,
html[data-theme="light"] .badge-system-note,
html[data-theme="light"] .section-caption {
  color: #586581;
}

html[data-theme="light"] .level-progress-wrapper {
  background: rgba(30, 50, 80, .04);
  border-color: rgba(49, 65, 105, .12);
}

html[data-theme="light"] .stat-box,
html[data-theme="light"] .badges-section {
  background: rgba(255, 255, 255, .9);
}

html[data-theme="light"] .badge-item {
  border-color: rgba(49, 65, 105, .1);
  background: rgba(30, 50, 80, .025);
}

html[data-theme="light"] .profile-menu-button,
html[data-theme="light"] .profile-action {
  color: #24324e;
  background: rgba(255, 255, 255, .8);
}

html[data-theme="light"] .profile-menu-content {
  background: #ffffff;
  box-shadow: 0 12px 35px rgba(30, 45, 80, .14);
}

html[data-theme="light"] .profile-menu-content a {
  color: #24324e;
}

html[data-theme="light"] .mobile-nav {
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 10px 35px rgba(30, 45, 80, .14);
}

html[data-theme="light"] .mobile-nav a {
  color: #586581;
}

html[data-theme="light"] .mobile-nav a.active {
  color: #078cae;
  background: rgba(7, 140, 174, .09);
}

/* ---------- Accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
  .profile-page *,
  .profile-page *::before,
  .profile-page *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
