/* ========================================
   REFERRAL SYSTEM - B4GLASS REDESIGN
   Clean, modern and didactic interface
   ======================================== */

/* Layout spacing for affiliates page */
.layout-affiliates .page-shell {
  padding-top: 32px;
}

.reflink-cabinet {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Scroll margin for anchor links - accounts for sticky header */
#mis-links {
  scroll-margin-top: calc(var(--topbar-height) + 24px);
}

/* ========================================
   HERO BANNER
   ======================================== */

.ref-hero {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(217, 70, 239, 0.15) 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 24px;
  padding: 48px 40px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: center;
}

.ref-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.ref-hero__content {
  position: relative;
  z-index: 1;
}

.ref-hero__title {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 12px 0;
  background: linear-gradient(135deg, #fff 0%, #e0e7ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ref-hero__subtitle {
  font-size: 18px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  margin: 0 0 28px 0;
  line-height: 1.5;
}

.ref-hero__link-box {
  display: flex;
  gap: 12px;
  max-width: 600px;
}

.ref-hero__input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px 20px;
  color: rgba(255, 255, 255, 0.95);
  font-size: 15px;
  font-family: 'SF Mono', 'Monaco', monospace;
  font-weight: 500;
  transition: all 0.3s ease;
}

.ref-hero__input:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.ref-hero__copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
  border: none;
  border-radius: 12px;
  padding: 16px 24px;
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

.ref-hero__copy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.5);
}

.ref-hero__copy-btn svg {
  flex-shrink: 0;
}

.ref-hero__cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.ref-hero__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ref-hero__btn--primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

.ref-hero__btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.5);
}

.ref-hero__btn--secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
}

.ref-hero__btn--secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ref-hero__decoration {
  width: 160px;
  height: 160px;
  opacity: 0.6;
}

.ref-hero__decoration svg {
  width: 100%;
  height: 100%;
  animation: rotate 20s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ========================================
   HOW IT WORKS - 3 STEPS
   ======================================== */

.ref-how-it-works {
  padding: 0;
}

.ref-section-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 32px 0;
  color: white;
}

.ref-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.ref-step {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ref-step:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 12px 32px rgba(139, 92, 246, 0.2);
}

.ref-step__number {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
  color: white;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-step__icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(139, 92, 246, 0.15);
  border: 2px solid rgba(139, 92, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.ref-step__icon svg {
  stroke: #c4b5fd;
}

.ref-step__title {
  font-size: 20px;
  font-weight: 700;
  color: white;
  margin: 0 0 12px 0;
}

.ref-step__desc {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
  margin: 0;
}

/* ========================================
   ACTIVE PROGRAM
   ======================================== */

.ref-program {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 32px;
  position: relative;
}

.ref-program__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
}

.ref-program__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.ref-program__title-section {
  flex: 1;
}

.ref-program__title {
  font-size: 24px;
  font-weight: 800;
  color: white;
  margin: 0;
}

.ref-program__dashboard-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: 2px solid rgba(16, 185, 129, 0.4);
  border-radius: 14px;
  color: white;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  position: relative;
  overflow: hidden;
}

.ref-program__dashboard-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ref-program__dashboard-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
  border-color: rgba(16, 185, 129, 0.6);
}

.ref-program__dashboard-btn:hover::before {
  opacity: 1;
}

.ref-program__dashboard-btn:active {
  transform: translateY(0px);
}

.ref-program__dashboard-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.ref-program__benefits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.ref-program__item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ref-program__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ref-program__icon--green {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.ref-program__icon--green svg {
  stroke: #6ee7b7;
}

.ref-program__icon--blue {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.ref-program__icon--blue svg {
  stroke: #60a5fa;
}

.ref-program__label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 6px;
}

.ref-program__value {
  font-size: 28px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.ref-program__note {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
}

/* ========================================
   PROGRAM DETAILS - EXPANDIBLE
   ======================================== */

.ref-program__badge-small {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 700;
}

.ref-program__details-toggle {
  width: 100%;
  margin-top: 24px;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.3s ease;
}

.ref-program__details-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(139, 92, 246, 0.4);
}

.ref-program__details-toggle svg {
  transition: transform 0.3s ease;
}

.ref-program__details-toggle.active svg {
  transform: rotate(180deg);
}

.ref-program__details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
}

.ref-program__details.active {
  max-height: 5000px;
}

.ref-program__details-content {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.ref-details-section {
  padding: 24px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
}

.ref-details-title {
  font-size: 18px;
  font-weight: 700;
  color: white;
  margin: 0 0 16px 0;
}

.ref-details-desc {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.7;
  margin: 0;
}

.ref-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.ref-details-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}

.ref-details-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ref-details-value {
  font-size: 16px;
  font-weight: 700;
  color: white;
}

.ref-details-formula {
  padding: 16px;
  background: rgba(139, 92, 246, 0.1);
  border-left: 4px solid #8b5cf6;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.7;
}

.ref-details-note {
  padding: 16px;
  background: rgba(59, 130, 246, 0.1);
  border-left: 4px solid #3b82f6;
  border-radius: 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.7;
}

/* VIP Carryover Note */
.ref-details-note--vip {
  background: rgba(251, 191, 36, 0.1);
  border-left: 4px solid rgba(251, 191, 36, 0.8);
  border-radius: 8px;
}

