/* css/redesign-profile.css
   Фаза 4 редизайна (docs/REDESIGN_PLAN.md): личный кабинет — общий "shell"
   (карточка с аватаром/ID/балансом бонусов, underline-табы) плюс вкладка
   "Заказы" (4.1). Переопределения через --rd-* токены поверх css/base.css —
   разметка/логика (js/profileMain.js, js/profile/ordersTab.js) не
   переписаны, только визуальные классы. Остальные вкладки профиля
   переезжают на эти же токены в следующих под-фазах (4.2–4.10). */

#profilePage {
  font-family: var(--rd-font-family);
}

/* ===== Шапка профиля (аватар, ID, баланс бонусов) ===== */
#profilePage .profile-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: var(--rd-radius-card);
  padding: 28px 32px;
  margin-bottom: 24px;
}
#profilePage .profile-header-identity {
  display: flex;
  align-items: center;
  gap: 20px;
}
#profilePage .profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--rd-panel-header);
  border: 1px solid var(--rd-border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rd-gold);
  flex-shrink: 0;
}
#profilePage .profile-avatar .icon {
  width: 24px;
  height: 24px;
}
#profilePage .profile-header-name {
  font-weight: 700;
  font-size: 1.1em;
  color: var(--rd-text);
}
#profilePage .profile-header-id {
  font-size: 0.8em;
  color: var(--rd-text-muted);
  margin-top: 2px;
}
#profilePage .profile-header-bonus {
  text-align: right;
}
#profilePage .profile-header-bonus-label {
  font-size: 0.7em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rd-text-muted);
  margin-bottom: 4px;
}
#profilePage .profile-header-bonus-value {
  font-size: 1.5em;
  font-weight: 800;
  color: var(--rd-gold);
}

/* ===== Табы профиля — underline-строка, не пилюли ===== */
#profilePage .tabs#profileTabs {
  background: none;
  border-bottom: 1px solid var(--rd-border);
  border-radius: 0;
  padding: 0;
  gap: 22px;
}
#profilePage .tabs#profileTabs button {
  border-radius: 0;
  padding: 10px 2px;
  border-bottom: 2px solid transparent;
  color: var(--rd-text-muted);
  font-weight: 700;
  font-size: 0.9em;
}
#profilePage .tabs#profileTabs button:hover {
  background: none;
  color: var(--rd-text);
}
#profilePage .tabs#profileTabs button.active {
  background: none;
  border-bottom-color: var(--rd-gold);
  color: var(--rd-gold);
}

/* ===== Вкладка "Заказы" ===== */
/* #orderTabs (фильтр Активные/Не оплаченные/Завершённые) остался на голом
   .tabs из css/base.css (серая пилюля) — пропущен в Фазе 4.1, найден при
   проверке Фазы 5.4. Стиль — тот же приём, что у #p2pSubTabs (Фаза 4.5). */
#profilePage .tabs#orderTabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  background: var(--rd-panel-header);
  border-radius: 10px;
  padding: 4px;
}
#profilePage .tabs#orderTabs button {
  border-radius: 8px;
  padding: 9px 20px;
  color: var(--rd-text-muted);
  font-weight: 700;
  font-size: 0.8em;
}
#profilePage .tabs#orderTabs button:hover {
  background: none;
  color: var(--rd-text);
}
#profilePage .tabs#orderTabs button.active {
  background: var(--rd-gold);
  color: oklch(0.15 0.01 85);
}
#profilePage .order-item {
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 14px;
  padding: 16px 20px;
}
#profilePage .order-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
#profilePage .order-item-name {
  font-weight: 700;
  font-size: 0.95em;
  color: var(--rd-text);
}
#profilePage .order-item-meta {
  font-size: 0.8em;
  color: var(--rd-text-muted);
  margin-top: 2px;
}
#profilePage .order-item-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
#profilePage .order-item-price {
  font-weight: 700;
  color: var(--rd-gold);
}
#profilePage .order-item-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rd-border);
  color: var(--rd-text-muted);
  font-size: 0.9em;
}
#profilePage .order-item-details p {
  margin: 3px 0;
}
#profilePage .order-item-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Статус-пилюля — переопределяем цвета старых .status-* классов на токены */
#profilePage .status-badge {
  border-radius: 12px;
  font-size: 0.75em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 5px 12px;
}
#profilePage .status-new { background: oklch(0.6 0.14 240 / 0.25); color: var(--rd-status-new); }
#profilePage .status-work { background: oklch(0.65 0.15 55 / 0.25); color: var(--rd-status-pending); }
#profilePage .status-done { background: oklch(0.6 0.13 150 / 0.25); color: var(--rd-status-done); }
#profilePage .status-error { background: oklch(0.55 0.17 25 / 0.25); color: var(--rd-status-error); }
#profilePage .status-cancel { background: oklch(0.5 0.006 260 / 0.35); color: var(--rd-status-cancelled); }

