/* === RESET & BASE === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #22263a;
  --bg-input: #13151d;
  --border: #2a2e3d;
  --border-focus: #6366f1;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* === HEADER === */
.header {
  background: linear-gradient(135deg, #1a1d27 0%, #0f1117 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 28px; }

.logo h1 {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
}

.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.stat-divider { width: 1px; height: 32px; background: var(--border); }

/* === MAIN === */
.main { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* === BREADCRUMB === */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}

.breadcrumb-item { color: var(--text-dim); cursor: pointer; }
.breadcrumb-item:hover { color: var(--accent); }
.breadcrumb-item.active { color: var(--text); font-weight: 600; cursor: default; }
.breadcrumb-separator { color: var(--text-dim); }

/* === CONTROLS BAR === */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.controls-left { display: flex; gap: 12px; flex-wrap: wrap; }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-card);
  color: var(--text);
}

.btn:hover { background: var(--bg-card-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover { box-shadow: 0 6px 24px var(--accent-glow); }
.btn-secondary { background: var(--bg-card); border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-card); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-success { background: var(--success); border-color: transparent; color: #fff; }

.btn-create {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: transparent;
  color: #fff;
  font-size: 14px;
  padding: 12px 28px;
}

.btn-create:hover { box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }

/* === TRIP GRID === */
.trip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.trip-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.trip-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
}

.trip-card-image {
  position: relative;
  height: 160px;
  background: linear-gradient(135deg, #1e2235, #2a2e3d);
  overflow: hidden;
}

.trip-card-image img { width: 100%; height: 100%; object-fit: cover; }

.trip-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-researched { background: var(--accent-glow); color: var(--accent); }
.badge-images { background: var(--warn-bg); color: var(--warn); }
.badge-created { background: var(--success-bg); color: var(--success); }

.trip-card-body { padding: 16px; }
.trip-card-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.trip-card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.trip-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-days { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.tag-region { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.tag-bubble { background: rgba(236, 72, 153, 0.15); color: #f472b6; }

.trip-card-stats { font-size: 11px; color: var(--text-dim); }

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

/* === TRIP PREVIEW === */
.preview-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.preview-cover {
  position: relative;
  width: 100%;
  height: 280px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #1e2235, #2a2e3d);
}

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

.preview-cover-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.preview-title { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.preview-description { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 16px; }
.preview-meta { display: flex; gap: 12px; flex-wrap: wrap; }

/* === DAY CARD === */
.day-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.day-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.06) 0%, transparent 100%);
}

.day-card-header h3 { font-size: 16px; font-weight: 700; }

.day-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-glow);
  color: var(--accent);
}

.day-card-desc {
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* === TRIP ROUTE MAP (single map for entire trip) === */
.trip-route-map-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

.trip-route-map-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.06) 0%, transparent 100%);
}

.trip-route-map-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.trip-route-map {
  height: 480px;
  background: var(--bg-input);
  position: relative;
  overflow: hidden;
}

.trip-route-map .map-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 13px;
}

/* Map legend */
.trip-route-legend {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.map-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.map-legend-day {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.map-legend-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.3);
}

.map-legend-label {
  color: var(--text);
  font-weight: 600;
}

.map-legend-range {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
}

.day-stops { padding: 12px; }

/* === STOP CARD === */
.stop-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

.stop-card:last-child { margin-bottom: 0; }
.stop-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.stop-type-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.type-attraction { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.type-activity { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.type-accommodation { background: rgba(236, 72, 153, 0.2); color: #f472b6; }

.stop-title { font-size: 14px; font-weight: 700; }
.stop-location { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.stop-description { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }

/* === IMAGE GALLERY === */
.stop-selected-image {
  width: 100%;
  height: 200px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 10px;
  background: var(--bg-card);
}

.stop-selected-image img { width: 100%; height: 100%; object-fit: cover; }

.stop-image-gallery { margin-top: 8px; }

.gallery-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.gallery-thumb {
  flex-shrink: 0;
  width: 90px;
  height: 65px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
  opacity: 0.7;
}

.gallery-thumb:hover { opacity: 1; border-color: var(--text-dim); }
.gallery-thumb.selected { opacity: 1; border-color: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

.gallery-thumb.set-cover-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  padding: 4px;
  opacity: 1;
}

.no-images {
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

/* === PREVIEW ACTIONS === */
.preview-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

/* === PANELS === */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 15px; font-weight: 700; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-glow);
  color: var(--accent);
}

/* === LOG === */
.panel-log { margin-top: 24px; }

.log-container {
  max-height: 200px;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.8;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.log-entry { color: var(--text-muted); padding: 1px 0; }
.log-entry.log-success { color: var(--success); }
.log-entry.log-error { color: var(--error); }
.log-entry.log-info { color: var(--accent); }

/* === EMPTY / LOADING === */
.empty-state { padding: 32px 20px; text-align: center; color: var(--text-dim); font-size: 13px; }
.loading { padding: 32px 20px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* === OVERLAY === */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.overlay[hidden] { display: none; }
.overlay-content { text-align: center; color: var(--text); max-width: 400px; }

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

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

/* === PROGRESS BAR === */
.progress-bar-container { margin-top: 16px; }

.progress-bar {
  width: 300px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .trip-grid { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; gap: 12px; }
  .controls-bar { flex-direction: column; }
  .controls-left { width: 100%; }
  .controls-left .btn { flex: 1; justify-content: center; }
}
