/* ==========================================================================
   Opinet Gas Station Price Finder - Modern Mobile-First UI (Dark & Light)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+KR:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root,
[data-theme="dark"] {
  --font-main: 'Plus Jakarta Sans', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-main: #0a0e17;
  --bg-gradient: radial-gradient(circle at 50% -20%, #1e1b4b 0%, #0a0e17 80%);
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(28, 38, 59, 0.95);
  --bg-header: rgba(10, 14, 23, 0.85);
  --bg-input: rgba(15, 23, 42, 0.7);

  --border: rgba(255, 255, 255, 0.08);
  --border-active: #6366f1;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);

  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --cyan: #06b6d4;

  --text-title: #f8fafc;
  --text-body: #cbd5e1;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 30px -4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-gradient: radial-gradient(circle at 50% -20%, #e0e7ff 0%, #f1f5f9 80%);
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.88);
  --bg-input: #ffffff;

  --border: rgba(0, 0, 0, 0.08);
  --border-active: #4f46e5;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.2);

  --emerald: #059669;
  --amber: #d97706;
  --rose: #e11d48;
  --cyan: #0284c7;

  --text-title: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-dim: #475569;

  --shadow-card: 0 10px 25px -4px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 25px rgba(79, 70, 229, 0.15);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background: var(--bg-main);
  background-image: var(--bg-gradient);
  color: var(--text-body);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 80px;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container */
.app-viewport {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Top Sticky Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-badge-text h1 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-title);
  letter-spacing: -0.3px;
  line-height: 1.1;
}

.brand-badge-text p {
  font-size: 11.5px;
  color: var(--text-muted);
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-body);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* Fuel Selector Tabs (Horizontal Scrollable) */
.fuel-tabs-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.fuel-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.fuel-tab {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.fuel-tab:hover {
  border-color: var(--primary);
  color: var(--text-title);
}

.fuel-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Location Bar & Mode Switcher */
.location-control-panel {
  padding: 14px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-segmented-control {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: var(--radius-full);
}

.mode-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Radius / Region Selectors */
.selector-subrow {
  display: flex;
  gap: 8px;
  align-items: center;
}

.radius-chips {
  display: flex;
  gap: 6px;
}

.radius-chip {
  padding: 5px 11px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.radius-chip.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(6, 182, 212, 0.12);
}

.region-select {
  padding: 7px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-title);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.region-select:focus {
  border-color: var(--primary);
}

/* Average Price & Savings Banner */
.savings-banner {
  margin: 0 18px 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(6, 182, 212, 0.15) 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.savings-info {
  display: flex;
  flex-direction: column;
}

.savings-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.savings-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-title);
}

.savings-calc {
  text-align: right;
}

.savings-calc-title {
  font-size: 11px;
  color: var(--text-muted);
}

.savings-calc-num {
  font-size: 14px;
  font-weight: 800;
  color: #10b981;
}

/* Filter Toolbar (Sort & View Toggle) */
.filter-toolbar {
  padding: 0 18px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.filter-tags-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-tags-scroll::-webkit-scrollbar {
  display: none;
}

.filter-tag-chip {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.filter-tag-chip.active {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.view-toggle-wrap {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 2px;
}

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

.view-btn.active {
  background: var(--primary);
  color: #ffffff;
}

/* Gas Stations List */
.stations-container {
  padding: 0 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.station-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.station-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.4);
}

.station-card.cheapest-rank {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 10px 30px -4px rgba(16, 185, 129, 0.2), 0 0 0 1px #10b981;
}

.station-card.cheapest-rank::before {
  content: '최저가 TOP 1';
  position: absolute;
  top: 0;
  right: 0;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 10px;
  border-bottom-left-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.station-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.rank-badge {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}

.brand-chip {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.station-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-title);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-body {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 12px;
}

.price-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.price-currency {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.price-amount {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-title);
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
}

.price-unit {
  font-size: 13px;
  color: var(--text-muted);
}

.price-diff-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
}

.price-diff-badge.cheaper {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.price-diff-badge.expensive {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
}

.station-meta-info {
  text-align: right;
  font-size: 12.5px;
  color: var(--text-dim);
}

.distance-tag {
  font-weight: 700;
  color: var(--cyan);
}

/* Facility Chips Row */
.facilities-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.facility-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.facility-badge.active {
  color: var(--text-title);
  border-color: rgba(99, 102, 241, 0.3);
}

/* Action Buttons (Navi, Call) */
.station-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 40px;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.btn-navi {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.btn-navi.tmap {
  background: #e11d48;
}

.btn-navi.kakao {
  background: #f59e0b;
  color: #000;
}

.btn-navi:hover {
  opacity: 0.9;
}

.btn-tel {
  width: 36px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-title);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

/* Map View Container */
.map-view-container {
  display: none;
  flex: 1;
  position: relative;
  height: calc(100vh - 240px);
  min-height: 450px;
  margin: 0 18px 18px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

#mapInstance {
  width: 100%;
  height: 100%;
}

/* Floating Bottom Sheet on Map Marker Click */
.map-floating-card {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  z-index: 1000;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  display: none;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Custom Map Bubble Marker */
.price-marker-bubble {
  background: var(--bg-card);
  border: 2px solid var(--marker-color, var(--primary));
  color: var(--text-title);
  padding: 4px 9px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 800;
  font-family: var(--font-mono);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.price-marker-bubble:hover {
  transform: scale(1.1);
  z-index: 10000;
}

/* Modal Settings Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-title);
  margin-bottom: 12px;
}

.input-styled {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-title);
  font-size: 14px;
  outline: none;
  margin-bottom: 16px;
}

.input-styled:focus {
  border-color: var(--primary);
}

/* Loading & Empty State */
.loading-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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