/* 嘉豐 UI 品牌規範：主橘 #FF8C5A、深橘 #C07040、暗灰 #2D3748、米白 #FAF7F2 */
:root {
  --jf-orange: #FF8C5A;
  --jf-orange-deep: #C07040;
  --jf-blue: #4A9EFF;
  --jf-pink: #FF6B9D;
  --jf-purple: #9B59B6;
  --jf-teal: #17A2B8;
  --jf-cyan: #00BCD4;
  --jf-yellow: #FAAD14;
  --gray-900: #1A202C;
  --gray-700: #2D3748;
  --gray-500: #718096;
  --gray-300: #CBD5E0;
  --gray-100: #EDF2F7;
  --bg: #FAF7F2;
  --white: #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif;
  color: var(--gray-700);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 36px !important; width: auto !important; max-width: 36px; max-height: 36px; display: block; flex-shrink: 0; object-fit: contain; }
.brand-title { font-size: 18px; font-weight: 600; color: var(--gray-900); }
.topbar-meta { color: var(--gray-500); font-size: 13px; }

/* Layout */
.layout {
  display: flex;
  height: calc(100vh - 57px);
}
.sidebar {
  width: 320px; flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--gray-100);
  overflow-y: auto;
  padding: 16px;
}
.main {
  flex: 1; position: relative;
}
#map { width: 100%; height: 100%; background: #e0e8ef; }

/* 嘉豐 CTA 卡 */
.jf-card {
  background: linear-gradient(135deg, #FFF4ED 0%, #FFE7D6 100%);
  border: 2px solid var(--jf-orange);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-md);
}
.jf-card-title {
  font-size: 16px; font-weight: 700;
  color: var(--jf-orange-deep);
  margin: 0 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.jf-card-logo-wrap {
  text-align: center;
  margin: -4px 0 8px;
}
.jf-card-logo {
  max-width: 100%;
  height: auto;
  max-height: 56px;
  display: inline-block;
}
.jf-card-services { margin: 6px 0 10px; font-size: 13px; }
.jf-card-services li {
  list-style: none; margin: 4px 0;
  padding-left: 18px; position: relative;
}
.jf-card-services li::before {
  content: "✓"; color: var(--jf-orange);
  position: absolute; left: 0; font-weight: 700;
}
.jf-card-phone {
  font-weight: 600; color: var(--gray-900);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  margin: 6px 0;
}
.jf-card-phone:hover { color: var(--jf-orange-deep); }
.jf-card-recruit {
  background: #E53E3E; color: var(--white);
  text-align: center; font-weight: 700;
  padding: 8px; border-radius: 6px;
  margin: 10px 0 8px;
  letter-spacing: 1px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}
.jf-card-actions { display: flex; gap: 8px; margin-top: 6px; }
.jf-card-actions a {
  flex: 1; text-align: center;
  padding: 6px; font-size: 12px;
  background: var(--white);
  border: 1px solid var(--jf-orange);
  color: var(--jf-orange-deep);
  border-radius: 6px; text-decoration: none;
  transition: all .15s;
}
.jf-card-actions a:hover { background: var(--jf-orange); color: var(--white); }

/* Filter blocks */
.filter-block { margin-bottom: 16px; }
.filter-label {
  display: block; font-weight: 600;
  color: var(--gray-900); margin-bottom: 6px;
  font-size: 13px;
}
.filter-label-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.filter-label-row .filter-label { flex: 1; margin: 0; }
.link-btn {
  background: none; border: none; color: var(--jf-orange);
  font-size: 12px; cursor: pointer; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

#filter-district, #filter-keyword {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 14px; background: var(--white);
}
#filter-district:focus, #filter-keyword:focus {
  outline: none; border-color: var(--jf-orange);
  box-shadow: 0 0 0 3px rgba(255,140,90,.15);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-row label {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; background: var(--gray-100);
  border-radius: 16px; cursor: pointer;
  font-size: 12px; user-select: none;
  transition: all .15s;
}
.chip-row label:has(input:checked) {
  background: var(--jf-orange); color: var(--white);
}
.chip-row input { display: none; }

/* Category groups */
.cat-groups { display: flex; flex-direction: column; gap: 8px; }
.cat-group {
  background: var(--gray-100);
  border-radius: 8px;
  overflow: hidden;
}
.cat-group-header {
  padding: 6px 10px; font-weight: 600; font-size: 12px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  color: var(--gray-900);
}
.cat-group-header .dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.cat-group-body { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.cat-group-body label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; cursor: pointer;
  padding: 2px 0;
}
.cat-group-body input[type="checkbox"] { accent-color: var(--jf-orange); }
.cat-group.collapsed .cat-group-body { display: none; }

.stat-block {
  margin-top: 12px; padding: 10px;
  background: var(--gray-100); border-radius: 6px;
  text-align: center; font-size: 12px; color: var(--gray-500);
}

/* Legend */
.legend {
  position: absolute; bottom: 16px; left: 16px;
  background: var(--white); padding: 10px 14px;
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  font-size: 12px; z-index: 999;
  max-width: 240px;
}
.legend-title { font-weight: 700; margin-bottom: 6px; color: var(--gray-900); }
.legend-item { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.legend-item .dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
}

/* Popup */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.leaflet-popup-content { margin: 14px 16px; min-width: 240px; max-width: 320px; }
.popup-name { font-size: 16px; font-weight: 700; color: var(--gray-900); margin: 0 0 6px; }
.popup-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.popup-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  color: var(--white); font-weight: 600;
}
.popup-row { font-size: 13px; margin: 4px 0; color: var(--gray-700); }
.popup-row .label { color: var(--gray-500); margin-right: 6px; min-width: 56px; display: inline-block; }
.popup-services { background: var(--gray-100); padding: 6px 8px; border-radius: 6px; margin: 6px 0; font-size: 12px; }
.popup-note {
  background: #FFF8E1; border-left: 3px solid var(--jf-yellow);
  padding: 6px 10px; margin: 8px 0; font-size: 12px; color: var(--gray-700);
  border-radius: 0 4px 4px 0;
}
.popup-actions { display: flex; gap: 6px; margin-top: 10px; }
.popup-actions a {
  flex: 1; text-align: center; padding: 6px;
  font-size: 12px; font-weight: 600; text-decoration: none;
  border-radius: 6px;
}
.popup-actions .btn-call {
  background: var(--jf-orange); color: var(--white);
}
.popup-actions .btn-nav {
  background: var(--white); color: var(--jf-orange-deep);
  border: 1px solid var(--jf-orange);
}
.popup-meta { font-size: 11px; color: var(--gray-500); margin-top: 8px; text-align: right; }