#profilePage .chat-order-btn {
  background: oklch(0.4 0.14 240 / 0.3);
  color: oklch(0.75 0.13 240);
  border: none;
  border-radius: 8px;
}
#profilePage .chat-order-btn:hover {
  background: oklch(0.4 0.14 240 / 0.45);
}

/* ===== Вкладка "Бонусы" ===== */
#profilePage .bonus-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 12px;
}
#profilePage .bonus-history-reason {
  font-weight: 700;
  font-size: 0.95em;
  color: var(--rd-text);
}
#profilePage .bonus-history-date {
  font-size: 0.8em;
  color: var(--rd-text-muted);
  margin-top: 2px;
}
#profilePage .bonus-history-amount {
  font-weight: 700;
}
#profilePage .bonus-amount-positive { color: var(--rd-status-done); }
#profilePage .bonus-amount-negative { color: var(--rd-status-error); }
#profilePage .bonus-amount-neutral { color: var(--rd-gold); }
#profilePage .bonus-history-empty {
  text-align: center;
  color: var(--rd-text-muted);
  padding: 20px 0;
}

/* ===== Вкладка "Лояльность" ===== */
#profilePage .loyalty-columns {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
#profilePage .loyalty-column-left {
  flex: 1;
  min-width: 260px;
  max-width: 340px;
}
#profilePage .loyalty-column-right {
  flex: 1;
  min-width: 260px;
}
#profilePage .loyalty-label {
  font-size: 0.75em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rd-text-muted);
  margin-bottom: 6px;
}
#profilePage .loyalty-current-card {
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 14px;
  padding: 26px 30px;
  margin-bottom: 16px;
}
#profilePage .loyalty-current-value {
  font-size: 1.5em;
  font-weight: 800;
  color: var(--rd-gold);
  margin-bottom: 16px;
}
#profilePage .loyalty-progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--rd-border);
  overflow: hidden;
  margin-bottom: 10px;
}
#profilePage .loyalty-progress-fill {
  height: 100%;
  background: var(--rd-gold);
}
#profilePage .loyalty-progress-text {
  font-size: 0.8em;
  color: var(--rd-text-muted);
}
#profilePage .loyalty-stats-row {
  display: flex;
  gap: 16px;
}
#profilePage .loyalty-stat-card {
  flex: 1;
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 14px;
  padding: 18px 20px;
}
#profilePage .loyalty-stat-value {
  font-size: 1.25em;
  font-weight: 800;
  color: var(--rd-text);
}
#profilePage .loyalty-stat-value-green {
  color: var(--rd-status-done);
}
#profilePage .loyalty-levels-title {
  margin-bottom: 12px;
}
#profilePage .loyalty-levels-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#profilePage .loyalty-tier-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 12px;
  padding: 14px 18px;
  text-align: left;
}
#profilePage .loyalty-tier-row.active {
  background: var(--rd-panel-header);
  border-color: var(--rd-border-gold);
}
#profilePage .loyalty-tier-name {
  font-size: 0.875em;
  font-weight: 700;
  color: var(--rd-text);
}
#profilePage .loyalty-tier-row.active .loyalty-tier-name {
  color: var(--rd-gold);
}
#profilePage .loyalty-tier-threshold {
  font-size: 0.8em;
  color: var(--rd-text-muted);
}