.ref-details-note--vip strong {
  color: rgba(251, 191, 36, 0.95);
}

/* Carryover Status Values */
.ref-details-value--standard {
  color: rgba(59, 130, 246, 0.95) !important;
  font-weight: 600;
}

.ref-details-value--vip {
  color: rgba(251, 191, 36, 0.95) !important;
  font-weight: 600;
  background: rgba(251, 191, 36, 0.1);
  padding: 4px 12px;
  border-radius: 6px;
  display: inline-block;
}

.ref-details-warning {
  padding: 20px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.7;
}

.ref-details-warning strong {
  color: #fca5a5;
}

.ref-details-warning ul {
  margin: 12px 0;
  padding-left: 24px;
}

.ref-details-warning li {
  margin-bottom: 8px;
}

.ref-details-list {
  margin: 12px 0 0 0;
  padding-left: 24px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.8;
}

.ref-details-list li {
  margin-bottom: 8px;
}

/* Tiers Table */
.ref-tiers-table {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.ref-tier-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.ref-tier-row.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 0 24px rgba(139, 92, 246, 0.2);
}

.ref-tier-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: white;
}

.ref-tier-requirements {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.ref-tier-ngr {
  font-weight: 600;
}

.ref-tier-benefits {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.ref-tier-benefit {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #6ee7b7;
  white-space: nowrap;
}

/* ========================================
   STATISTICS
   ======================================== */

.ref-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.ref-stat {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 28px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ref-stat:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.ref-stat__icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ref-stat__icon--green {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.2) 100%);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.ref-stat__icon--green svg {
  stroke: #6ee7b7;
}

.ref-stat__icon--purple {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(124, 58, 237, 0.2) 100%);
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.ref-stat__icon--purple svg {
  stroke: #c4b5fd;
}

.ref-stat__icon--blue {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(37, 99, 235, 0.2) 100%);
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.ref-stat__icon--blue svg {
  stroke: #60a5fa;
}

.ref-stat__content {
  flex: 1;
  min-width: 0;
}

.ref-stat__label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 8px;
}

.ref-stat__value {
  font-size: 28px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
}

/* ========================================
   REFERRALS TABLE
   ======================================== */

.ref-table {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 32px;
}

.ref-table__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ref-table__row {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: center;
  transition: all 0.3s ease;
}

.ref-table__row:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.ref-table__user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ref-table__avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.ref-table__name {
  font-size: 15px;
  font-weight: 600;
  color: white;
}

.ref-table__stats {
  display: flex;
  gap: 32px;
  justify-content: flex-end;
}

.ref-table__stat {
  text-align: right;
}

.ref-table__stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}

.ref-table__stat-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.ref-table__stat--positive .ref-table__stat-value {
  color: #6ee7b7;
}

.ref-table__stat--negative .ref-table__stat-value {
  color: #fca5a5;
}

.ref-table__empty {
  text-align: center;
  padding: 60px 20px;
}

.ref-table__empty svg {
  stroke: rgba(255, 255, 255, 0.3);
  margin-bottom: 20px;
}

.ref-table__empty p {
  font-size: 15px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 900px) {
  .layout-affiliates .page-shell {
    padding-top: 24px;
  }
  
  .ref-hero {
    grid-template-columns: 1fr;
    padding: 36px 28px;
  }
  
  .ref-hero__decoration {
    display: none;
  }
  
  .ref-hero__title {
    font-size: 32px;
  }
  
  .ref-steps {
    grid-template-columns: 1fr;
  }
  
  .ref-table__row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .ref-table__stats {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .layout-affiliates .page-shell {
    padding-top: 16px;
  }
  
  .reflink-cabinet {
    padding: 0 12px 32px;
    gap: 24px;
  }
  
  .ref-hero {
    padding: 28px 20px;
    border-radius: 20px;
  }
  
  .ref-hero__title {
    font-size: 28px;
  }
  
  .ref-hero__subtitle {
    font-size: 16px;
  }
  
  .ref-hero__link-box {
    flex-direction: column;
  }
  
  .ref-hero__copy-btn {
    justify-content: center;
  }
  
  .ref-section-title {
    font-size: 24px;
  }
  
  .ref-step {
    padding: 24px 20px;
  }
  
  .ref-program {
    padding: 24px 20px;
  }
  
  .ref-program__header {
    flex-direction: column;
    gap: 16px;
  }
  
  .ref-program__dashboard-btn {
    width: 100%;
    justify-content: center;
    padding: 16px 24px;
    font-size: 16px;
  }
  
  .ref-program__benefits {
    grid-template-columns: 1fr;
  }
  
  .ref-program__details-toggle {
    padding: 14px 20px;
    font-size: 14px;
  }
  
  .ref-details-section {
    padding: 20px 16px;
  }
  
  .ref-details-grid {
    grid-template-columns: 1fr;
  }
  
  .ref-tier-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .ref-tier-benefits {
    justify-content: flex-start;
  }
  
  .ref-details-warning {
    padding: 16px;
  }
  
  .ref-stats {
    grid-template-columns: 1fr;
  }
  
  .ref-table {
    padding: 24px 16px;
  }
  
  .ref-table__row {
    padding: 16px;
  }
  
  .ref-table__stats {
    gap: 16px;
  }
}
