﻿/* ==========================================================================
   딥 차콜 & 일렉트릭 블루 (Deep Charcoal & Electric Blue) Theme
   ========================================================================== */
:root {
  /* Background & Surface */
  --bg-color: #121214;
  --surface: #1E1E24;
  --surface-muted: #2A2A32;
  --border: #3A3A45;
  --border-light: #4A4A58;

  /* Typography */
  --text-primary: #E4E6EB;
  --text-secondary: #B0B3B8;
  --text-muted: #8A8D91;

  /* Primary & Accent */
  --primary-main: #3B82F6;
  --primary-hover: #2563EB;
  --primary-light: #1E3A8A;
  --primary-deep: #0D1E4C;
  --accent-1: #06B6D4;
  --accent-2: #8B5CF6;

  /* Semantic Colors */
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --info: #3B82F6;

  /* Header & Overlay Blur */
  --header-bg: rgba(18, 18, 20, 0.65);
  --modal-overlay-bg: rgba(18, 18, 20, 0.65);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ==========================================================================
   미니멀 스크롤바 커스터마이징
   ========================================================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ==========================================================================
   App Layout
   ========================================================================== */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}

/* ==========================================================================
   고정 헤더 (65% 투명도 + backdrop-filter blur)
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 16px;
  border-bottom: 1px solid rgba(58, 58, 69, 0.4);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tab-nav {
  display: flex;
  flex: 1;
  gap: 10px;
}

.tab-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* 비활성 탭: 다크 네이비 / 서피스 톤 */
.tab-btn {
  background-color: #0c1427;
  color: #718096;
  border-color: #1e293b;
}

/* 활성 탭: 딥 네이비 & 선명한 화이트 텍스트 (시안 디자인 반영) */
.tab-btn.active {
  background-color: #000d4d;
  color: #FFFFFF;
  border-color: #1e3a8a;
  box-shadow: 0 2px 8px rgba(0, 13, 77, 0.5);
}

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

.settings-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.settings-btn:hover {
  color: var(--text-primary);
  background-color: var(--surface-muted);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.tab-content {
  flex: 1;
  display: none;
  padding: 20px 16px 80px 16px;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   화면 1: 위치 기록하기 (Record View)
   ========================================================================== */
#record-tab {
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

.record-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
}

/* 중앙 대형 원형 버튼 */
.record-btn-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 40px;
}

.record-btn-pulse {
  position: absolute;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0) 70%);
  animation: pulse-ring 2.5s infinite;
  pointer-events: none;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.85);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.3;
  }
  100% {
    transform: scale(0.85);
    opacity: 0.8;
  }
}

.record-btn {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: #000d4d;
  color: #FFFFFF;
  border: 4px solid #102a71;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.5px;
  box-shadow: 0 10px 30px rgba(0, 13, 77, 0.6), inset 0 2px 6px rgba(255, 255, 255, 0.15);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.record-btn:hover {
  background: #00136b;
  border-color: var(--primary-main);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 36px rgba(59, 130, 246, 0.4), inset 0 2px 8px rgba(255, 255, 255, 0.25);
}

.record-btn:active {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 4px 12px rgba(0, 13, 77, 0.8);
}

.record-btn.loading {
  pointer-events: none;
  opacity: 0.9;
}

.record-btn-text {
  display: block;
}

.record-hint {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 10px;
}

/* 위치 수신 상태 표시 영역 */
.status-card {
  margin-top: 24px;
  padding: 12px 18px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  animation: fadeIn 0.3s ease;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-main);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   화면 2: 위치 기록보기 (List View)
   ========================================================================== */
#list-tab {
  width: 100%;
}

.list-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
}

.list-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--surface-muted);
  color: var(--text-primary);
  border-color: var(--primary-main);
}

.icon-btn .material-symbols-outlined {
  font-size: 18px;
}

/* 기록 목록 컨테이너 */
.record-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 아코디언 카드 (시안 배치를 정확히 반영) */
.record-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.record-card.open {
  border-color: var(--primary-main);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.record-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background-color: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

.record-card-header:hover {
  background-color: var(--surface-muted);
}

.record-time-text {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* 우측 둥근 화살표 아이콘 */
.record-toggle-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: #000d4d;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  transition: transform 0.25s ease, background-color 0.2s ease;
  flex-shrink: 0;
}

.record-card.open .record-toggle-icon-wrap {
  background-color: var(--primary-main);
}

.record-card.open .record-toggle-icon-wrap .material-symbols-outlined {
  transform: rotate(180deg);
}

.record-toggle-icon-wrap .material-symbols-outlined {
  font-size: 22px;
  transition: transform 0.25s ease;
}

/* 아코디언 바디 (지도 표시 영역) */
.record-card-body {
  display: none;
  padding: 14px;
  background-color: var(--surface-muted);
  border-top: 1px solid var(--border);
}

.record-card.open .record-card-body {
  display: block;
  animation: expandCard 0.25s ease-out;
}

@keyframes expandCard {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 지도 영역 (Leaflet.js) */
.record-map {
  width: 100%;
  height: 320px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background-color: #121214;
  z-index: 1;
}

/* 카드 하단 정보 및 링크 바 */
.record-details {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.coord-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.coord-badge {
  background-color: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent-1);
}

.map-links {
  display: flex;
  gap: 6px;
}

.map-link-btn {
  padding: 5px 9px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.map-link-btn:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-main);
}

/* 빈 목록 상태 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state .material-symbols-outlined {
  font-size: 48px;
  margin-bottom: 12px;
  color: var(--border-light);
}

.empty-state p {
  font-size: 1rem;
}

/* ==========================================================================
   커스텀 토스트 알림 (Toast Messages)
   ========================================================================== */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 420px;
}

.toast {
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.25s ease;
}

.toast.removing {
  opacity: 0;
  transform: translateY(12px) scale(0.95);
}

.toast-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.toast.success {
  border-left: 4px solid var(--success);
}
.toast.success .toast-icon {
  color: var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}
.toast.error .toast-icon {
  color: var(--error);
}

.toast.info {
  border-left: 4px solid var(--info);
}
.toast.info .toast-icon {
  color: var(--info);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}
.toast.warning .toast-icon {
  color: var(--warning);
}

.toast-message {
  flex: 1;
  word-break: break-word;
  line-height: 1.4;
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   커스텀 모달 다이얼로그 (Dimmed with backdrop-filter blur)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--modal-overlay-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

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

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s ease;
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--surface-muted);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  max-height: 70vh;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  background-color: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--primary-main);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background-color: rgba(0, 0, 0, 0.1);
}

.btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-secondary {
  background-color: var(--surface-muted);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background-color: var(--border);
  color: var(--text-primary);
}

.btn-primary {
  background-color: var(--primary-main);
  color: #FFFFFF;
}

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

/* ==========================================================================
   Leaflet Custom Dark Popup
   ========================================================================== */
.leaflet-popup-content-wrapper {
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

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

.leaflet-container {
  font-family: inherit;
}
