/**
 * Стили страницы профиля (Личный кабинет)
 * Цвета и типографика — см. docs/PROFILE_DESIGN.md
 */

/* --- Переменные страницы профиля (алиасы к основной палитре) --- */
.profile-page {
  --profile-bg: var(--bg);
  --profile-paper: var(--bg);
  --profile-charcoal: var(--text);
  --profile-muted: var(--text-muted);
  --profile-border: var(--border);
  --profile-brand: var(--accent);
  --profile-font-sans: var(--font);
  --profile-font-serif: var(--font-heading);
}

body.profile-page {
  min-height: 100vh;
  background-color: var(--profile-bg);
  font-family: var(--profile-font-sans);
  color: var(--profile-charcoal);
  -webkit-font-smoothing: antialiased;
}

/* --- Контейнер контента профиля (JS переключает display: grid) --- */
#profile-content {
  display: none;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: 64rem;
  margin-left: auto;
  margin-right: auto;
  padding-bottom: 4rem;
}

#profile-content.profile-content-visible {
  display: grid;
}

/* Двухколоночная сетка на десктопе */
.profile-grid-inner {
  display: grid;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .profile-grid-inner {
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
  }
}

.profile-section-hero { order: 1; }
.profile-section-actions { order: 2; }

/* --- Hero-карточка (аватар, уровень, XP, статистика) --- */
.profile-hero-card {
  position: relative;
  border: 1px solid var(--profile-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  padding: 1.5rem;
  box-shadow: none;
}

@media (min-width: 640px) {
  .profile-hero-card {
    padding: 2rem;
  }
}

/* Кнопка настроек в углу hero-карточки */
.profile-hero-actions {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-hero-settings-btn,
.profile-hero-logout-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--profile-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.profile-hero-settings-btn:hover,
.profile-hero-logout-btn:hover {
  color: var(--profile-charcoal);
  background: rgba(26, 26, 26, 0.06);
}

.profile-hero-logout-btn:hover {
  color: var(--accent-red);
}

.profile-hero-settings-btn:focus-visible,
.profile-hero-logout-btn:focus-visible {
  outline: 2px solid var(--profile-brand);
  outline-offset: 2px;
}

.profile-hero-settings-btn i,
.profile-hero-logout-btn i {
  font-size: 1.25rem;
}

/* Блок идентичности: аватар + имя */
.profile-hero-identity {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--profile-border);
}

@media (min-width: 640px) {
  .profile-hero-identity {
    gap: 1.25rem;
  }
}

#profile-avatar {
  width: 4rem;
  height: 4rem;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--profile-font-sans);
  font-weight: 600;
  font-size: 1.25rem;
  background-color: rgba(24, 138, 0, 0.12);
  color: var(--profile-brand);
}

@media (min-width: 640px) {
  #profile-avatar {
    width: 5rem;
    height: 5rem;
  }
}

#profile-content #profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-hero-meta {
  min-width: 0;
}

#profile-name {
  font-family: var(--profile-font-sans);
  font-weight: 600;
  color: var(--profile-charcoal);
  font-size: 1.125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 640px) {
  #profile-name {
    font-size: 1.25rem;
  }
}

#profile-plan {
  font-family: var(--profile-font-sans);
  color: var(--profile-muted);
  font-size: 0.875rem;
  margin-top: 0.125rem;
}

.profile-level-line {
  font-family: var(--profile-font-serif);
  color: rgba(26, 26, 26, 0.8);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

@media (min-width: 640px) {
  .profile-level-line {
    font-size: 1rem;
  }
}

#profile-level {
  font-weight: 600;
  color: var(--profile-brand);
}

.profile-level-line .profile-level-sep {
  color: var(--profile-muted);
}

/* Блок XP */
.profile-xp-block {
  margin-bottom: 1.5rem;
}

.profile-xp-label {
  font-family: var(--profile-font-sans);
  color: var(--profile-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.profile-xp-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}

#profile-xp-text {
  font-family: var(--profile-font-sans);
  font-weight: 500;
  color: var(--profile-charcoal);
  font-variant-numeric: tabular-nums;
}

.profile-xp-suffix {
  font-family: var(--profile-font-sans);
  color: var(--profile-muted);
  font-size: 0.75rem;
}

.profile-xp-track {
  height: 0.625rem;
  background-color: var(--profile-border);
  border-radius: 9999px;
  overflow: hidden;
}

