/* 메인 지도 화면: 지도·핀, 학교 검색과 학교 카드, 제보 상세·순위, 등하교 바, 비상 버튼, 설정 시트 */

/* ---------- 지도 ---------- */
body:not(.parent-body) #map {
  position: absolute; top: var(--head-h); left: 0; right: 0; z-index: 1;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
body:has(#map):not(.parent-body) { overflow: hidden; }
.leaflet-top.leaflet-left { margin-top: 56px; }

/* 제보 핀 (물방울 모양, 공감 수에 따라 크기가 커짐) */
.pin-wrap { background: none; border: none; }
.pin {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3); border: 2.5px solid #fff;
  position: relative;
}
.pin span { transform: rotate(45deg); font-size: 15px; line-height: 1; }
.pin-badge {
  position: absolute; top: -8px; right: -8px; transform: rotate(45deg);
  background: #fff; color: var(--ink); font-size: 11px; font-weight: 800;
  min-width: 18px; height: 18px; line-height: 18px; text-align: center;
  border-radius: 999px; box-shadow: 0 1px 3px rgba(0,0,0,0.3); padding: 0 3px;
}
/* 학부모 경고 핀 */
.pin.parent-warn {
  border: 3px dashed #fff;
  box-shadow: 0 0 0 2px #e8820c, 0 3px 8px rgba(0,0,0,0.35);
}
.pin-parent-badge {
  position: absolute; top: -8px; right: -8px;
  background: #fff; border-radius: 999px; font-size: 11px;
  width: 18px; height: 18px; line-height: 18px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* 핀 묶음(마커 클러스터) 테마색 */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large { background: rgba(0, 166, 176, 0.3); }
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: var(--blue); color: #fff; font-weight: 800;
}
.marker-cluster span { color: #fff; }

/* 상단 알림 버튼 배지 */
.notif-btn { position: relative; }
.notif-btn .count-badge {
  position: absolute; top: -4px; right: -4px;
  margin: 0; min-width: 16px; height: 16px; line-height: 14px;
  padding: 0 4px; font-size: 10px; border: 1.5px solid #fff;
}

/* 예전 떠 있는 제보 버튼 (지금은 하단 탭바의 '제보') */
.fab {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 1000; padding: 15px 28px; border: 0; border-radius: 999px;
  background: var(--blue); color: #fff; font-size: 17px; font-weight: 800;
  box-shadow: 0 8px 22px rgba(0, 143, 153, 0.45);
}
.fab:active { transform: translateX(-50%) scale(0.96); }
body:has(.attend-bar:not(.hidden)) .fab { bottom: 112px; }

/* ---------- 학교 검색 ---------- */
.search-wrap {
  position: absolute; top: 104px; left: 0; right: 0; z-index: 950;
  padding: 0 12px 10px;
}
#school-search {
  width: 100%; padding: 13px 15px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 15px; background: #fff; box-shadow: var(--shadow-sm);
}
#school-search:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft);
}
.search-results {
  list-style: none; margin: 6px 0 0; padding: 5px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  max-height: 260px; overflow-y: auto; box-shadow: var(--shadow-md);
}
.search-results li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--r-sm);
}
.search-results li:active { background: var(--blue-soft); }
.school-info {
  display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; cursor: pointer;
}
.school-name { font-weight: 700; font-size: 15px; }
.school-region { font-size: 13px; color: var(--muted); }
.school-site {
  flex-shrink: 0; padding: 7px 11px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue);
  font-size: 13px; font-weight: 800; text-decoration: none; white-space: nowrap;
}
.school-site:active { background: #d8e7fe; }
.no-result { color: var(--muted); font-size: 14px; justify-content: center; }

/* 검색한 학교 핀과 학교 정보 카드 */
.school-pin { background: none; border: none; }
.school-pin-inner {
  width: 42px; height: 42px; line-height: 38px; text-align: center;
  font-size: 20px; background: #fff; border: 3px solid var(--blue);
  border-radius: 50%; box-shadow: var(--shadow-md);
}
.school-signboard { width: 100%; height: 180px; object-fit: cover; display: block; }
#school-card h2 { margin: 0 0 2px; font-size: 20px; }
.school-phone-row {
  display: flex; align-items: center; gap: 8px; margin: 12px 0;
  font-size: 16px; font-weight: 600;
}
.school-phone-row a { color: var(--blue); text-decoration: none; }
.school-actions { display: flex; gap: 8px; margin-top: 16px; }
.school-act {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 6px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: #fff; color: var(--ink); text-decoration: none;
  font-size: 13px; font-weight: 700; text-align: center;
}
.school-act:active { background: var(--bg); }
.school-act .act-ico { font-size: 22px; }

/* ---------- 제보 상세 ---------- */
#detail-photo { width: 100%; max-height: 300px; object-fit: cover; display: block; }
.type-badge {
  display: inline-block; padding: 6px 13px; border-radius: 999px;
  color: #fff; font-size: 13px; font-weight: 800;
}
.resolved-badge {
  display: inline-block; margin-left: 6px; padding: 6px 11px;
  border-radius: 999px; background: var(--safe-soft); color: var(--safe);
  font-size: 13px; font-weight: 800;
}
#detail-desc { font-size: 18px; margin: 14px 0 6px; line-height: 1.5; font-weight: 500; }
.sheet-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.like {
  padding: 13px 22px; border: 2px solid var(--blue); border-radius: var(--r-md);
  background: #fff; color: var(--blue); font-size: 16px; font-weight: 800;
}
.like.liked { background: var(--blue); color: #fff; }
#teacher-tools { display: flex; gap: 6px; margin-left: auto; }

/* ---------- 위험 지점 순위 ---------- */
.rank-list { list-style: none; padding: 0; margin: 12px 0 0; counter-reset: rank; }
.rank-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
  counter-increment: rank;
}
.rank-list li:active { background: var(--bg); }
.rank-list li::before {
  content: counter(rank); font-weight: 800; color: var(--blue);
  min-width: 22px; text-align: center; font-size: 16px;
}
.rank-type {
  width: 34px; height: 34px; border-radius: 50%; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}
.rank-desc { flex: 1; font-size: 15px; font-weight: 500; }
.rank-like { font-size: 14px; font-weight: 800; color: var(--muted); }

/* ---------- 학생: 등교/하교 바 (탭바 위에 떠 있음) ---------- */
.attend-bar {
  position: fixed; left: 12px; right: 12px; z-index: 1000;
  bottom: calc(var(--tab-h) + 10px + env(safe-area-inset-bottom));
  padding: 10px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-md);
}
.attend-btns { display: flex; gap: 8px; }
.attend-btn {
  flex: 1; padding: 12px; border: 0; border-radius: var(--r-md);
  font-size: 15px; font-weight: 800; color: #fff; box-shadow: var(--shadow-sm);
}
.attend-btn.in { background: var(--safe); }
.attend-btn.out { background: var(--blue); }
.attend-btn.done { opacity: 0.5; }
.attend-status {
  text-align: center; font-size: 13px; color: var(--muted); margin-top: 6px; font-weight: 600;
  white-space: pre-line; /* 등하교 주소 줄바꿈 */
}
/* 학부모 연결 코드는 설정 시트에서 보여 준다 */
.link-code-row { display: none; text-align: center; font-size: 13px; color: var(--muted); margin-top: 4px; }
.link-code-row strong { color: var(--blue); font-size: 16px; letter-spacing: 3px; }

