/* ==================== Mobile-First 반응형 CSS ==================== */

/* 기본 모바일 스타일 */
:root {
  --primary-color: #3b82f6;
  --secondary-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --bottom-nav-height: 60px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* 로그인 후 메인 컨테이너 */
#main-container {
  min-height: 100vh;
  padding-bottom: var(--bottom-nav-height);
}

/* 모바일 헤더 */
.mobile-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

.mobile-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* 컨텐츠 영역 */
.content-wrapper {
  padding: 16px;
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
  max-width: 600px;
  margin: 0 auto;
}

/* 하단 탭 네비게이션 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: white;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 30;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 1px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 9px;
  gap: 2px;
  min-width: 0; /* 텍스트 줄바꿈 허용 */
  overflow: visible; /* 아이콘이 잘리지 않도록 */
}

.nav-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-size: 9px;
  line-height: 1.2;
}

.nav-item i {
  font-size: 16px;
  margin-bottom: 1px;
  flex-shrink: 0; /* 아이콘 크기 고정 */
}

/* 화면 폭이 375px 이하일 때 (iPhone SE, 작은 안드로이드) */
@media (max-width: 375px) {
  .nav-item {
    font-size: 8px;
    padding: 3px 0;
  }
  
  .nav-item i {
    font-size: 14px;
  }
  
  .nav-item span {
    font-size: 8px;
  }
}

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

.nav-item:active {
  transform: scale(0.95);
}

/* 카드 스타일 */
.card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text-primary);
}

/* 버튼 스타일 */
.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  text-decoration: none;
  min-height: 44px; /* iOS 터치 타겟 최소 크기 */
  width: 100%;
}

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

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

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

.btn-success {
  background: var(--secondary-color);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

/* 입력 필드 */
.input-field {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 44px; /* iOS 터치 타겟 */
  background: white;
  color: var(--text-primary);
}

.input-field:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 모바일에서 상단 탭 네비게이션 숨김 (회원 대시보드 전용) */
/* 트레이너 대시보드는 .trainer-top-tabs 로 마킹되어 예외 처리됨 —
   모바일에서도 상단 탭을 가로 스크롤로 그대로 노출. */
@media (max-width: 768px) {
  /* 회원 대시보드의 상단 네비게이션 바 숨김 */
  .border-b.border-gray-200 > nav {
    display: none !important;
  }

  /* 상단 네비게이션 전체 컨테이너 숨김 (트레이너 탭은 예외) */
  nav.overflow-x-auto:not(.trainer-top-tabs *) {
    display: none !important;
  }

  /* 데스크톱용 탭 버튼들 숨김 — 단, .trainer-top-tabs 안쪽 버튼은 노출 */
  button[id^="tab-"]:not([id^="bottom-tab-"]) {
    display: none !important;
  }
  .trainer-top-tabs button[id^="tab-"] {
    display: inline-flex !important;
    align-items: center;
  }
}

/* 리스트 아이템 */
.list-item {
  background: white;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
}

/* 스탯 카드 */
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-color);
  display: block;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}

/* 그리드 레이아웃 */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* 모달 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
  padding: 0;
}

.modal-content {
  background: white;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* 태블릿 이상 (768px+) */
@media (min-width: 768px) {
  .content-wrapper {
    max-width: 800px;
    padding: 24px;
  }

  .mobile-header h1 {
    font-size: 20px;
  }

  .grid-2 {
    gap: 16px;
  }

  .grid-3 {
    gap: 16px;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal-content {
    max-width: 500px;
    border-radius: 20px;
    max-height: 80vh;
  }
}

/* 데스크톱 (1024px+) */
@media (min-width: 1024px) {
  .content-wrapper {
    max-width: 1200px;
    padding: 32px;
  }

  .bottom-nav {
    display: none; /* PC에서는 사이드바 사용 */
  }

  #main-container {
    padding-bottom: 0;
  }

  .grid-3 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 로딩 스피너 */
.spinner {
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 알림 메시지 */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  border-left: 4px solid;
}

.alert-success {
  background: #d1fae5;
  border-color: var(--secondary-color);
  color: #065f46;
}

.alert-error {
  background: #fee2e2;
  border-color: var(--danger-color);
  color: #991b1b;
}

.alert-warning {
  background: #fef3c7;
  border-color: var(--warning-color);
  color: #92400e;
}

.alert-info {
  background: #dbeafe;
  border-color: var(--primary-color);
  color: #1e40af;
}

/* 뱃지 */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-primary {
  background: #dbeafe;
  color: var(--primary-color);
}

.badge-success {
  background: #d1fae5;
  color: var(--secondary-color);
}

.badge-danger {
  background: #fee2e2;
  color: var(--danger-color);
}

.badge-warning {
  background: #fef3c7;
  color: var(--warning-color);
}

/* 유틸리티 클래스 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.hidden { display: none; }
.block { display: block; }

/* 식단 기록 카드 */
.meal-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.meal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.meal-type {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-color);
}

.meal-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.meal-photo {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
}

.meal-info {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.meal-stat {
  text-align: center;
}

.meal-stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.meal-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* 포인트 카드 */
.point-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}

.point-balance {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.point-label {
  font-size: 14px;
  opacity: 0.9;
}

/* 챌린지 카드 */
.challenge-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary-color);
}

.challenge-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.challenge-progress {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0;
}

.challenge-progress-bar {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.3s ease;
}

/* 만보기 원형 진행률 */
.step-circle {
  width: 200px;
  height: 200px;
  margin: 0 auto;
  position: relative;
}

.step-circle-progress {
  transform: rotate(-90deg);
}

.step-count {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.step-count-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary-color);
}

.step-count-label {
  font-size: 14px;
  color: var(--text-secondary);
}

/* PC 대응: 사이드바 네비게이션 */
@media (min-width: 1024px) {
  #main-container {
    display: flex;
  }

  .sidebar {
    width: 250px;
    min-height: 100vh;
    background: white;
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }

  .sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .sidebar-nav-item {
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    text-decoration: none;
  }

  .sidebar-nav-item:hover {
    background: var(--bg-secondary);
  }

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

  .sidebar-nav-item i {
    font-size: 18px;
  }

  .main-content {
    flex: 1;
    overflow-y: auto;
  }
}
