/* ===== CSS Variables (Theme System) ===== */
:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-tab: #f1f5f9;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --accent-transport: #059669;
  --accent-sightseeing: #d97706;
  --accent-food: #dc2626;
  --accent-hotel: #7c3aed;
  --accent-budget-transport: #059669;
  --accent-budget-hotel: #7c3aed;
  --accent-budget-food: #dc2626;
  --accent-budget-souvenir: #ec4899;
  --accent-budget-leisure: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ===== App Shell ===== */
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* ===== Header ===== */
.header {
  background: var(--primary);
  color: white;
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 { font-size: 1rem; font-weight: 600; }
.header-actions { display: flex; gap: 8px; }
.btn-icon {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.btn-icon:hover { background: rgba(255,255,255,0.3); }

/* ===== Trip Selector ===== */
.trip-selector {
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.trip-selector select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  background: white;
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ===== Tab Navigation ===== */
.tab-nav {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 90;
}
.tab-btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tab-btn .tab-icon { font-size: 1.2rem; }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== Content Area ===== */
.tab-content { flex: 1; padding: 16px 16px 100px; }
.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== Cover Tab ===== */
.cover {
  text-align: center;
  padding: 32px 16px;
}
.cover-icon { font-size: 4rem; margin-bottom: 12px; }
.cover-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}
.cover-period {
  font-size: 1rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 20px;
}
.cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}
.cover-purpose {
  background: var(--bg-tab);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}
.cover-divider {
  width: 40px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  margin: 20px auto;
}

/* ===== Schedule Tab ===== */
.day-section { margin-bottom: 24px; }
.day-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
}
.day-badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}
.day-date { font-size: 0.85rem; color: var(--text-secondary); }

.itinerary-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
}
.itinerary-card[data-genre="transport"] { border-left-color: var(--accent-transport); }
.itinerary-card[data-genre="sightseeing"] { border-left-color: var(--accent-sightseeing); }
.itinerary-card[data-genre="food"] { border-left-color: var(--accent-food); }
.itinerary-card[data-genre="hotel"] { border-left-color: var(--accent-hotel); }

.itinerary-time {
  min-width: 52px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding-top: 2px;
}
.itinerary-body { flex: 1; min-width: 0; }
.itinerary-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.itinerary-genre { font-size: 1rem; }
.itinerary-name { font-size: 0.95rem; font-weight: 600; }
.itinerary-memo {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: pre-line;
  margin-bottom: 4px;
}
.itinerary-facility {
  font-size: 0.75rem;
  color: var(--text-light);
  background: var(--bg-tab);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.itinerary-actions { display: flex; gap: 8px; margin-top: 4px; }
.action-link {
  font-size: 0.75rem;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
}
.action-link:hover { text-decoration: underline; }

/* Timeline connector */
.timeline-connector {
  width: 2px;
  height: 8px;
  background: var(--border);
  margin: 0 auto 0 36px;
}

/* ===== Budget Tab ===== */
.budget-summary {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.budget-total-label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; }
.budget-total-value { font-size: 2rem; font-weight: 700; color: var(--text); }

.budget-chart {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin: 16px 0 12px;
}
.budget-chart-segment { height: 100%; transition: width 0.5s ease; }

.budget-categories { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 16px; }
.budget-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.budget-cat-dot { width: 8px; height: 8px; border-radius: 50%; }

.budget-items { margin-top: 16px; }
.budget-category-section { margin-bottom: 16px; }
.budget-category-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.budget-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
}
.budget-item-name { color: var(--text); flex: 1; }
.budget-item-qty { color: var(--text-light); font-size: 0.8rem; margin: 0 12px; }
.budget-item-amount { font-weight: 600; color: var(--text); white-space: nowrap; }

/* ===== Packing Tab ===== */
.packing-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.8rem;
  font-family: var(--font);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.filter-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.packing-genre-section { margin-bottom: 20px; }
.packing-genre-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.packing-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  box-shadow: var(--shadow);
}
.packing-checkbox {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 0.8rem;
  background: white;
}
.packing-checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.packing-item-name { flex: 1; font-size: 0.9rem; }
.packing-item-name.checked { text-decoration: line-through; color: var(--text-light); }
.packing-class-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-tab);
  color: var(--text-secondary);
}

.packing-progress {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.packing-progress-bar {
  height: 8px;
  background: var(--bg-tab);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.packing-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.packing-progress-text { font-size: 0.8rem; color: var(--text-secondary); text-align: right; }

/* ===== PDF Button (floating) ===== */
.fab-pdf {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px; height: 56px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  transition: transform 0.2s;
}
.fab-pdf:hover { transform: scale(1.1); }

/* ===== Loading & Empty ===== */
.loading { text-align: center; padding: 40px; color: var(--text-light); }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }

/* ===== Utility ===== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ===== Print / PDF ===== */
@media print {
  .header, .tab-nav, .trip-selector, .fab-pdf, .packing-checkbox { display: none !important; }
  .tab-panel { display: block !important; page-break-inside: avoid; }
  .app { max-width: 100%; }
  body { background: white; }
}
