/* ═══════════════════════════════════════════════════════════
   자산관리 앱 — 전체 스타일
   Material Design 3 영감, 한국어 최적화
═══════════════════════════════════════════════════════════ */

/* ── CSS 변수 (색상/크기 한 곳에서 관리) ───────────────── */
:root {
  --primary: #1E6FFF;
  --primary-light: #E8F0FF;
  --secondary: #00C57E;
  --warning: #FF9B21;
  --danger: #FF4B4B;

  /* 자산 카테고리 색상 */
  --color-savings: #1E6FFF;
  --color-etf: #00C57E;
  --color-stock: #FF9B21;
  --color-gold: #FFD700;
  --color-cash: #9E9E9E;
  --color-other: #B39DDB;

  /* 배경/서피스 */
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --card: #FFFFFF;
  --border: #E0E0E0;

  /* 텍스트 */
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --text-hint: #BDBDBD;

  /* 크기 */
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --nav-height: 64px;
}

/* 다크 모드 */
[data-theme="dark"] {
  --bg: #121212;
  --surface: #1E1E1E;
  --card: #2C2C2C;
  --border: #3A3A3A;
  --text-primary: #F5F5F5;
  --text-secondary: #B0B0B0;
  --text-hint: #555;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* ── 기본 리셋 ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ── PIN 잠금 화면 (로그인 없음, 개인용 화면 잠금) ───────── */
.pin-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px;
  background: var(--surface);
}

.pin-logo {
  font-size: 56px;
  margin-bottom: 16px;
}

.login-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-primary);
  text-align: center;
}

.login-subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 14px;
  text-align: center;
}

.pin-input {
  width: 100%;
  max-width: 320px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
}
.pin-input:focus { border-color: var(--primary); }

/* ── 앱 레이아웃 ────────────────────────────────────────── */
#app { display: none; min-height: 100vh; }

/* 모바일: 하단 탭 */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* 데스크톱: 좌측 사이드바 */
@media (min-width: 900px) {
  .app-container { flex-direction: row; }

  .page-content {
    padding: 24px 32px;
    padding-bottom: 24px;
    max-width: 800px;
  }

  .bottom-nav { display: none; }
  .side-nav { display: flex; }
}

/* ── 하단 네비게이션 (모바일) ───────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.2s;
  border: none;
  background: none;
  padding: 8px 0;
}

.nav-item .material-icons { font-size: 22px; }
.nav-item.active { color: var(--primary); }
.nav-item.active .material-icons { font-weight: 700; }

/* ── 사이드 네비게이션 (데스크톱) ─────────────────────── */
.side-nav {
  display: none;
  flex-direction: column;
  width: 220px;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 12px;
  position: sticky;
  top: 0;
  gap: 4px;
}

.side-nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 24px;
  font-weight: 800;
  font-size: 16px;
}

.side-nav-logo span { font-size: 24px; }

.side-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.side-nav-item:hover { background: var(--bg); color: var(--text-primary); }
.side-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }
.side-nav-item .material-icons { font-size: 20px; }

/* ── 페이지 (show/hide) ─────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── 공통 컴포넌트 ──────────────────────────────────────── */
.page-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.card-sm {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.big-number {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
}

.sub-number {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 진행률 바 */
.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.progress-fill.green { background: var(--secondary); }
.progress-fill.warning { background: var(--warning); }

/* 배지 */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: #E6FAF3; color: var(--secondary); }
.badge-warning { background: #FFF4E6; color: var(--warning); }
.badge-danger { background: #FFEAEA; color: var(--danger); }
.badge-gray { background: var(--bg); color: var(--text-secondary); }

/* 버튼 */
.btn {
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #FFEAEA; color: var(--danger); }
.btn-fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(30,111,255,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 99;
}

@media (min-width: 900px) {
  .btn-fab { bottom: 24px; right: 32px; }
}

/* ── 폼 ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.2s;
  outline: none;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 12px; color: var(--text-hint); margin-top: 4px; }

/* 계산 결과 박스 */
.calc-result {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 16px;
}
.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
}
.calc-row.highlight {
  font-weight: 700;
  font-size: 16px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 8px;
}

/* ── 모달 ─────────────────────────────────────────────────*/
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  max-width: 540px;
}

@media (min-width: 600px) {
  .modal { border-radius: var(--radius); }
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 1; }

/* ── 목록 항목 ──────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.list-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

.list-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.icon-blue { background: var(--primary-light); }
.icon-green { background: #E6FAF3; }
.icon-warning { background: #FFF4E6; }
.icon-gold { background: #FFFDE6; }
.icon-gray { background: var(--bg); }

.list-info { flex: 1; min-width: 0; }
.list-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.list-right { text-align: right; flex-shrink: 0; }
.list-amount { font-weight: 700; font-size: 15px; }
.list-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── 빈 상태 ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty-state .material-icons { font-size: 48px; color: var(--text-hint); margin-bottom: 12px; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ── 유틸 ───────────────────────────────────────────────── */
.text-primary-color { color: var(--primary); }
.text-success { color: var(--secondary); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── 차트 컨테이너 ──────────────────────────────────────── */
.chart-container { position: relative; height: 220px; margin: 8px 0; }

/* ── 로딩 ───────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 토스트 알림 ─────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%; transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 12px 20px;
  border-radius: 99px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  pointer-events: none;
}
#toast.show { opacity: 1; }

/* ── 대시보드 요약 그리드 ───────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.summary-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.summary-card .card-title { font-size: 11px; }
.summary-card .big-number { font-size: 20px; }
