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

/* hidden 屬性必須壓過下方各處的 display 規則,否則 modal/登出鈕會常駐顯示 */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Helvetica Neue", Arial, sans-serif;
  color: #1f2937;
  background: #f9fafb;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  z-index: 500;
}

header h1 {
  font-size: 20px;
  font-weight: 600;
}

#auth-area button {
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#auth-area button:hover { background: #f3f4f6; }

#user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#sidebar {
  width: 300px;
  background: white;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.filter-bar label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.filter-bar label:hover { background: #f3f4f6; }

/* 標記開關:色點對應地圖標記顏色、數量、未勾選時整組淡化 */
.filter-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.filter-item.status-visited .dot { background: #22c55e; }
.filter-item.status-wishlist .dot { background: transparent; border: 2px solid #9ca3af; }
.filter-item.status-planning .dot { background: #eab308; }
.filter-item .count {
  color: #6b7280;
  font-size: 12px;
}
.filter-item .count:not(:empty)::before { content: "("; }
.filter-item .count:not(:empty)::after { content: ")"; }
.filter-item:has(input:not(:checked)) { opacity: 0.4; }
.filter-bar input { accent-color: #3b82f6; }

#toggle-all-btn {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  color: #374151;
}
#toggle-all-btn:hover { background: #f3f4f6; }

.hint {
  padding: 10px 12px;
  font-size: 12px;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

#place-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.place-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
}

.place-item:hover { background: #f9fafb; }

.place-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.place-item.status-visited .dot { background: #22c55e; }
.place-item.status-wishlist .dot { background: transparent; border: 2px solid #9ca3af; }
.place-item.status-planning .dot { background: #eab308; }

.place-info { flex: 1; min-width: 0; }
.place-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }

#map {
  flex: 1;
  z-index: 1;
}

/* Custom map markers */
.custom-marker {
  background: transparent;
  border: none;
}

.marker-pin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Popup content */
.popup-content h3 { margin-bottom: 6px; font-size: 15px; }
.popup-content p { margin-bottom: 4px; font-size: 13px; }
.popup-content .status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: white;
  margin-bottom: 8px;
}
.popup-content .status-visited { background: #22c55e; }
.popup-content .status-wishlist { background: #9ca3af; }
.popup-content .status-planning { background: #eab308; }
.popup-content button {
  margin-top: 6px;
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

/* Popup media */
.popup-photos {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.popup-photo {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.popup-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 6px;
  margin: 8px 0;
}

.popup-video-file {
  width: 100%;
  max-height: 220px;
  border-radius: 6px;
  margin: 8px 0;
  background: #000;
}

/* Video chips in modal */
.video-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.video-preview:empty { display: none; }

.video-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 13px;
}

.video-chip .photo-remove {
  position: static;
  flex-shrink: 0;
}

/* Photo preview in modal */
.photo-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.photo-preview:empty { display: none; }

.photo-thumb {
  position: relative;
  width: 72px;
  height: 72px;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  margin: 0;
}

.photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #ef4444;
  color: white;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.modal-content h2 { margin-bottom: 16px; font-size: 18px; }

#place-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

#place-form input,
#place-form select,
#place-form textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

#place-form textarea { resize: vertical; }

#place-form input:focus,
#place-form select:focus,
#place-form textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modal-buttons button {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.btn-primary { background: #3b82f6; color: white; flex: 1; }
.btn-primary:hover { background: #2563eb; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: #f3f4f6; color: #374151; }
.btn-ghost:hover { background: #e5e7eb; }

/* Setup warning */
.setup-warning {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 500px;
  margin: 0 auto;
  padding: 16px 20px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  z-index: 2000;
  font-size: 14px;
}

.setup-warning code {
  background: rgba(0,0,0,0.08);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
}

.setup-warning p { margin-top: 6px; }

/* Mobile */
@media (max-width: 768px) {
  main { flex-direction: column; }
  #sidebar { width: 100%; height: 200px; border-right: none; border-bottom: 1px solid #e5e7eb; }
  header h1 { font-size: 16px; }
}
