/* ============================================
   Footprint Baxi · 样式
   配色:温暖童趣,主色调八喜专属
   ============================================ */

:root {
  --color-primary: #ff8a65;       /* 暖橙 */
  --color-primary-dark: #f57c4e;
  --color-success: #66bb6a;
  --color-danger: #ef5350;
  --color-secondary: #42a5f5;
  --color-bg: #fafafa;
  --color-card: #ffffff;
  --color-text: #2c2c2c;
  --color-text-light: #757575;
  --color-border: #e0e0e0;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-modal: 0 8px 32px rgba(0,0,0,0.18);
  --radius: 12px;
  --radius-sm: 6px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ============ 顶部栏 ============ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
}

.topbar-left { display: flex; align-items: baseline; gap: 12px; }

.title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--color-primary);
}

.subtitle {
  font-size: 12px;
  color: var(--color-text-light);
}

.topbar-right { display: flex; gap: 8px; align-items: center; }

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--color-bg);
  border-radius: 20px;
}

.user-info img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

/* ============ 按钮 ============ */
.btn {
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-success { background: var(--color-success); color: white; }
.btn-danger { background: var(--color-danger); color: white; }
.btn-secondary { background: var(--color-secondary); color: white; }
.btn-ghost { background: transparent; color: var(--color-text-light); border: 1px solid var(--color-border); }
.btn-ghost:hover { background: var(--color-bg); }

.btn-lg { padding: 12px 32px; font-size: 16px; }

/* ============ 主体布局 ============ */
.main {
  position: absolute;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  right: 0;
}

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

/* ============ 遮罩 ============ */
.overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.overlay-content {
  text-align: center;
  padding: 32px;
  max-width: 480px;
}

.overlay-emoji {
  font-size: 64px;
  margin-bottom: 16px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.overlay-content h2 {
  margin: 0 0 8px;
  color: var(--color-primary);
}

.overlay-content p {
  color: var(--color-text-light);
  margin: 8px 0;
}

.overlay-hint {
  font-size: 12px;
  margin-top: 24px;
}

/* ============ 侧边栏 ============ */
.sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  background: white;
  box-shadow: -2px 0 8px rgba(0,0,0,0.06);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--color-text-light);
  font-weight: 600;
}

#search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.footprint-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.fp-card {
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.fp-card:hover {
  background: white;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-card);
}

.fp-card-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.fp-card-date {
  font-size: 12px;
  color: var(--color-text-light);
}

.fp-card-photo {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: white;
  border: none;
  box-shadow: var(--shadow-card);
  font-size: 20px;
  cursor: pointer;
  z-index: 70;
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  overflow-y: auto;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: slideUp 0.2s ease-out;
}

.modal-detail { max-width: 600px; }

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--color-text-light);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  line-height: 1;
}

.modal-close:hover { background: var(--color-bg); }

/* ============ 表单 ============ */
#footprint-form {
  padding: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-half { flex: 1; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.req { color: var(--color-danger); }

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input { flex: 1; }

.coord-display {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-success);
  font-family: monospace;
}

.form-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-light);
}

/* ============ 照片预览 ============ */
.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.photo-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-bg);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.photo-thumb.uploading { opacity: 0.5; }

/* ============ 进度条 ============ */
.upload-progress {
  margin-top: 12px;
  padding: 12px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  width: 0%;
  transition: width 0.2s;
}

#progress-text {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-light);
  text-align: center;
}

/* ============ 操作按钮 ============ */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.form-actions .btn-danger { margin-right: auto; }

/* ============ 详情弹窗 ============ */
#detail-body {
  padding: 20px;
}

#detail-body img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

#detail-body .detail-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

#detail-body .detail-photos img {
  height: 100px;
  object-fit: cover;
  margin-bottom: 0;
}

#detail-body .detail-notes {
  white-space: pre-wrap;
  background: var(--color-bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.detail-meta {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 12px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 999;
  box-shadow: var(--shadow-modal);
  animation: toastIn 0.2s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ 高德 marker 自定义 ============ */
.baxi-marker {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s;
}

.baxi-marker:hover {
  transform: scale(1.15);
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
  .subtitle { display: none; }
  .sidebar { width: 100%; }
  .user-info span { display: none; }
  .topbar { padding: 0 12px; }
  .title { font-size: 16px; }
}

/* 让高德信息窗体更圆 */
.amap-info-window {
  border-radius: var(--radius-sm);
}