/* css/app.css
 * 应用样式 —— 从 v12 抽出，不改任何视觉行为
 * 后续如果想换主题，可以拆成 tokens.css + components.css
 */

* { box-sizing: border-box; }

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f8fafc;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  color: #1f2937;
}

@media (min-width: 768px) { body { flex-direction: row; } }

/* ─── Sidebar ────────────────────────────────────────── */

.sidebar {
  width: 100%;
  height: 50vh;
  background: white;
  box-shadow: 2px 0 15px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

@media (min-width: 768px) { .sidebar { width: 35%; height: 100vh; } }

.header {
  padding: 24px 24px 12px 24px;
  background: linear-gradient(to right, #fdf2f8, #fef2f2);
  border-bottom: 1px solid #fee2e2;
  flex-shrink: 0;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header h1 {
  margin: 0;
  font-size: 22px;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-trip-btn {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid #ef4444;
  background: #ef4444;
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.share-trip-btn:hover { background: #dc2626; }

.header p {
  margin: 8px 0 0 0;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

/* ─── Tabs ──────────────────────────────────────────── */

.tabs-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px 16px 24px;
  background: linear-gradient(to right, #fdf2f8, #fef2f2);
  border-bottom: 1px solid #fee2e2;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar,
.itinerary-list::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid #fca5a5;
  background: white;
  color: #ef4444;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.tab-btn:hover { transform: translateY(-1px); }
.tab-btn.active { background: #ef4444; color: white; border-color: #ef4444; }

.itinerary-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: none;
}

/* ─── Map ───────────────────────────────────────────── */

.map-container {
  width: 100%;
  height: 50vh;
  background: #e5e7eb;
  position: relative;
  z-index: 10;
}

@media (min-width: 768px) { .map-container { width: 65%; height: 100vh; } }
#map { width: 100%; height: 100%; }

.status-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  background: rgba(255,255,255,0.95);
  border: 1px solid #fee2e2;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  color: #4b5563;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  line-height: 1.45;
}

@media (min-width: 768px) {
  .status-panel { left: 16px; right: auto; bottom: 16px; max-width: 460px; }
}

.status-panel strong { color: #ef4444; }

.custom-marker {
  background-color: #ef4444;
  color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
  border: 2px solid white;
}

/* ─── Day groups & cards ────────────────────────────── */

.day-group { margin-bottom: 32px; position: relative; }

.day-title {
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(4px);
  z-index: 10;
  padding: 8px 0;
  border-bottom: 2px solid #f87171;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 700;
  color: #ef4444;
}

.day-add-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px dashed #ef4444;
  background: white;
  color: #ef4444;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.day-add-btn:hover {
  background: #ef4444;
  color: white;
  border-style: solid;
}

.event-container {
  padding-left: 8px;
  border-left: 2px solid #f3f4f6;
  margin-left: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: white;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #f3f4f6;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  cursor: pointer;
  border-left: 4px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  transition: all 0.2s ease;
}

.card:hover { transform: translateX(4px); border-left-color: #fca5a5; }
.card.active { border-left-color: #ef4444; background-color: #fef2f2; }
.card.dragging { opacity: 0.55; }
.card.drag-over {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.card::before {
  content: '';
  width: 12px;
  height: 12px;
  background: #e5e7eb;
  border-radius: 50%;
  position: absolute;
  left: -27px;
  top: 24px;
  border: 2px solid white;
  transition: background 0.2s;
}

.card.active::before { background: #ef4444; }
.drag-handle {
  width: 20px;
  min-height: 28px;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: grab;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.drag-handle:active { cursor: grabbing; }
.drag-handle:hover { color: #ef4444; }

.card-icon { font-size: 24px; margin-top: 2px; }
.card-content { flex: 1; min-width: 0; }
.card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.time-badge { background: #f3f4f6; color: #4b5563; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.event-desc { font-size: 14px; font-weight: 700; color: #1f2937; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.event-action-btn {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #4b5563;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.event-action-btn:hover:not(:disabled) {
  border-color: #ef4444;
  color: #ef4444;
  background: #fef2f2;
}

.event-action-btn.danger:hover:not(:disabled) {
  border-color: #dc2626;
  color: #dc2626;
}

.event-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.location-info {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.4;
}

.location-icon { width: 14px; height: 14px; flex-shrink: 0; }

/* ─── Route cards ───────────────────────────────────── */

.route-card {
  --route-color: #ef4444;
  margin: -4px 0 -4px 40px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--route-color) 60%, white);
  border-left-width: 6px;
  background: white;
  color: #374151;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  cursor: pointer;
  transition: all 0.2s ease;
}

.route-card:hover { background: #ffffbf; transform: translateX(2px); }
.route-card.loading { background: #f8fafc; }
.route-card.error, .route-card.estimated { background: #fff7ed; border-style: dashed; }

.route-card-main { display: flex; gap: 10px; align-items: flex-start; }

.route-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--route-color) 16%, white);
  color: var(--route-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.route-body { flex: 1; min-width: 0; }

.route-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.45;
}

.route-mode {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--route-color) 14%, white);
  color: var(--route-color);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.route-meta, .route-placeholder {
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.45;
}

.route-steps {
  margin: 8px 0 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.route-step {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  font-size: 12px;
  color: #4b5563;
  line-height: 1.45;
}

.route-step-index {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ─── InfoWindow ────────────────────────────────────── */

.amap-info-content { border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); padding: 12px !important; }
.info-window-content { min-width: 160px; }
.info-window-title { font-weight: 700; color: #1f2937; font-size: 14px; margin: 0 0 6px 0; }
.info-window-addr { font-size: 12px; color: #6b7280; margin: 0; line-height: 1.4; }

/* ─── 搜索/添加地点 弹窗 ────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modal-fade-in 0.15s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: white;
  border-radius: 16px;
  width: min(520px, 100%);
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(to right, #fdf2f8, #fef2f2);
  border-bottom: 1px solid #fee2e2;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close:hover { background: rgba(239, 68, 68, 0.08); color: #ef4444; }

.modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.modal-search-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.modal-search-input:focus {
  outline: none;
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.modal-search-btn {
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  background: #ef4444;
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.modal-search-btn:hover { background: #dc2626; }

.modal-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 2px;
}

.modal-hint {
  font-size: 13px;
  color: #6b7280;
  padding: 12px 4px;
  text-align: center;
}

.modal-result-item {
  width: 100%;
  text-align: left;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.modal-result-item:hover {
  border-color: #fca5a5;
  background: #fef2f2;
}

.modal-result-item.selected {
  border-color: #ef4444;
  background: #fef2f2;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

.modal-result-name {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 2px;
}

.modal-result-addr {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
}

.modal-event-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid #f3f4f6;
  padding-top: 14px;
}

.modal-event-summary {
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-radius: 10px;
  padding: 10px 12px;
}

.modal-summary-name {
  font-size: 13px;
  font-weight: 700;
  color: #ef4444;
  margin-bottom: 2px;
}

.modal-summary-addr {
  font-size: 12px;
  color: #6b7280;
}

.modal-form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-form-row label {
  width: 48px;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  flex-shrink: 0;
}

.modal-form-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}

.modal-form-row input:focus {
  outline: none;
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.modal-cancel,
.modal-submit {
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.modal-cancel {
  background: white;
  border: 1px solid #e5e7eb;
  color: #4b5563;
}

.modal-cancel:hover { background: #f9fafb; }

.modal-submit {
  background: #ef4444;
  border: 1px solid #ef4444;
  color: white;
}

.modal-submit:hover { background: #dc2626; }

.share-modal { max-width: 620px; }

.share-url-input {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: #374151;
}

.share-url-input:focus {
  outline: none;
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.editor-modal { max-width: 560px; }

.editor-form { gap: 10px; }

.editor-section-title {
  font-size: 13px;
  font-weight: 800;
  color: #ef4444;
  padding-top: 4px;
}

.editor-results:empty {
  display: none;
}

.editor-coords-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.editor-coords-row .modal-form-row label {
  width: 42px;
}

@media (max-width: 640px) {
  .editor-coords-row {
    grid-template-columns: 1fr;
  }
}