#profile-xp-fill {
  height: 100%;
  border-radius: 9999px;
  background-color: var(--profile-brand);
  transition: width 0.5s ease;
}

/* Подзаголовок перед статистикой */
.profile-stats-label {
  font-family: var(--profile-font-sans);
  color: var(--profile-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

/* Карточки статистики (flip при наведении — см. style.css .stat-card) */
.profile-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

#profile-content .profile-stat-card {
  min-width: 0;
  flex: 1;
  border-radius: 12px;
  padding: 0.875rem 1rem;
  text-align: center;
}

#profile-content .stat-card.profile-stat-card {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--profile-border);
  min-height: 80px;
  overflow: hidden;
}

#profile-content .profile-stat-card .stat-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#profile-content .profile-stat-card .stat-label {
  color: var(--profile-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.125rem;
}

#profile-content .profile-stat-card[data-color="green"] .stat-card-back { background: var(--profile-brand); }
#profile-content .profile-stat-card[data-color="orange"] .stat-card-back { background: var(--green-light); }
#profile-content .profile-stat-card[data-color="cyan"] .stat-card-back { background: var(--green-dark); }

#profile-content .profile-stat-card .stat-card-back {
  border-radius: 12px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  padding: 8px;
}

.profile-stat-value {
  display: block;
  font-family: var(--profile-font-sans);
  font-weight: 600;
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
}

.profile-stat-value--brand {
  color: var(--profile-brand);
}

.profile-stat-value--charcoal {
  color: var(--profile-charcoal);
}

/* --- Блок «Усильте ассистента» --- */
.profile-powerup-card {
  border: 1px solid rgba(24, 138, 0, 0.25);
  border-radius: 12px;
  background: #fff;
  padding: 1.5rem;
}

@media (min-width: 640px) {
  .profile-powerup-card {
    padding: 2rem;
  }
}

.profile-powerup-title {
  font-family: var(--profile-font-serif);
  color: var(--profile-charcoal);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

@media (min-width: 640px) {
  .profile-powerup-title {
    font-size: 1.5rem;
  }
}

.profile-powerup-desc {
  font-family: var(--profile-font-sans);
  color: var(--profile-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* Персонализация внутри блока «Усильте ассистента» */
.profile-personalization {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--profile-border);
  background: rgba(255, 255, 255, 0.6);
}

.profile-personalization-title {
  font-family: var(--profile-font-serif);
  color: var(--profile-charcoal);
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 0.25rem 0;
}

.profile-personalization-desc {
  font-family: var(--profile-font-sans);
  color: var(--profile-muted);
  font-size: 0.875rem;
  margin: 0 0 0.75rem 0;
}

.profile-personalization-actions {
  margin-top: 0.5rem;
}

.profile-personalization-link {
  font-family: var(--profile-font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--profile-brand);
  text-decoration: none;
}

.profile-personalization-link:hover {
  text-decoration: underline;
}

.profile-integration-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Карточка интеграции (как в настройках «Связи», в стиле профиля) */
.profile-integration-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--profile-border);
  border-radius: 12px;
  background: var(--profile-paper);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-integration-card:hover {
  border-color: rgba(24, 138, 0, 0.35);
  box-shadow: 0 2px 8px rgba(24, 138, 0, 0.06);
}

@media (min-width: 640px) {
  .profile-integration-card {
    padding: 1.25rem 1.5rem;
  }
}

.profile-integration-card-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-integration-card-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--profile-font-sans);
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}

.profile-integration-card-icon--google {
  background: #1a1b1e;
  color: #fff;
}

.profile-integration-card-title {
  font-family: var(--profile-font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--profile-charcoal);
  display: block;
}

.profile-integration-card-desc {
  font-family: var(--profile-font-sans);
  font-size: 0.875rem;
  color: var(--profile-muted);
  display: block;
  margin-top: 2px;
}

.profile-integration-card-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.profile-integration-card-action .profile-btn-connect {
  min-height: 44px;
}

@media (max-width: 639px) {
  .profile-integration-card {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .profile-integration-card-action {
    justify-content: flex-start;
  }
  .profile-integration-card-action .profile-btn-connect {
    width: 100%;
  }
}

.profile-integration-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--profile-border);
  background: var(--profile-paper);
}

@media (min-width: 640px) {
  .profile-integration-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.profile-integration-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-integration-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--profile-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--profile-font-sans);
  font-weight: 700;
  color: var(--profile-charcoal);
}

