/**
 * mypage.css — 마이페이지 전용 디자인 시스템
 *
 * 원칙: Apple 미니멀 + 한국 사주 톤 (cream/gold/charcoal)
 *  - 글로우/네온/화려한 그래디언트 금지 (AI티 제거)
 *  - 정보 위계 명확 (제목 Serif KR / 본문 sans)
 *  - 모바일 first: 결제내역/분석이력 테이블 → 카드 stack
 *  - 텍스트 overflow 방어 (긴 이메일/주문번호/order_id break-all)
 */

/* ============================================================
 *  헤더 / 타이포그래피 위계
 * ============================================================ */
.mypage-page {
  padding: 32px 16px 16px;
  max-width: 920px;
  margin: 0 auto;
}

.mypage__hero {
  text-align: center;
  margin-bottom: 36px;
  padding: 0 8px;
}

.mypage__kicker {
  display: inline-block;
  font-family: 'Noto Serif KR', serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: #8C5E2A;
  text-transform: uppercase;
  padding: 6px 16px;
  background: rgba(196, 151, 92, 0.1);
  border: 1px solid rgba(166, 123, 66, 0.28);
  border-radius: 999px;
  margin-bottom: 16px;
}

.mypage__title {
  font-family: 'Noto Serif KR', serif;
  font-size: 32px;
  font-weight: 700;
  color: #14100D;
  letter-spacing: -0.025em;
  line-height: 1.18;
  margin: 0;
}

.mypage__subtitle {
  font-size: 13px;
  color: #6B5F57;
  margin-top: 10px;
  line-height: 1.6;
  font-weight: 500;
}

/* ============================================================
 *  통계 row — 분석 N회 / 리포트 N개 / D+N
 * ============================================================ */
.mypage__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 28px;
  padding: 0 4px;
}

.stat {
  background: #FFFFFF;
  border: 1px solid #E8E2D6;
  border-radius: 14px;
  padding: 18px 12px;
  text-align: center;
  box-shadow:
    0 1px 2px rgba(26, 20, 16, 0.04),
    0 8px 20px -12px rgba(166, 123, 66, 0.12);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(166, 123, 66, 0.5), transparent);
}

.stat__value {
  font-family: 'Noto Serif KR', serif;
  font-size: 24px;
  font-weight: 700;
  color: #14100D;
  letter-spacing: -0.025em;
  line-height: 1.1;
  display: block;
  margin-bottom: 5px;
}

.stat__label {
  font-size: 11px;
  font-weight: 700;
  color: #6B5F57;
  letter-spacing: 0.06em;
}

/* ============================================================
 *  카드 컨테이너
 * ============================================================ */
.mypage__grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.mypage-card {
  background: #FFFFFF;
  border: 1px solid #E8E2D6;
  border-radius: 16px;
  padding: 26px;
  box-shadow:
    0 1px 2px rgba(26, 20, 16, 0.04),
    0 12px 32px -16px rgba(26, 20, 16, 0.08);
  position: relative;
}

.mypage-card__title {
  font-family: 'Noto Serif KR', serif;
  font-size: 19px;
  font-weight: 700;
  color: #14100D;
  letter-spacing: -0.018em;
  margin: 0 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #EDE8DF;
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.3;
}

.mypage-card__title-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(196, 151, 92, 0.14), rgba(166, 123, 66, 0.08));
  border: 1px solid rgba(166, 123, 66, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mypage-card__title-icon svg {
  width: 18px;
  height: 18px;
  color: #A67B42;
}

/* legacy: title 안에 svg 직접 있을 때 */
.mypage-card__title > svg {
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(196, 151, 92, 0.14), rgba(166, 123, 66, 0.08));
  border: 1px solid rgba(166, 123, 66, 0.18);
  color: #A67B42;
  flex-shrink: 0;
  box-sizing: border-box;
}

.mypage-card__title-meta {
  margin-left: auto;
  font-family: 'NanumSquareRound', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #6B5F57;
  letter-spacing: 0.06em;
  background: #FAF7F2;
  border: 1px solid #EDE8DF;
  padding: 4px 10px;
  border-radius: 999px;
}

/* ============================================================
 *  프로필 info — 라벨/값 stack (긴 이메일 break-all)
 * ============================================================ */
.profile-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}

.profile-field {
  background: #FBF8F2;
  border: 1px solid #EDE8DF;
  border-radius: 12px;
  padding: 14px 16px;
}

.profile-field__label {
  font-size: 10px;
  font-weight: 700;
  color: #8B7E72;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.profile-field__value {
  font-size: 15px;
  font-weight: 600;
  color: #14100D;
  line-height: 1.45;
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* ============================================================
 *  프리미엄 리포트 카드 그리드
 * ============================================================ */
.premium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.premium-card-wrap { position: relative; }

.premium-card {
  position: relative;
  display: block;
  padding: 22px 22px 20px;
  background: #15110D;
  border: 1px solid rgba(212, 175, 55, 0.32);
  border-radius: 8px;
  text-decoration: none;
  color: #F5EBDA;
  min-height: 148px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.premium-card:hover,
.premium-card:focus-visible {
  transform: translateY(-2px);
  border-color: #D4AF37;
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.14);
}

.premium-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.6), transparent);
}

