/* ═══════════════════════════════════════════════════════════════════
   RISING EDGE — Component Library
   Every reusable UI component lives here exactly once.
═══════════════════════════════════════════════════════════════════ */

/* ╔══════════════════════════════════╗
   ║  BUTTONS                        ║
   ╚══════════════════════════════════╝ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0.625rem var(--sp-5);
  font-size: 0.875rem;
  font-weight: var(--weight-semi);
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all var(--dur-base) var(--ease-out);
  -webkit-user-select: none;
  user-select: none;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary-600);
  color: #fff;
  border-color: var(--primary-600);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.5);
}

.btn-secondary {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary-400);
  border-color: rgba(37, 99, 235, 0.3);
}
.btn-secondary:hover {
  background: rgba(37, 99, 235, 0.2);
}

.btn-outline {
  background: transparent;
  color: var(--text-base);
  border-color: var(--border-med);
}
.btn-outline:hover {
  border-color: var(--primary-500);
  color: var(--primary-400);
  background: rgba(37, 99, 235, 0.06);
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-base);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-sm {
  padding: 0.375rem var(--sp-3);
  font-size: var(--text-sm);
}
.btn-lg {
  padding: 0.875rem var(--sp-8);
  font-size: 1rem;
}
.btn-xl {
  padding: 1rem var(--sp-10);
  font-size: 1.0625rem;
  font-weight: 700;
}
.btn-icon {
  padding: 0.625rem;
  width: 38px;
  height: 38px;
}

/* ╔══════════════════════════════════╗
   ║  BADGES / PILLS                 ║
   ╚══════════════════════════════════╝ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.badge-blue {
  background: rgba(37, 99, 235, 0.15);
  color: var(--primary-400);
}
.badge-cyan {
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan-400);
}
.badge-green {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.badge-orange {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}
.badge-red {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}
.badge-gray {
  background: var(--bg-muted);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-purple {
  background: rgba(139, 92, 246, 0.12);
  color: #a78bfa;
}

/* ╔══════════════════════════════════╗
   ║  CARDS                          ║
   ╚══════════════════════════════════╝ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card-body {
  padding: var(--sp-5) var(--sp-6);
}
.card-hover {
  transition:
    transform var(--dur-base),
    border-color var(--dur-base),
    box-shadow var(--dur-base);
}
.card-hover:hover {
  transform: translateY(-2px);
  border-color: var(--border-med);
  box-shadow: var(--shadow-md);
}

/* Stat card */
.stat-card {
  padding: var(--sp-5) var(--sp-6);
}
.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  color: var(--text-base);
  line-height: 1;
  margin-bottom: var(--sp-1);
}
.stat-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.stat-trend {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-top: var(--sp-1);
}
.stat-trend.up {
  color: var(--success);
}
.stat-trend.down {
  color: var(--danger);
}

/* Training card */
.training-card {
  display: flex;
  flex-direction: column;
}
.training-card-img {
  aspect-ratio: 16/9;
  overflow: hidden;
}
.training-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow);
}
.training-card:hover .training-card-img img {
  transform: scale(1.04);
}
.training-card-body {
  padding: var(--sp-5);
  flex: 1;
  display: flex;
  flex-direction: column;
}
.training-card-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}
.training-card-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-base);
  margin-bottom: var(--sp-2);
  line-height: var(--leading-snug);
}
.training-card-desc {
  font-size: var(--text-sm);
  color: var(--text-sub);
  line-height: var(--leading-normal);
  flex: 1;
}
.training-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}
.training-card-price {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-base);
}

/* Resource card */
.resource-card {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
  padding: var(--sp-5);
}
.resource-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(37, 99, 235, 0.12);
}

/* ╔══════════════════════════════════╗
   ║  FORMS                          ║
   ╚══════════════════════════════════╝ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--text-base);
}
.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0.6875rem var(--sp-4);
  background: var(--bg-input);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-md);
  color: var(--text-base);
  font-size: var(--text-sm);
  font-family: inherit;
  transition:
    border-color var(--dur-base),
    box-shadow var(--dur-base);
  outline: none;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
.textarea {
  resize: vertical;
  min-height: 120px;
}
.select {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

/* Search */
.search-wrap {
  position: relative;
}
.search-wrap .input {
  padding-left: 2.5rem;
}
.search-icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Radio / Checkbox */
.radio-group,
.check-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.radio-item,
.check-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--dur-base);
}
.radio-item:hover,
.check-item:hover {
  border-color: var(--primary-500);
}
.radio-item input,
.check-item input {
  accent-color: var(--primary-500);
  width: 16px;
  height: 16px;
}
.radio-item.selected,
.check-item.selected {
  border-color: var(--primary-500);
  background: rgba(37, 99, 235, 0.06);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-med);
  border-radius: var(--radius-xl);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  background: var(--bg-alt);
  cursor: pointer;
  transition:
    border-color var(--dur-base),
    background var(--dur-base);
}
.upload-zone:hover {
  border-color: var(--primary-500);
  background: rgba(37, 99, 235, 0.04);
}

/* ╔══════════════════════════════════╗
   ║  TABLES                         ║
   ╚══════════════════════════════════╝ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: var(--sp-4);
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td {
  border-bottom: none;
}
.data-table tbody tr:hover {
  background: var(--bg-hover);
}

/* ╔══════════════════════════════════╗
   ║  PROGRESS                       ║
   ╚══════════════════════════════════╝ */