.profile-integration-icon--telegram {
  background: rgba(0, 136, 204, 0.1);
  color: #0088cc;
}

.profile-integration-title {
  font-family: var(--profile-font-sans);
  font-weight: 600;
  color: var(--profile-charcoal);
  display: block;
}

.profile-integration-desc {
  font-family: var(--profile-font-sans);
  color: var(--profile-muted);
  font-size: 0.875rem;
}

.profile-integration-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.profile-btn-connect {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0 1.5rem;
  font-family: var(--profile-font-sans);
  font-weight: 500;
  font-size: 1rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  background-color: var(--profile-brand);
  color: #fff;
  text-decoration: none;
  box-sizing: border-box;
}

.profile-btn-connect:hover {
  opacity: 0.9;
}

@media (min-width: 640px) {
  .profile-btn-connect {
    width: auto;
  }
}

.profile-btn-connect--secondary {
  width: 100%;
  background: transparent;
  color: var(--profile-charcoal);
  border: 1px solid rgba(26, 26, 26, 0.2);
}

.profile-btn-connect--secondary:hover {
  background: rgba(26, 26, 26, 0.05);
}

@media (min-width: 640px) {
  .profile-btn-connect--secondary {
    width: auto;
  }
}

/* Бейдж «Подключено» на карточке Google (как в настройках, в стиле профиля) */
.profile-integration-card .google-badge-connected,
.profile-page .badge-success.google-badge-connected {
  font-family: var(--profile-font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(24, 138, 0, 0.15);
  color: var(--profile-brand);
  display: inline-block;
}

/* --- Блок промокода --- */
.profile-promo-card {
  margin-top: 1.5rem;
  border: 1px solid var(--profile-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  padding: 1.25rem 1.5rem;
}

@media (min-width: 640px) {
  .profile-promo-card {
    padding: 1.5rem 2rem;
  }
}

.profile-promo-title {
  font-family: var(--profile-font-serif);
  color: var(--profile-charcoal);
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}

.profile-promo-desc {
  font-family: var(--profile-font-sans);
  color: var(--profile-muted);
  font-size: 0.875rem;
  margin: 0 0 1rem 0;
}

.profile-promo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.profile-promo-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 1rem;
  font-family: var(--profile-font-sans);
  font-size: 1rem;
  border: 1px solid var(--profile-border);
  border-radius: 12px;
  background: #fff;
  color: var(--profile-charcoal);
  transition: border-color 0.2s;
}

.profile-promo-input::placeholder {
  color: var(--profile-muted);
}

.profile-promo-input:focus {
  outline: none;
  border-color: var(--profile-brand);
}

.profile-promo-btn {
  min-height: 44px;
  padding: 0 1.25rem;
  font-family: var(--profile-font-sans);
  font-weight: 500;
  font-size: 0.9375rem;
  border: none;
  border-radius: 12px;
  background: var(--profile-brand);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s;
}

.profile-promo-btn:hover {
  opacity: 0.9;
}

.profile-promo-message {
  font-family: var(--profile-font-sans);
  font-size: 0.875rem;
  margin: 0.5rem 0 0 0;
  color: var(--profile-muted);
}

.profile-promo-message--error {
  color: var(--accent-red);
}

/* Модальное окно: пробная неделя активирована */
.profile-promo-success-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(26, 26, 26, 0.4);
}

.profile-promo-success-modal {
  max-width: 22rem;
  width: 100%;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--profile-border);
}

.profile-promo-success-content {
  padding: 2rem 1.5rem;
  text-align: center;
}

.profile-promo-success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: rgba(24, 138, 0, 0.15);
  color: var(--profile-brand);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.profile-promo-success-title {
  font-family: var(--profile-font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--profile-charcoal);
  margin: 0 0 0.5rem 0;
}

.profile-promo-success-text {
  font-family: var(--profile-font-sans);
  font-size: 0.9375rem;
  color: var(--profile-muted);
  margin: 0 0 1.5rem 0;
}

.profile-promo-success-close {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-family: var(--profile-font-sans);
  font-weight: 500;
  font-size: 1rem;
  border: none;
  border-radius: 12px;
  background: var(--profile-brand);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.2s;
}

.profile-promo-success-close:hover {
  opacity: 0.9;
}

/* Утилиты (для JS: показ/скрытие) */
.hidden {
  display: none !important;
}