/* ===== Вкладка "Реферальная программа" ===== */
#profilePage .referral-columns {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
#profilePage .referral-column-left {
  flex: 1;
  min-width: 260px;
  max-width: 340px;
}
#profilePage .referral-column-right {
  flex: 1;
  min-width: 260px;
}
#profilePage .referral-code-card,
#profilePage .referral-terms-block,
#profilePage .referral-referrer-block {
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 14px;
  padding: 22px 26px;
  margin-bottom: 16px;
}
#profilePage .referral-code-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
#profilePage .referral-code-value {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 1em;
  font-weight: 700;
  color: var(--rd-text);
  letter-spacing: 0.05em;
}
#profilePage .referral-stat-row {
  display: flex;
  gap: 24px;
}
#profilePage .referral-stat-value {
  font-size: 1em;
  font-weight: 700;
  color: var(--rd-gold);
}
#profilePage .referral-stat-value-green {
  color: var(--rd-status-done);
}
#profilePage .referral-terms-text {
  font-size: 0.8em;
  color: var(--rd-text);
  line-height: 1.6;
}
#profilePage .referral-terms-text b {
  color: var(--rd-gold);
}
#profilePage .referral-referrer-value {
  font-size: 0.8em;
  color: var(--rd-text);
}
#profilePage .referral-friends-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#profilePage .referral-friend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 12px;
  padding: 14px 18px;
}
#profilePage .referral-friend-email {
  font-size: 0.85em;
  color: var(--rd-text);
}
#profilePage .referral-friend-date {
  font-size: 0.8em;
  color: var(--rd-text-muted);
}
#profilePage .referral-friends-empty {
  text-align: center;
  color: var(--rd-text-muted);
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 12px;
  padding: 20px 0;
}
#profilePage .referral-copy-btn {
  background: var(--rd-panel-header);
  border: 1px solid var(--rd-border-gold);
  color: var(--rd-gold);
}
#profilePage .referral-copy-btn:hover {
  background: var(--rd-panel);
}

/* ===== Вкладка "P2P" — общая оболочка (под-вкладки) + карточки списков ===== */
#profilePage .tabs#p2pSubTabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  background: var(--rd-panel-header);
  border-radius: 10px;
  padding: 4px;
}
#profilePage .tabs#p2pSubTabs button {
  border-radius: 8px;
  padding: 9px 20px;
  color: var(--rd-text-muted);
  font-weight: 700;
  font-size: 0.8em;
}
#profilePage .tabs#p2pSubTabs button:hover {
  background: none;
  color: var(--rd-text);
}
#profilePage .tabs#p2pSubTabs button.active {
  background: var(--rd-gold);
  color: oklch(0.15 0.01 85);
}

#profilePage .p2p-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 0.8em;
  color: var(--rd-text-muted);
}
#profilePage .deals-list,
#profilePage .p2p-products-list,
#profilePage .p2p-requests-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#profilePage .p2p-item {
  background: var(--rd-panel);
  border-left: 3px solid var(--rd-border);
  border-radius: 0 12px 12px 0;
  padding: 16px 20px;
}
#profilePage .p2p-item-meta {
  font-size: 0.72em;
  color: var(--rd-text-muted);
  margin-bottom: 5px;
}
#profilePage .p2p-item-title {
  font-weight: 700;
  font-size: 0.875em;
  color: var(--rd-text);
  margin-bottom: 5px;
}
#profilePage .p2p-item-subline {
  font-size: 0.78em;
  color: var(--rd-text-muted);
  margin-bottom: 6px;
}
#profilePage .p2p-item-price {
  color: var(--rd-gold);
  font-weight: 700;
}
#profilePage .p2p-item-status {
  font-size: 0.75em;
  font-weight: 700;
  margin-bottom: 12px;
}
#profilePage .p2p-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
#profilePage .p2p-item-note {
  font-size: 0.8em;
}
#profilePage .p2p-empty {
  text-align: center;
  color: var(--rd-text-muted);
  padding: 20px 0;
}

