/* ===== Variables ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --accent: #10b981;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-width: 240px;
  --header-height: 56px;
  --bottom-nav-height: 64px;
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  background: var(--surface);
  transition: border-color var(--transition);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.hidden { display: none !important; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9375rem;
  transition: background var(--transition), transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.875rem;
}

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #1e3a5f 0%, #2563eb 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 24px;
  padding: 40px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-card input {
  margin-bottom: 12px;
}

.login-hint {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ===== App Layout ===== */
.app {
  min-height: 100vh;
}

.app-main {
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.btn-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-back:hover { background: var(--bg); }

.view-container {
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}

/* ===== Sidebar (PC) ===== */
.sidebar {
  display: none;
}

/* ===== Bottom Nav (Mobile) ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 500;
  transition: color var(--transition);
}

.nav-item .nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--primary);
}

/* Sidebar nav items */
.sidebar-nav .nav-item {
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  width: 100%;
}

.sidebar-nav .nav-item.active {
  background: var(--primary-light);
}

.sidebar-sub {
  padding-left: 20px;
}

.sidebar-sub .nav-item {
  font-size: 0.875rem;
  padding: 10px 16px;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ===== Profile Card ===== */
.profile-card {
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.profile-card .member-name {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-card .member-goal {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 16px;
}

.profile-stats {
  display: flex;
  gap: 16px;
}

.profile-stat {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.profile-stat .label {
  font-size: 0.75rem;
  opacity: 0.85;
}

.profile-stat .value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 2px;
}

/* ===== Progress ===== */
.progress-section { margin-bottom: 8px; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  margin-bottom: 6px;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.4s ease;
}

.progress-fill.accent { background: var(--accent); }

/* ===== Schedule ===== */
.schedule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.schedule-item:last-child { border-bottom: none; }

.schedule-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
}

.schedule-icon.pt { background: #fef3c7; }
.schedule-icon.personal { background: #d1fae5; }

.schedule-info .date {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.schedule-info .title {
  font-weight: 600;
}

/* ===== Calendar ===== */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

.calendar-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-nav-btn:hover { background: var(--border); }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.calendar-weekdays span:first-child { color: #ef4444; }
.calendar-weekdays span:last-child { color: #3b82f6; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
}

.calendar-day:hover:not(.empty) { background: var(--bg); }

.calendar-day.empty { cursor: default; }
.calendar-day.today { background: var(--primary-light); font-weight: 700; }
.calendar-day.selected { background: var(--primary); color: #fff; }
.calendar-day.other-month { color: var(--text-secondary); opacity: 0.5; }

.calendar-day .day-markers {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  font-size: 0.5rem;
  line-height: 1;
}

.calendar-detail {
  margin-top: 16px;
}

.calendar-detail-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
  font-size: 0.875rem;
}

/* ===== List Items ===== */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
}

.list-item:active { transform: scale(0.99); }

.list-item-info .date {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.list-item-info .title {
  font-weight: 600;
  margin-top: 2px;
}

.list-item-arrow {
  color: var(--text-secondary);
  font-size: 1.25rem;
}

/* ===== Exercise Detail ===== */
.exercise-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.exercise-item:last-child { border-bottom: none; }

.exercise-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.exercise-item.completed label { text-decoration: line-through; color: var(--text-secondary); }

.exercise-item label {
  font-weight: 600;
  cursor: pointer;
}

.exercise-detail {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.exercise-reason {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-style: italic;
}

.exercise-body { flex: 1; min-width: 0; }

.edit-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  flex-shrink: 0;
  align-self: flex-start;
}

.exercise-edit { margin-top: 6px; }
.exercise-edit .edit-name {
  width: 100%;
  margin-bottom: 6px;
}
.edit-row { display: flex; gap: 6px; }
.edit-actions { display: flex; gap: 6px; margin-top: 8px; }

.condition-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.condition-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
}

.condition-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== PT Detail (Read-only) ===== */
.feedback-box {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 8px;
  font-size: 0.875rem;
  line-height: 1.6;
}

.feedback-box.ai {
  border-left: 3px solid var(--primary);
}

.feedback-box.trainer {
  border-left: 3px solid var(--accent);
}

.feedback-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.readonly-badge {
  display: inline-block;
  font-size: 0.6875rem;
  background: var(--bg);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: 8px;
}

/* ===== Weight Chart ===== */
.weight-current {
  text-align: center;
  margin-bottom: 16px;
}

.weight-current .value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
}

.weight-current .unit {
  font-size: 1rem;
  color: var(--text-secondary);
}

.chart-container {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 16px;
}

.chart-container svg {
  display: block;
  width: 100%;
  height: auto;
}

.weight-input-row {
  display: flex;
  gap: 8px;
}

.weight-input-row input { flex: 1; }
.weight-input-row .btn { width: auto; white-space: nowrap; }

/* ===== 무게/세트/횟수 등 짧은 숫자 입력칸 ===== */
/* 기본 input 패딩(12px 14px)이 좁은 너비와 만나면 border-box 특성상
   실제 입력 가능 영역이 브라우저 숫자 스피너에 다 잠식돼 사실상 입력 불가 상태가 됨.
   짧은 숫자칸 전용 클래스로 패딩을 줄이고 스피너를 숨겨 항상 타이핑 가능하게 함. */
.qty-input {
  width: 56px;
  min-width: 44px;
  padding: 6px 4px;
  text-align: center;
  flex: none;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-input[type="number"] {
  -moz-appearance: textfield;
}

/* ===== Inquiry ===== */
.inquiry-form textarea {
  height: 140px;
  resize: vertical;
  margin-bottom: 12px;
}

.inquiry-history {
  margin-top: 20px;
}

.inquiry-item {
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.inquiry-item .date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.inquiry-item .content {
  font-size: 0.875rem;
}

.inquiry-status {
  display: inline-block;
  font-size: 0.6875rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--primary-light);
  color: var(--primary);
  margin-top: 6px;
}

/* ===== Exercise Hub ===== */
.exercise-hub {
  display: grid;
  gap: 12px;
}

.hub-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
}

.hub-card:active { transform: scale(0.99); }

.hub-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.hub-icon.personal { background: #d1fae5; }
.hub-icon.pt { background: #fef3c7; }

.hub-info h3 {
  font-size: 1rem;
  font-weight: 700;
}

.hub-info p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== PC Layout ===== */
@media (min-width: 900px) {
  .app {
    display: flex;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 20px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
  }

  .brand-icon { font-size: 1.5rem; }

  .sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-secondary);
  }

  .app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding-bottom: 0;
  }

  .bottom-nav { display: none; }

  .view-container {
    max-width: 800px;
    padding: 24px;
  }

  .app-header {
    padding: 0 24px;
  }

  .toast {
    bottom: 32px;
  }
}