.premium-card__kicker {
  font-family: 'Noto Serif KR', serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #D4AF37;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.premium-card__name {
  font-family: 'Noto Serif KR', serif;
  font-size: 19px;
  font-weight: 700;
  color: #F5EBDA;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.premium-card__birth {
  font-size: 12px;
  color: #A79B85;
  letter-spacing: 0.02em;
  margin: 0 0 14px;
}

.premium-card__preview {
  font-size: 13px;
  color: #C8BCA3;
  line-height: 1.7;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: keep-all;
}

.premium-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.premium-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #D4AF37;
  letter-spacing: 0.1em;
}

.premium-card__cta::after {
  content: '→';
  transition: transform 0.18s;
}

.premium-card:hover .premium-card__cta::after {
  transform: translateX(3px);
}

.premium-card__meta-time {
  font-size: 10px;
  color: #756A56;
  letter-spacing: 0.05em;
}

.premium-card__share {
  position: absolute;
  bottom: 18px;
  right: 18px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: #D4AF37;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.premium-card__share:hover {
  background: #D4AF37;
  color: #0E0B09;
}

.premium-card__badge {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 3px 8px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 2px;
  font-size: 9px;
  font-weight: 700;
  color: #D4AF37;
  letter-spacing: 0.18em;
}

.premium-card--generating {
  background: #1A1612;
  border-color: rgba(212, 175, 55, 0.18);
}

.premium-card--generating .premium-card__badge {
  color: #C0AE7D;
  border-color: rgba(192, 174, 125, 0.32);
}

.premium-grid__empty {
  grid-column: 1 / -1;
  padding: 40px 20px;
  text-align: center;
  color: #5C5450;
  font-size: 14px;
  line-height: 1.75;
  border: 1px dashed #D9D0C0;
  border-radius: 12px;
  background: #FBF8F2;
  font-weight: 500;
}

.premium-grid__empty strong {
  display: block;
  color: #14100D;
  margin-bottom: 8px;
  font-weight: 800;
  font-family: 'Noto Serif KR', serif;
  font-size: 15px;
}

/* ============================================================
 *  분석 이력 / 결제 내역
 *  - 데스크톱 (≥640px): 테이블
 *  - 모바일 (<640px): 카드 stack (텍스트 overflow 방어)
 * ============================================================ */
.history-table { width: 100%; border-collapse: collapse; }

.history-table thead th {
  font-size: 11px;
  font-weight: 700;
  color: #6B5F57;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #EDE8DF;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #FBF8F2;
}

.history-table tbody td {
  font-size: 13.5px;
  color: #2C2420;
  padding: 14px;
  border-bottom: 1px solid #F4F0E9;
  vertical-align: middle;
  word-break: keep-all;
  overflow-wrap: anywhere;
  font-weight: 500;
}

.history-table tbody tr:hover { background: #FCFAF6; }
.history-table tbody tr:last-child td { border-bottom: none; }

.history-table .history-table__order-id {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 11.5px;
  color: #4C4440;
  word-break: break-all;
  font-weight: 600;
}

.history-table__cell-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #A67B42;
  text-decoration: none;
}

.history-table__cell-link:hover { text-decoration: underline; }

/* 결제 status badge — 5/11 사고 fix (CSS 누락이라 안 보였음) */
.status {
  display: inline-block;
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.3;
  border: 1px solid transparent;
}
.status--complete {
  background: #E6F4EA;
  color: #2F6B2A;
  border-color: rgba(47, 107, 42, 0.18);
}
.status--refunded {
  background: #FCEAEA;
  color: #B03B3B;
  border-color: rgba(176, 59, 59, 0.18);
}
.status--pending {
  background: #FFF4DA;
  color: #8A6A1F;
  border-color: rgba(184, 134, 11, 0.22);
}

/* 모바일 카드 (기본 hidden, ≤640px 에서만 표시) */
.history-cards { display: none; flex-direction: column; gap: 12px; }

.history-card-item {
  background: #FBF8F2;
  border: 1px solid #E8E2D6;
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 0 rgba(26, 20, 16, 0.02);
}

.history-card-item__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.history-card-item__title {
  font-size: 15px;
  font-weight: 700;
  color: #14100D;
  line-height: 1.4;
  word-break: keep-all;
  flex: 1;
  min-width: 0;
  letter-spacing: -0.01em;
}

.history-card-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12.5px;
  color: #5C5450;
  line-height: 1.5;
  font-weight: 500;
}

.history-card-item__meta strong {
  color: #14100D;
  font-weight: 700;
}

