/* ═══════════════════════════════════════════════════════════
   위스키관리 앱 — 전체 스타일
   앰버 + 브라운(위스키 톤), 한국어 최적화
═══════════════════════════════════════════════════════════ */

/* ── CSS 변수 (색상/크기 한 곳에서 관리) ───────────────── */
:root {
  --primary: #92400E;
  --primary-light: rgba(146,64,14,0.12);
  --secondary: #B45309;
  --warning: #C2410C;
  --danger: #DC2626;

  /* 강조색 위에 올라가는 텍스트 색 */
  --on-primary: #FFFFFF;
  --on-warning: #FFFFFF;
  --on-secondary: #FFFFFF;

  /* 위스키 종류별 색상 (통계 차트/뱃지에 사용) */
  --color-single-malt: #92400E;
  --color-blended: #B45309;
  --color-bourbon: #C2410C;
  --color-rye: #A16207;
  --color-japanese: #7C2D12;
  --color-other: #78716C;

  /* 배경/서피스 */
  --bg: #FDF6EC;
  --surface: #FFFFFF;
  --card: #FFFFFF;
  --border: #E9DFCE;
  --border-strong: #D8C9AC;

  /* 텍스트 */
  --text-primary: #29211A;
  --text-secondary: #78716C;
  --text-hint: #A8A29E;

  /* 크기 */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: none;
  --nav-height: 64px;
}

/* ── 기본 리셋 ──────────────────────────────────────────── */
*, *::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); }

.pin-visual { display: none; }

/* 데스크톱: 좌(브랜드) / 우(입력폼) 분할 레이아웃 */
@media (min-width: 900px) {
  .pin-screen {
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
  .pin-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow: hidden;
  }
  .pin-visual::before, .pin-visual::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--border);
  }
  .pin-visual::before { width: 440px; height: 440px; }
  .pin-visual::after { width: 300px; height: 300px; }
  .pin-visual-inner { position: relative; z-index: 1; text-align: center; padding: 40px; }
  .pin-visual-icon {
    width: 88px; height: 88px;
    border-radius: 50%;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 38px;
    margin: 0 auto 20px;
  }
  .pin-visual-title { font-size: 24px; font-weight: 800; color: var(--text-primary); margin-bottom: 10px; }
  .pin-visual-sub { font-size: 14px; color: var(--text-secondary); max-width: 280px; margin: 0 auto; line-height: 1.7; }

  .pin-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
  }
  .pin-form .pin-logo { display: none; }
}

/* ── 앱 레이아웃 ────────────────────────────────────────── */
#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: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card-sm {
  background: var(--card);
  border: 1px solid var(--border);
  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: rgba(15,118,110,0.12); color: var(--secondary); }
.badge-warning { background: rgba(217,119,6,0.12); color: var(--warning); }
.badge-danger { background: rgba(220,38,38,0.1); color: var(--danger); }
.badge-gray { background: rgba(0,0,0,0.05); color: var(--text-secondary); }
.badge-gold { background: rgba(161,98,7,0.14); color: #A16207; }

/* 버튼 */
.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: var(--on-primary); }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(220,38,38,0.1); color: var(--danger); }
.btn-fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: 3px solid var(--bg);
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(146,64,14,0.35), 0 0 0 1px rgba(0,0,0,0.04);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}

@media (min-width: 900px) {
  .btn-fab { bottom: 32px; 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: 1px solid var(--border);
  border-bottom: none;
  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: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.list-item:hover { border-color: var(--border-strong); box-shadow: 0 8px 20px rgba(0,0,0,0.06); }

.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: rgba(15,118,110,0.12); }
.icon-warning { background: rgba(217,119,6,0.12); }
.icon-gold { background: rgba(202,138,4,0.14); }
.icon-gray { background: rgba(0,0,0,0.05); }
.icon-danger { background: rgba(220,38,38,0.1); }

.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: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.summary-card .card-title { font-size: 11px; }
.summary-card .big-number { font-size: 20px; }

/* ── 컬렉션 브레드크럼 (전체 > 대분류 > 증류소) ─────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.breadcrumb .crumb {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
}
.breadcrumb .crumb:hover { background: var(--bg); color: var(--text-primary); }
.breadcrumb .crumb-current {
  font-weight: 700;
  color: var(--primary);
  cursor: default;
}
.breadcrumb .crumb-current:hover { background: none; }
.breadcrumb .crumb-sep { color: var(--text-hint); }

/* ── 대분류(Cask) 카드 그리드 ───────────────────────────── */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 600px) {
  .browse-grid { grid-template-columns: repeat(3, 1fr); }
}
.browse-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
  text-align: center;
}
.browse-card:hover {
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}
.browse-card-empty { opacity: 0.55; }
.browse-card-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin: 0 auto 10px;
}
.browse-card-label { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.browse-card-count { font-size: 12px; color: var(--text-secondary); }
.browse-card-sub { font-size: 12px; font-weight: 600; color: var(--primary); margin-top: 2px; }