/* ---------- 학생: 비상 버튼과 비상 시트 ---------- */
.sos-fab {
  position: fixed; right: 14px; z-index: 1000;
  bottom: calc(var(--tab-h) + 112px + env(safe-area-inset-bottom)); /* 등하교 바 위 */
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 800;
  line-height: 1.1; box-shadow: 0 6px 18px rgba(226,59,59,0.5);
  animation: sosPulse 1.8s infinite;
}
.sos-title { margin: 0 0 10px; font-size: 22px; color: var(--danger); }
.sos-title.sent { color: var(--safe); }
.sos-note {
  margin: 10px 0 16px; padding: 10px 12px; background: var(--warn-soft);
  border-radius: var(--r-sm); font-size: 12.5px; color: #8a5a10; line-height: 1.5;
}
.sos-big {
  width: 100%; padding: 20px; border: 0; border-radius: var(--r-md);
  background: var(--danger); color: #fff; font-size: 20px; font-weight: 800;
  box-shadow: 0 8px 20px rgba(226,59,59,0.4);
}
.sim-badge {
  display: inline-block; margin: 10px 0 14px; padding: 7px 12px;
  background: var(--blue-soft); color: #2c5a8a; border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
}
.sos-messages { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.sos-msg { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.sos-msg-head { padding: 9px 12px; background: var(--bg); font-weight: 800; font-size: 14px; }
.sos-msg-body {
  padding: 11px 12px; font-size: 13.5px; line-height: 1.55; white-space: pre-line;
  color: var(--ink);
}

/* ---------- 설정 시트 ---------- */
#settings-panel .sheet-body { padding: 18px 18px 26px; }
#settings-panel h2 { margin: 0 0 16px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.set-label { font-weight: 700; font-size: 15px; }
.set-lang { display: flex; gap: 6px; }
.set-lang-btn {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--muted); font-size: 13px; font-weight: 700;
}
.set-lang-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.set-code { color: var(--blue); font-size: 17px; letter-spacing: 3px; font-weight: 800; }
.set-item {
  display: block; width: 100%; text-align: left; margin-top: 10px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: #fff; font-size: 15px; font-weight: 700; color: var(--ink);
}
.set-item:active { background: var(--bg); }
.set-item.danger { color: var(--danger); border-color: #f3c4c4; }
.set-row.set-col { flex-direction: column; align-items: stretch; gap: 6px; position: relative; }
.set-row.set-col .set-label { margin-bottom: 2px; }
#set-school-input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: 15px; background: #fff;
}
#set-school-results { position: static; margin-top: 4px; }
.set-gc { display: flex; gap: 8px; }
.set-gc input {
  width: 72px; padding: 10px; border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: 15px; text-align: center; background: #fff;
}
.set-saved { color: var(--safe); font-weight: 700; font-size: 14px; margin: 8px 0 0; text-align: center; }
.set-qr-box { margin-top: 10px; text-align: center; }
.set-qr-img {
  width: 200px; height: 200px; max-width: 70%;
  border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; padding: 8px;
}

@media (min-width: 768px) {
  .attend-bar { max-width: 536px; margin: 0 auto; }
}
