/**
 * Dealy - 메인 스타일시트
 * 모바일 우선 디자인
 */

/* ========== 리셋 및 기본 설정 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Safe Area Insets (노치/Dynamic Island 대응) */
:root {
  /* iOS Safe Area 변수 */
  --safe-area-inset-top: env(safe-area-inset-top);
  --safe-area-inset-right: env(safe-area-inset-right);
  --safe-area-inset-bottom: env(safe-area-inset-bottom);
  --safe-area-inset-left: env(safe-area-inset-left);
  
  /* 색상 변수 */
  /* 컬러 시스템 (스크린샷 기반) */
  --primary: #00D9A3;
  --primary-dark: #00A378;
  --primary-light: #33E3B3;
  
  --danger: #FF4D6D;
  --danger-light: #FFE5EA;
  
  --success: #00D9A3;
  --success-light: #E5F9F3;
  
  --warning: #FFA726;
  --warning-light: #FFF3E0;
  
  /* 그레이스케일 */
  --gray-50: #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #EEEEEE;
  --gray-300: #E0E0E0;
  --gray-400: #BDBDBD;
  --gray-500: #9E9E9E;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;
  
  /* 텍스트 */
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --text-inverse: #FFFFFF;
  
  /* 배경 */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F5F5F5;
  --bg-tertiary: #FAFAFA;
  
  /* 타이포그래피 */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 
                 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  
  /* 간격 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  
  /* 반경 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* 그림자 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
  
  /* 전환 */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* iOS Safe Area */
  --safe-area-inset-top: env(safe-area-inset-top, 0);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
  --safe-area-inset-left: env(safe-area-inset-left, 0);
  --safe-area-inset-right: env(safe-area-inset-right, 0);
}

/* ========== 기본 요소 ========== */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
  
  /* 라이트모드 강제 고정 */
  color-scheme: light only;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  
  /* PWA 전체 화면 배경 확장 (노치/Dynamic Island 포함) */
  min-height: 100vh;
  background: linear-gradient(135deg, #fafbfc 0%, #f0f9f6 100%);
  background-attachment: fixed;
  line-height: 1.5;
  overflow-x: hidden;
  
  /* 스크롤 위치 초기화 */
  position: relative;
  background-color: var(--bg-secondary);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ========== 타이포그래피 ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--spacing-md);
}

h1 { font-size: 28px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
h4 { font-size: 18px; }
h5 { font-size: 16px; }
h6 { font-size: 14px; }

p {
  margin-bottom: var(--spacing-md);
}

/* ========== 링크 ========== */
a {
  color: var(--primary);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

a:hover {
  opacity: 0.8;
}

/* ========== 버튼 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  
  min-height: 44px; /* iOS 터치 최소 크기 */
  padding: 12px 24px;
  
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  
  transition: all var(--transition-base);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 버튼 변형 */
.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

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

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

.btn-text {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}

/* 버튼 크기 */
.btn-sm {
  min-height: 36px;
  padding: 8px 16px;
  font-size: 14px;
}

.btn-lg {
  min-height: 52px;
  padding: 16px 32px;
  font-size: 18px;
}

/* ========== 입력 요소 ========== */
input,
textarea,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px 16px;
  
  font-family: inherit;
  font-size: 16px; /* iOS 자동 줌 방지 */
  
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-md);
  
  transition: border-color var(--transition-fast);
  box-sizing: border-box !important;
}

/* iOS date input 특별 처리 */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

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

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

/* ========== 카드 ========== */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
}

.card-hover {
  transition: all var(--transition-base);
  cursor: pointer;
}

.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-hover:active {
  transform: translateY(0);
}

/* ========== 레이아웃 유틸리티 ========== */
.container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

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

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* ========== 텍스트 유틸리티 ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

/* ========== 숨김 유틸리티 ========== */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========== 애니메이션 ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

.animate-fade-in {
  animation: fadeIn var(--transition-base);
}

.animate-slide-up {
  animation: slideUp var(--transition-slow);
}

/* ========== 로딩 스피너 ========== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========== 반응형 ========== */
@media (min-width: 768px) {
  .container {
    padding: 0 var(--spacing-xl);
  }
  
  h1 { font-size: 32px; }
  h2 { font-size: 28px; }
  h3 { font-size: 24px; }
}