.progress-bar {
  height: 4px;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary-500);
  border-radius: var(--radius-full);
  transition: width 0.4s var(--ease-out);
}
.progress-fill.cyan {
  background: var(--cyan-400);
}
.progress-fill.success {
  background: var(--success);
}
.progress-bar-lg {
  height: 8px;
}
.progress-bar-sm {
  height: 3px;
}

/* ╔══════════════════════════════════╗
   ║  TABS / PILLS FILTER            ║
   ╚══════════════════════════════════╝ */
.tabs {
  display: flex;
  gap: var(--sp-1);
  background: var(--bg-alt);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  width: fit-content;
  flex-wrap: wrap;
}
.tab-item {
  padding: 0.4375rem var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-sub);
  transition: all var(--dur-base);
  border: none;
  background: none;
}
.tab-item.active {
  background: var(--bg-card);
  color: var(--text-base);
  box-shadow: var(--shadow-xs);
}
.tab-item:hover:not(.active) {
  color: var(--text-base);
}

.filter-pills {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.filter-pill {
  padding: 0.375rem var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 1px solid var(--border-med);
  color: var(--text-sub);
  background: var(--bg-alt);
  transition: all var(--dur-base);
}
.filter-pill.active {
  background: var(--primary-600);
  color: #fff;
  border-color: var(--primary-600);
}
.filter-pill:hover:not(.active) {
  border-color: var(--primary-500);
  color: var(--primary-400);
}

/* ╔══════════════════════════════════╗
   ║  ALERTS / CALLOUTS              ║
   ╚══════════════════════════════════╝ */
.alert {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  border: 1px solid;
}
.alert-info {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--primary-300);
}
.alert-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: #34d399;
}
.alert-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
  color: var(--warning);
}
.alert-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

/* ╔══════════════════════════════════╗
   ║  ICON BUTTON                    ║
   ╚══════════════════════════════════╝ */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur-base);
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-base);
  border-color: var(--border-med);
}

/* ╔══════════════════════════════════╗
   ║  AVATAR                         ║
   ╚══════════════════════════════════╝ */
.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-sm {
  width: 28px;
  height: 28px;
}
.avatar-md {
  width: 40px;
  height: 40px;
}
.avatar-lg {
  width: 64px;
  height: 64px;
}
.avatar-xl {
  width: 96px;
  height: 96px;
}
.avatar-2xl {
  width: 120px;
  height: 120px;
}

.avatar-placeholder {
  border-radius: var(--radius-full);
  background: var(--primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-bold);
  color: #fff;
  flex-shrink: 0;
}

/* ╔══════════════════════════════════╗
   ║  MODAL                          ║
   ╚══════════════════════════════════╝ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: var(--sp-8);
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  transform: scale(0.96);
  transition: transform var(--dur-base);
}
.modal-overlay.open .modal {
  transform: scale(1);
}

/* Promo popup: an image-only modal variant (no card padding/background),
   used for the homepage leaderboard poster. */
.promo-modal {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  max-width: 420px;
  position: relative;
}
.promo-modal-frame {
  position: relative;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  max-height: 88vh;
  overflow-y: auto;
  line-height: 0;
}
.promo-modal-frame img {
  display: block;
  width: 100%;
  height: auto;
}
.promo-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background var(--dur-fast);
}
.promo-modal-close:hover {
  background: rgba(0, 0, 0, 0.75);
}

/* ╔══════════════════════════════════╗
   ║  SKELETON LOADER                ║
   ╚══════════════════════════════════╝ */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-hover) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease infinite;
  border-radius: var(--radius-md);
}

/* ╔══════════════════════════════════╗
   ║  TOOLTIP                        ║
   ╚══════════════════════════════════╝ */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-muted);
  color: var(--text-base);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast);
  z-index: var(--z-toast);
}
[data-tooltip]:hover::after {
  opacity: 1;
}

/* ╔══════════════════════════════════╗
   ║  LIVE BADGE / NOTIFICATION DOT  ║
   ╚══════════════════════════════════╝ */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f87171;
  animation: pulse 1.6s ease infinite;
}
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  position: absolute;
  top: -2px;
  right: -2px;
  border: 2px solid var(--bg-page);
}

/* ╔══════════════════════════════════╗
   ║  CODE BLOCK                     ║
   ╚══════════════════════════════════╝ */
.code-block {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
}
.code-block pre {
  padding: var(--sp-4);
  margin: 0;
  border: none;
  background: transparent;
  border-radius: 0;
}

/* ╔══════════════════════════════════╗
   ║  SECTION HEADER                 ║
   ╚══════════════════════════════════╝ */
.section-header {
  margin-bottom: var(--sp-10);
}
.section-header .eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cyan-400);
  margin-bottom: var(--sp-3);
  display: block;
}
.section-header h2 {
  margin-bottom: var(--sp-4);
}
.section-header p {
  max-width: 600px;
  font-size: var(--text-md);
}

/* ╔══════════════════════════════════╗
   ║  DIVIDER                        ║
   ╚══════════════════════════════════╝ */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-8) 0;
}

/* ╔══════════════════════════════════╗
   ║  MISC HELPERS                   ║
   ╚══════════════════════════════════╝ */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