/* Статусы P2P — та же токен-палитра, что и у статусов заказов */
#profilePage .p2p-status-new { border-left-color: var(--rd-status-new); }
#profilePage .p2p-item-status.p2p-status-new,
#profilePage .p2p-item-note.p2p-status-new { color: var(--rd-status-new); }
#profilePage .p2p-status-done { border-left-color: var(--rd-status-done); }
#profilePage .p2p-item-status.p2p-status-done,
#profilePage .p2p-item-note.p2p-status-done { color: var(--rd-status-done); }
#profilePage .p2p-status-cancelled { border-left-color: var(--rd-status-cancelled); }
#profilePage .p2p-item-status.p2p-status-cancelled,
#profilePage .p2p-item-note.p2p-status-cancelled { color: var(--rd-status-cancelled); }
#profilePage .p2p-status-error { border-left-color: var(--rd-status-error); }
#profilePage .p2p-item-status.p2p-status-error,
#profilePage .p2p-item-note.p2p-status-error { color: var(--rd-status-error); }
#profilePage .p2p-status-pending { border-left-color: var(--rd-status-pending); }
#profilePage .p2p-item-status.p2p-status-pending,
#profilePage .p2p-item-note.p2p-status-pending { color: var(--rd-status-pending); }
#profilePage .p2p-status-progress { border-left-color: var(--rd-status-progress); }
#profilePage .p2p-item-status.p2p-status-progress,
#profilePage .p2p-item-note.p2p-status-progress { color: var(--rd-status-progress); }

#profilePage .p2p-sell-btn {
  background: var(--rd-gold);
  border: none;
  color: oklch(0.15 0.01 85);
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.8em;
  cursor: pointer;
}

#profilePage .p2p-toggle-btn {
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.75em;
  cursor: pointer;
}
#profilePage .p2p-toggle-btn.p2p-status-done { border-color: var(--rd-status-done); color: var(--rd-status-done); }
#profilePage .p2p-toggle-btn.p2p-status-progress { border-color: var(--rd-status-progress); color: var(--rd-status-progress); }
#profilePage .p2p-toggle-btn.p2p-status-new { border-color: var(--rd-status-new); color: var(--rd-status-new); }
#profilePage .p2p-toggle-btn.p2p-status-cancelled { border-color: var(--rd-status-cancelled); color: var(--rd-status-cancelled); }

#profilePage .p2p-action-btn {
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.75em;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#profilePage .p2p-btn-confirm {
  background: oklch(0.5 0.13 150 / 0.3);
  color: oklch(0.7 0.13 150);
}
#profilePage .p2p-btn-cancel {
  background: oklch(0.5 0.15 25 / 0.3);
  color: oklch(0.72 0.15 25);
}
#profilePage .p2p-btn-dispute {
  background: oklch(0.6 0.13 85 / 0.3);
  color: oklch(0.78 0.13 85);
}
#profilePage .p2p-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: oklch(0.4 0.13 240);
  color: #fff;
  border-radius: 8px;
  padding: 0 6px;
  margin-left: 4px;
  font-size: 0.85em;
  font-weight: 700;
}

/* ===== Модалка создания/редактирования P2P-заявки (вкладки "Мои товары"/"Заявки") =====
   Добавляется в document.body, а не внутрь #profilePage — поэтому без скоупа по id. */
