/* ========================================
   同学世界地图联系录 - 样式表
   移动端优先 · 微信适配 · 简洁清晰
   ======================================== */

/* --- 基础重置与变量 --- */
:root {
  --bg-primary: #1a1d23;
  --bg-secondary: #21252b;
  --bg-card: #282c34;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --accent: #4da6ff;
  --accent-glow: #73c0ff;
  --highlight: #ffd54f;
  --highlight-bg: rgba(255, 213, 79, 0.15);
  --danger: #ff6b6b;
  --success: #69db7c;
  --border: #3a3f4b;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --radius: 10px;
  --radius-sm: 6px;
  --header-height: 50px;
  --footer-height: 32px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* 微信内禁止下拉 */
  overscroll-behavior: none;
}

/* --- App 容器 --- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 768px;
  margin: 0 auto;
  position: relative;
}

/* --- 顶部导航栏 --- */
#header {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  z-index: 100;
  flex-shrink: 0;
}

/* 返回按钮 */
.nav-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: #353b48;
  border-color: var(--accent);
}

.nav-btn:active {
  transform: scale(0.96);
}

.btn-icon {
  font-size: 16px;
}

/* 面包屑导航 */
#breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.breadcrumb-item {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.breadcrumb-item:hover {
  color: var(--accent);
  background: rgba(77, 166, 255, 0.1);
}

.breadcrumb-item.active {
  color: var(--accent);
  font-weight: bold;
}

/* 搜索框 */
#searchBox {
  position: relative;
  flex-shrink: 0;
  width: 140px;
}

#searchInput {
  width: 100%;
  height: 34px;
  padding: 6px 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 17px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, width 0.3s;
}

#searchInput:focus {
  border-color: var(--accent);
  width: 180px;
}

#searchInput::placeholder {
  color: var(--text-muted);
}

/* 搜索结果下拉 */
.dropdown {
  display: none;
  position: absolute;
  top: 38px;
  right: 0;
  width: 240px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
}

.dropdown.show {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover,
.dropdown-item:active {
  background: rgba(77, 166, 255, 0.12);
}

.dropdown-item .item-name {
  font-weight: bold;
  display: block;
}

.dropdown-item .item-location {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.dropdown-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* --- 主内容区 --- */
#mainContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 地图容器 */
#mapContainer {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

#mapChart {
  flex: 1;
  min-height: 300px;
}

.hint-text {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* --- 人员列表 --- */
#personList {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px;
}

#personListHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 12px;
  flex-shrink: 0;
}

#personListTitle {
  font-size: 18px;
  color: var(--accent);
}

#personCount {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 3px 10px;
  border-radius: 12px;
}

#personCards {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 20px;
}

/* 人员卡片 */
.person-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.person-card:hover {
  border-color: var(--accent);
}

.person-card.highlighted {
  border-color: var(--highlight);
  box-shadow: 0 0 12px rgba(255, 213, 79, 0.2);
  background: var(--highlight-bg);
  animation: pulseHighlight 2s ease-in-out;
}

@keyframes pulseHighlight {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 213, 79, 0.2); }
  50% { box-shadow: 0 0 20px rgba(255, 213, 79, 0.5); }
}

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

.person-card .card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  flex-shrink: 0;
}

.person-card .card-name {
  font-size: 17px;
  font-weight: bold;
  color: var(--text-primary);
}

.person-card .card-class {
  font-size: 12px;
  color: var(--text-secondary);
}

.person-card .card-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 13px;
}

.person-card .info-item {
  display: flex;
  flex-direction: column;
}

.person-card .info-label {
  font-size: 11px;
  color: var(--text-muted);
}

.person-card .info-value {
  color: var(--text-primary);
  word-break: break-all;
}

.person-card .card-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

/* --- 加载和错误 --- */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26, 29, 35, 0.9);
  z-index: 300;
}

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

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

.loading-overlay p {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.error-toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: var(--danger);
  color: white;
  border-radius: 20px;
  font-size: 14px;
  z-index: 400;
  animation: fadeInOut 3s ease;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- 底部 --- */
#footer {
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#footer small {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- 滚动条 --- */
::-webkit-scrollbar {
  width: 4px;
}

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

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

/* --- 响应式 --- */
@media (min-width: 500px) {
  #searchBox {
    width: 170px;
  }

  #searchInput:focus {
    width: 220px;
  }

  .person-card .card-info {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (min-width: 768px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
