/* ── 마이 페이지 스타일 ── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #f8f9fc 0%, #f0f1f5 100%);
  color: #1d1d1f;
  min-height: 100vh;
  padding: 0;
}

/* ── Top Navigation ── */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e5e5ea;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #1d1d1f;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: #6e6e73;
  text-decoration: none;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
  color: #1d1d1f;
  background: #f0f0f5;
}

.nav-link.active {
  color: #2563eb;
  font-weight: 600;
}

.nav-user {
  font-size: 0.82rem;
  color: #48484a;
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn-logout {
  background: none;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #8e8e93;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn-logout:hover {
  color: #ff3b30;
  border-color: #ff3b30;
}

/* ── Container ── */
.my-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ── Loading ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 1rem;
  color: #8e8e93;
  font-size: 0.9rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e5ea;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Credit Summary Card ── */
.credit-summary-card {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-radius: 16px;
  padding: 1.5rem;
  color: #fff;
  margin-bottom: 1rem;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.25);
}

.credit-summary-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.credit-balance {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.credit-balance-num {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.credit-balance-unit {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.8;
}

.credit-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.credit-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.credit-stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.7;
}

.credit-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.credit-stat-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.25);
}

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid #e8e8ed;
  border-radius: 14px;
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.card-header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #f0f0f5;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1d1d1f;
}

/* ── Empty State ── */
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: #aeaeb2;
  font-size: 0.85rem;
}

/* ── Data Tables ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table thead th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #fafafa;
  border-bottom: 1px solid #e8e8ed;
  white-space: nowrap;
}

.data-table tbody td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f0f0f5;
  color: #3a3a3c;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #fafbff;
}

/* ── Credit type badges ── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-earn {
  background: #ecfdf5;
  color: #059669;
}

.badge-use {
  background: #fef2f2;
  color: #dc2626;
}

.badge-refund {
  background: #eff6ff;
  color: #2563eb;
}

/* ── Status badges ── */
.status-success {
  color: #059669;
  font-weight: 600;
}

.status-error {
  color: #dc2626;
  font-weight: 600;
}

.status-started {
  color: #f59e0b;
  font-weight: 600;
}

.status-expired {
  color: #9ca3af;
  font-weight: 600;
}

/* ── Action buttons in table ── */
.action-btn {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.action-btn-download {
  background: #eff6ff;
  color: #2563eb;
}

.action-btn-download:hover {
  background: #dbeafe;
}

.action-btn-editor {
  background: #f5f3ff;
  color: #7c3aed;
}

.action-btn-editor:hover {
  background: #ede9fe;
}

.action-btn:disabled,
.action-expired {
  background: #f5f5f7;
  color: #aeaeb2;
  cursor: default;
  pointer-events: none;
}

.action-expired {
  font-size: 0.7rem;
  font-weight: 500;
}

.action-group {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* ── Settings ── */
.settings-body {
  padding: 1rem 1.25rem;
}

.setting-group {
  margin-bottom: 0;
}

.setting-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 0.25rem;
}

.setting-desc {
  font-size: 0.78rem;
  color: #8e8e93;
  margin-bottom: 0.6rem;
}

.setting-divider {
  border: none;
  border-top: 1px solid #f0f0f5;
  margin: 1.25rem 0;
}

/* Model select buttons */
.model-select-group {
  display: flex;
  gap: 0.4rem;
}

.model-select-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #d2d2d7;
  border-radius: 8px;
  background: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  color: #6e6e73;
  cursor: pointer;
  transition: all 0.2s;
}

.model-select-btn:hover {
  border-color: #aaa;
  color: #1d1d1f;
}

.model-select-btn.active {
  border-color: #2563eb;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.setting-saved {
  font-size: 0.75rem;
  color: #059669;
  font-weight: 500;
  margin-top: 0.4rem;
}

/* Password form */
.password-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
}

.setting-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid #d1d1d6;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.setting-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-primary-sm {
  display: inline-block;
  padding: 0.55rem 1.2rem;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
  width: fit-content;
}

.btn-primary-sm:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary-sm:disabled {
  background: #c7c7cc;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.setting-message {
  font-size: 0.78rem;
  min-height: 1.2em;
}

.setting-message.success {
  color: #059669;
}

.setting-message.error {
  color: #ff3b30;
}

/* ── Amount display ── */
.amount-positive {
  color: #059669;
  font-weight: 600;
}

.amount-negative {
  color: #dc2626;
  font-weight: 600;
}

/* ── File name truncation in table ── */
.file-name-cell {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .top-nav {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }

  .nav-logo span {
    display: none;
  }

  .nav-links {
    gap: 0.4rem;
  }

  .nav-user {
    display: none;
  }

  .nav-link {
    font-size: 0.78rem;
    padding: 0.25rem 0.4rem;
  }

  .my-container {
    padding: 1rem 0.75rem 2rem;
  }

  .credit-balance-num {
    font-size: 2rem;
  }

  .hide-mobile {
    display: none;
  }

  .data-table {
    font-size: 0.75rem;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 0.5rem;
  }

  .model-select-group {
    flex-direction: column;
  }

  .file-name-cell {
    max-width: 100px;
  }
}

/* ── Focus rings ── */
:focus-visible {
  outline: 2px solid #0071e3;
  outline-offset: 2px;
}

button:focus-visible {
  outline: 2px solid #0071e3;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