/* Custom Leaflet marker - 透明 PNG + 大分類色環 */
.jf-marker {
  width: 38px; height: 38px;
  border-radius: 50%;
  background-color: #FFFFFF;
  background-size: 28px 28px;
  background-repeat: no-repeat;
  background-position: center;
  border: 2.5px solid currentColor;
  box-shadow: 0 2px 6px rgba(0,0,0,.22);
}
.jf-marker.is-jiafeng {
  width: 48px; height: 48px;
  border: 4px solid var(--jf-orange-deep);
  background-size: 36px 36px;
  box-shadow: 0 4px 12px rgba(192,112,64,.4);
}

/* Cluster 聚合泡泡 */
.marker-cluster {
  background-clip: padding-box;
  border-radius: 50%;
}
.marker-cluster div {
  width: 36px; height: 36px;
  margin: 4px; text-align: center;
  border-radius: 50%; font-weight: 700;
  font-family: -apple-system, "Microsoft JhengHei", sans-serif;
  font-size: 13px; color: white;
  line-height: 36px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.marker-cluster-small { background-color: rgba(255, 140, 90, 0.4); }
.marker-cluster-small div { background-color: #FF8C5A; }
.marker-cluster-medium { background-color: rgba(255, 107, 157, 0.5); }
.marker-cluster-medium div { background-color: #FF6B9D; }
.marker-cluster-large { background-color: rgba(155, 89, 182, 0.5); }
.marker-cluster-large div { background-color: #9B59B6; }

/* Mobile */
@media (max-width: 768px) {
  .sidebar { width: 100%; max-height: 50vh; }
  .layout { flex-direction: column; height: auto; }
  .main { height: 60vh; }
  .legend { max-width: 180px; font-size: 11px; }
}
