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

:root {
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --surface2:    #f8fafc;
  --border:      #e2e8f0;
  --accent:      #6366f1;
  --accent-dark: #4f46e5;
  --accent-glow: rgba(99,102,241,0.2);
  --text:        #0f172a;
  --text-dim:    #475569;
  --text-muted:  #94a3b8;
  --success:     #059669;
  --danger:      #e11d48;
  --radius:      10px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 1000;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.logo {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.logo-icon { font-size: 1.2rem; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 업로드 버튼 ───────────────────────────────── */
.btn-upload {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn-upload:hover {
  background: var(--accent-dark);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-upload .icon { font-size: 1rem; }

/* 모바일: 텍스트 숨기고 아이콘만 */
@media (max-width: 480px) {
  .btn-upload .label { display: none; }
  .btn-upload { padding: 8px 12px; }
}

/* ── Map ───────────────────────────────────────── */
#map {
  flex: 1;
  z-index: 0;
}

/* Leaflet 팝업 라이트 테마 */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important;
  padding: 0 !important;
  overflow: hidden;
  min-width: 200px;
}

.leaflet-popup-tip {
  background: var(--surface) !important;
}

.leaflet-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 1.2rem !important;
  top: 6px !important;
  right: 8px !important;
}

/* ── 팝업 내부 콘텐츠 ──────────────────────────── */
.popup-card { width: 220px; }

.popup-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--surface2);
}

.popup-info {
  padding: 10px 12px;
}

.popup-date {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.popup-link {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.popup-link:hover { text-decoration: underline; }

/* 모바일 팝업 */
@media (max-width: 480px) {
  .popup-card { width: 180px; }
}

/* ── 커스텀 마커 ───────────────────────────────── */
.photo-marker-pin {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.photo-marker-pin span {
  transform: rotate(45deg);
  font-size: 1rem;
  display: block;
}

/* ── 토스트 알림 ───────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  animation: toast-in 0.25s forwards, toast-out 0.3s 2.7s forwards;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.toast.success { background: #065f46; }
.toast.error   { background: #9f1239; }
.toast.info    { background: #1e40af; }

@keyframes toast-in  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; } }

/* ── 업로드 오버레이 (드래그 앤 드롭) ─────────── */
#drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(99,102,241,0.08);
  border: 3px dashed var(--accent);
  z-index: 8000;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
}

#drop-overlay.active { display: flex; }

/* ── 로딩 스피너 ───────────────────────────────── */
#loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(241,245,249,0.7);
  z-index: 7000;
  align-items: center;
  justify-content: center;
}

#loading.active { display: flex; }

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* ── 클러스터 아이콘 ──────────────────────────── */
.cluster-pin {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border: 3px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,0.35);
}

/* ── 사진 수 배지 ──────────────────────────────── */
.photo-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 99px;
}

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

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

/* ── 헤더 셀렉트 ──────────────────────────── */
header select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
  height: 34px;
  max-width: 90px;
}

@media (max-width: 480px) {
  header select { max-width: 72px; font-size: 0.72rem; }
  .photo-count  { display: none; }
}

/* ── 업로드 바텀 시트 ──────────────────────── */
.sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.35);
  z-index: 5000;
}
.sheet-backdrop.open { display: block; }

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 12px 16px max(20px, env(safe-area-inset-bottom));
  z-index: 5001;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
}
.bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 0 auto 16px;
}

.sheet-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.sheet-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
}
.sheet-item:hover  { background: var(--border); }
.sheet-item:active { background: var(--border); }

.sheet-item-icon {
  font-size: 1.2rem;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: 9px;
  flex-shrink: 0;
}

.sheet-item-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}