.history-card-item__order-id {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 11.5px;
  color: #6B5F57;
  word-break: break-all;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.history-card-item__actions {
  display: flex;
  gap: 14px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid #EDE8DF;
}

.history-card-item__action {
  font-size: 12.5px;
  font-weight: 800;
  color: #A67B42;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.history-card-item__action--mute {
  color: #6B5F57;
  font-weight: 600;
}

.history-card-item__action::after {
  content: ' →';
  transition: transform 0.18s;
}

/* ============================================================
 *  뱃지 + 상태
 * ============================================================ */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.badge--free { background: rgba(59, 107, 138, 0.14); color: #2D5673; }
.badge--premium { background: rgba(196, 151, 92, 0.16); color: #8C5E2A; }
.badge--vip { background: rgba(162, 59, 59, 0.14); color: #9B3838; }

.status {
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
}

.status--complete { color: #2F6648; }
.status--refunded { color: #6B5F57; }
.status--pending { color: #8C5E2A; }

/* ============================================================
 *  계정 관리 (비번 변경 / 로그아웃 / 탈퇴)
 * ============================================================ */
.pw-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
}

.pw-form__field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #6B5F57;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.pw-form__field input {
  width: 100%;
  padding: 12px 14px;
  background: #FAF7F2;
  border: 1px solid #EEEBE6;
  border-radius: 10px;
  color: #2C2420;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.18s, background 0.18s;
}

.pw-form__field input:focus {
  outline: none;
  border-color: #A67B42;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(166, 123, 66, 0.08);
}

.pw-form__btn {
  align-self: flex-start;
  padding: 11px 22px;
  background: #FAF7F2;
  border: 1px solid #EEEBE6;
  border-radius: 10px;
  color: #2C2420;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}

.pw-form__btn:hover {
  border-color: #A67B42;
  color: #A67B42;
  background: #FFFFFF;
}

.account-actions {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-action__btn {
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 1px solid #E8E2D6;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  color: #4C4440;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}

.account-action__btn:hover {
  border-color: #A67B42;
  color: #A67B42;
  background: #FBF8F2;
}

.danger-zone {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px dashed rgba(162, 59, 59, 0.18);
}

.danger-zone__desc {
  font-size: 12.5px;
  color: #5C5450;
  margin-bottom: 14px;
  line-height: 1.75;
  font-weight: 500;
}

.danger-zone__btn {
  padding: 10px 18px;
  background: transparent;
  border: 1px solid rgba(162, 59, 59, 0.32);
  border-radius: 10px;
  color: #C45B5B;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s, border-color 0.18s;
}

.danger-zone__btn:hover {
  background: rgba(162, 59, 59, 0.06);
  border-color: #C45B5B;
}

/* ============================================================
 *  빈 상태 + 스켈레톤
 * ============================================================ */
.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: #5C5450;
  font-size: 13.5px;
  line-height: 1.75;
  font-weight: 500;
}

.skeleton {
  display: inline-block;
  height: 1rem;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #F4F0E9 25%, #E8E2D6 50%, #F4F0E9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
 *  반응형: 모바일 (≤640px)
 *  - profile-info 1column
 *  - 통계 row 폰트 축소
 *  - history-table 숨김 + history-cards 표시
 *  - 카드 padding 축소
 * ============================================================ */
@media (max-width: 640px) {
  .mypage-page { padding: 26px 14px 16px; }

  .mypage__hero { margin-bottom: 24px; }
  .mypage__title { font-size: 28px; }
  .mypage__subtitle { font-size: 12.5px; }

  .mypage__stats { gap: 8px; margin-bottom: 22px; }
  .stat { padding: 16px 10px; border-radius: 12px; }
  .stat__value { font-size: 21px; }
  .stat__label { font-size: 10.5px; }

  .mypage-card { padding: 22px 20px; border-radius: 14px; }
  .mypage-card__title {
    font-size: 17px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    gap: 10px;
  }
  .mypage-card__title > svg,
  .mypage-card__title-icon { width: 32px; height: 32px; }
  .mypage-card__title > svg { padding: 7px; }

  .profile-info { grid-template-columns: 1fr; gap: 12px; }
  .profile-field { padding: 13px 14px; }
  .profile-field__value { font-size: 14.5px; }

  .premium-grid { grid-template-columns: 1fr; gap: 12px; }
  .premium-card { padding: 22px 20px 20px; min-height: auto; }
  .premium-card__name { font-size: 18px; }

  /* 테이블 숨기고 카드 stack 사용 */
  .table-wrap { display: none; }
  .history-cards { display: flex; }

  .pw-form__btn { width: 100%; align-self: stretch; }
}

/* Z Flip / 매우 작은 화면 (≤360px) */
@media (max-width: 360px) {
  .mypage-page { padding: 22px 12px 12px; }
  .mypage__title { font-size: 26px; }
  .mypage__stats { grid-template-columns: 1fr 1fr; }
  .mypage__stats .stat:last-child {
    grid-column: 1 / -1;
  }
  .mypage-card { padding: 20px 16px; border-radius: 14px; }
  .mypage-card__title { font-size: 16px; }
  .mypage-card__title-meta { display: none; }
}

/* ============================================================
 *  데스크톱: 테이블 vs 카드 분기 (위 모바일 미디어 쿼리 외 영역)
 * ============================================================ */
@media (min-width: 641px) {
  .table-wrap { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .history-cards { display: none; }
}
