/* ============================================================
   旅行攻略 · 共享協作
   設計：簡約乾淨 · 墨綠主色 · 卡片式
   ============================================================ */

:root {
  --primary: #2d5f4f;        /* 墨綠 */
  --primary-light: #4a8a72;
  --primary-bg: #f0f5f2;
  --accent: #c97b3f;          /* 暖橘點綴 */
  --danger: #c0392b;
  --bg: #fafaf7;
  --card-bg: #ffffff;
  --border: #e3e6e1;
  --text: #2c2c2c;
  --text-light: #6b6b6b;
  --text-faint: #999;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --radius: 10px;
  --radius-sm: 6px;
}

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

html, body {
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
}

/* ===== 頂部 ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  position: sticky;
  top: 8px;
  z-index: 50;
  border-top: 3px solid var(--primary);
}

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

.logo { font-size: 22px; }

.brand-name {
  font-weight: 700;
  font-size: 17px;
  color: var(--primary);
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 12px;
  font-weight: 600;
}

.identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nickname-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
}

.nickname-wrap input {
  width: 110px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.nickname-wrap input:focus {
  border-color: var(--primary);
}

.save-status {
  font-size: 12px;
  color: var(--text-faint);
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--primary-bg);
  min-width: 70px;
  text-align: center;
}

.save-status.saving { background: #fff8e6; color: #b07d00; }
.save-status.saved { background: #e8f5ed; color: var(--primary); }
.save-status.error { background: #fde6e3; color: var(--danger); }

/* ===== 加載 / 錯誤 ===== */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--primary-bg);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.9s linear infinite;
}

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

.error-banner {
  background: #fde6e3;
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}

/* ===== 主內容 ===== */
.main.hidden,
.hidden { display: none !important; }

/* ===== 卡片 ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.card-body { padding: 18px; }

.edit-toggle,
.btn-add {
  background: var(--card-bg);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 5px 14px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.edit-toggle:hover,
.btn-add:hover {
  background: var(--primary);
  color: white;
}

/* ===== 元信息 ===== */
.trip-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}

.trip-meta-row {
  display: flex;
  gap: 18px;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.cover-note {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  margin-bottom: 8px;
}

.updated-by {
  font-size: 12px;
  color: var(--text-faint);
}

/* ===== 表單 ===== */
label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
}

input[type="text"],
input[type="date"],
input[type="time"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  background: white;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

textarea { resize: vertical; min-height: 60px; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.btn-primary:hover { background: var(--primary-light); }

.btn-primary:disabled {
  background: var(--text-faint);
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}

.btn-ghost:hover { background: var(--primary-bg); }

.btn-ghost-small {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}

.btn-ghost-small:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  padding: 0 6px;
}

.btn-icon:hover { color: var(--danger); }

.btn-text {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

.btn-text:hover { text-decoration: underline; }

/* ===== 每日行程 ===== */
.day-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  background: white;
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--primary-bg) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}

.day-header h3 {
  font-size: 15px;
  color: var(--primary);
  font-weight: 700;
}

.day-date-view {
  font-size: 12px;
  color: var(--text-faint);
}

.day-actions {
  display: flex;
  gap: 6px;
}

.day-view { padding: 12px 16px; }

.items-list {
  list-style: none;
  padding: 0;
}

.items-list li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 8px;
  font-size: 14px;
}

.items-list li:last-child { border-bottom: none; }

.items-list .item-time {
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.items-list .item-title {
  font-weight: 600;
  color: var(--text);
}

.items-list .item-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
}

.day-edit { padding: 14px 16px; }

.items-editor { margin: 8px 0; }

.item-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr 1.4fr 30px;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}

.item-row input {
  padding: 6px 8px;
  font-size: 13px;
}

/* ===== 餐廳 / 備註網格 ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.sub-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: white;
  transition: box-shadow 0.15s;
}

.sub-card:hover { box-shadow: var(--shadow); }

.sub-view h4 {
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 6px;
  font-weight: 700;
}

.r-line, .n-content {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.r-rating {
  color: var(--accent);
  font-size: 14px;
  margin: 4px 0;
}

.r-notes, .n-content {
  font-size: 13px;
  color: var(--text);
  margin: 4px 0 8px;
  white-space: pre-wrap;
}

.note-cat {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

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

.sub-edit label {
  margin-bottom: 10px;
}

/* ===== 頁腳 ===== */
.footer {
  text-align: center;
  padding: 24px 0;
  color: var(--text-faint);
  font-size: 12px;
}

.footer p { margin-bottom: 8px; }

/* ===== 響應式 ===== */
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .identity {
    justify-content: space-between;
  }
  .nickname-wrap input { flex: 1; }
  .item-row {
    grid-template-columns: 1fr 1fr;
  }
  .item-row input { width: 100%; }
  .trip-meta-row {
    flex-direction: column;
    gap: 4px;
  }
}