.p2p-order-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.p2p-order-modal {
  width: 440px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--rd-panel);
  border: 1px solid var(--rd-border-gold);
  border-radius: 16px;
  padding: 26px;
}
.p2p-order-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.p2p-order-modal-header h3 {
  margin: 0;
  font-weight: 800;
  font-size: 1em;
  color: var(--rd-text);
}
.p2p-order-modal-close {
  background: none;
  border: none;
  color: var(--rd-text-muted);
  font-size: 1.4em;
  cursor: pointer;
  line-height: 1;
}
.p2p-order-field {
  margin-bottom: 14px;
}
.p2p-order-field label {
  display: block;
  font-size: 0.75em;
  color: var(--rd-text-muted);
  margin-bottom: 6px;
}
.p2p-order-field-row {
  display: flex;
  gap: 10px;
}
.p2p-order-checkbox-label {
  display: inline-block;
  margin-right: 15px;
  color: var(--rd-text);
}
.p2p-order-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--rd-border);
  background: var(--rd-panel-header);
  color: var(--rd-text);
  font-size: 0.85em;
  font-family: inherit;
}
.p2p-order-image-preview {
  max-width: 100px;
  max-height: 100px;
  display: block;
  margin-top: 5px;
  border-radius: 6px;
}
.p2p-order-submit-btn {
  width: 100%;
  background: var(--rd-gold);
  border: none;
  color: oklch(0.15 0.01 85);
  font-weight: 700;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.9em;
  cursor: pointer;
  margin-top: 15px;
}
.p2p-order-cancel-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--rd-border);
  color: var(--rd-text-muted);
  font-weight: 700;
  padding: 11px;
  border-radius: 10px;
  font-size: 0.85em;
  cursor: pointer;
  margin-top: 10px;
}

/* ===== Вкладка "Рассылки" (Уведомления по референсу) ===== */
#profilePage .broadcast-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#profilePage .broadcast-item {
  background: var(--rd-panel);
  border: 1px solid var(--rd-border);
  border-radius: 14px;
  padding: 16px 20px;
}
#profilePage .broadcast-item-unread {
  border-left: 3px solid var(--rd-gold);
}
#profilePage .broadcast-subject {
  font-weight: 700;
  font-size: 0.85em;
  color: var(--rd-text);
  margin-bottom: 4px;
}
#profilePage .broadcast-message {
  font-size: 0.78em;
  color: var(--rd-text-muted);
}
#profilePage .broadcast-meta {
  font-size: 0.7em;
  color: var(--rd-text-muted);
  opacity: 0.8;
  margin-top: 8px;
}
#profilePage .broadcast-empty {
  text-align: center;
  color: var(--rd-text-muted);
  padding: 20px 0;
}

/* ===== Мобильный tab-strip (Фаза 5.4) — горизонтальный скролл вместо
   переноса строк, та же логика переключения вкладок (js/profileMain.js),
   меняется только layout/CSS. Тот же приём hidden-scrollbar, что и у
   карусели быстрой покупки (css/quickbuy.css's .quick-games). ===== */
@media (max-width: 600px) {
  #profileTabsRow {
    flex-wrap: nowrap;
    gap: 8px;
  }
  #profilePage .tabs#profileTabs {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  #profilePage .tabs#profileTabs::-webkit-scrollbar {
    display: none;
  }
  #profilePage .tabs#profileTabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  #logoutFromProfileBtn {
    flex-shrink: 0;
    padding: 10px 14px !important;
    white-space: nowrap;
  }
  #profilePage .tabs#p2pSubTabs,
  #profilePage .tabs#orderTabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  #profilePage .tabs#p2pSubTabs::-webkit-scrollbar,
  #profilePage .tabs#orderTabs::-webkit-scrollbar {
    display: none;
  }
  #profilePage .tabs#p2pSubTabs button,
  #profilePage .tabs#orderTabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  #profilePage .profile-header-card {
    padding: 20px 18px;
  }
}
