/* OutHere Map Viewer — Styles */

/* ---------------------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------------------- */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: #f8f4f0;
  color: #1f2937;
  overflow: hidden;         /* map is full-screen */
}

/* ---------------------------------------------------------------------------
   Full-screen map
   --------------------------------------------------------------------------- */

#map {
  position: absolute;
  inset: 0;
}

/* ---------------------------------------------------------------------------
   Header bar
   --------------------------------------------------------------------------- */

.header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-title {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
  font-weight: 400;
  margin-left: 8px;
}

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

/* Layers toggle button in the header */
.layers-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.layers-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.layers-btn.active {
  background: rgba(255, 255, 255, 0.3);
}

/* ---------------------------------------------------------------------------
   Layer control panel
   --------------------------------------------------------------------------- */

.layer-panel {
  position: absolute;
  top: 56px;                /* below header */
  right: 8px;
  width: 260px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  z-index: 2;
  padding: 12px 0;
  display: none;            /* toggled via JS */
}

.layer-panel.open {
  display: block;
}

.layer-panel h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  padding: 4px 16px 8px;
}

/* Individual layer toggle row */
.layer-toggle {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.layer-toggle:hover {
  background: #f3f4f6;
}

.layer-toggle input[type="checkbox"] {
  accent-color: #667eea;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.layer-toggle .layer-name {
  font-size: 0.9rem;
  font-weight: 500;
  flex: 1;
}

/* Legend dots/swatches within each toggle row */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 16px 10px 42px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: #6b7280;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Divider between sections */
.layer-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 6px 16px;
}

/* ---------------------------------------------------------------------------
   MapLibre control overrides
   --------------------------------------------------------------------------- */

/* Push native controls below the header */
.maplibregl-ctrl-top-left,
.maplibregl-ctrl-top-right {
  top: 56px;
}

/* Push the right-side controls left of the layer panel when open */
.maplibregl-ctrl-top-right {
  right: 4px;
}

/* Style native controls to match the app */
.maplibregl-ctrl-group {
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  border: none !important;
}

.maplibregl-ctrl-group button {
  width: 36px !important;
  height: 36px !important;
}

/* Scale bar */
.maplibregl-ctrl-scale {
  background: rgba(255, 255, 255, 0.85) !important;
  border-color: #6b7280 !important;
  font-size: 11px !important;
  border-radius: 3px !important;
  padding: 1px 6px !important;
}

/* Geolocate button pulse */
.maplibregl-ctrl-geolocate {
  border-radius: 8px !important;
}

/* ---------------------------------------------------------------------------
   Loading overlay
   --------------------------------------------------------------------------- */

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(248, 244, 240, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.3s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 16px;
  font-size: 0.9rem;
  color: #6b7280;
}

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

/* ---------------------------------------------------------------------------
   Error banner
   --------------------------------------------------------------------------- */

.error-banner {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 5;
  max-width: 90%;
  text-align: center;
  display: none;
}

.error-banner.visible {
  display: block;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Planning toolbar (below header, left side)
   --------------------------------------------------------------------------- */

.planning-toolbar {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  display: none;            /* shown when plan panel is open */
  gap: 6px;
  z-index: 3;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  padding: 6px 8px;
}

.planning-toolbar.visible {
  display: flex;
}

.tool-btn {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #374151;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tool-btn:hover {
  background: #e5e7eb;
}

.tool-btn.active {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

/* ---------------------------------------------------------------------------
   Drawing hint overlay
   --------------------------------------------------------------------------- */

.drawing-hint {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 41, 55, 0.85);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.drawing-hint.visible {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   Trip planning panel (left sidebar)
   --------------------------------------------------------------------------- */

.trip-panel {
  position: absolute;
  top: 56px;
  left: 8px;
  width: 280px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  z-index: 2;
  display: none;
}

.trip-panel.open {
  display: block;
}

.trip-panel-section {
  padding: 12px 16px;
}

.trip-panel-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin-bottom: 8px;
}

.trip-panel-section label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 6px;
}

.trip-panel-section input[type="text"],
.trip-panel-section input[type="date"],
.trip-panel-section input[type="number"],
.trip-panel-section textarea,
.trip-panel-section select {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  color: #1f2937;
  margin-top: 2px;
}

.trip-panel-section input:focus,
.trip-panel-section textarea:focus,
.trip-panel-section select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.trip-dates-row {
  display: flex;
  gap: 8px;
}

.trip-dates-row label {
  flex: 1;
}

.trip-panel-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 0 16px;
}

/* ---------------------------------------------------------------------------
   Trip feature list
   --------------------------------------------------------------------------- */

.trip-empty {
  font-size: 0.8rem;
  color: #9ca3af;
  text-align: center;
  padding: 12px 0;
}

.trip-feature-row {
  display: flex;
  align-items: center;
  padding: 8px 0;
  gap: 8px;
  border-bottom: 1px solid #f3f4f6;
}

.trip-feature-row:last-child {
  border-bottom: none;
}

.trip-feature-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.trip-feature-info {
  flex: 1;
  min-width: 0;
}

.trip-feature-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trip-feature-sub {
  display: block;
  font-size: 0.75rem;
  color: #9ca3af;
}

.trip-feature-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.trip-feat-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 4px;
  color: #9ca3af;
  transition: color 0.1s, background 0.1s;
}

.trip-feat-btn:hover {
  color: #374151;
  background: #f3f4f6;
}

.trip-feat-delete:hover {
  color: #dc2626;
}

/* ---------------------------------------------------------------------------
   Trip feature edit form
   --------------------------------------------------------------------------- */

.trip-feature-form {
  display: none;
  padding: 12px 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.trip-feature-form.visible {
  display: block;
}

.trip-feature-form h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: #1f2937;
}

.trip-feature-form label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 6px;
}

.trip-feature-form input[type="text"],
.trip-feature-form input[type="number"],
.trip-feature-form textarea,
.trip-feature-form select {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  color: #1f2937;
  margin-top: 2px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem !important;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: #667eea;
  width: 16px;
  height: 16px;
}

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

.form-save {
  background: #667eea;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.form-save:hover {
  background: #5a6fd6;
}

.form-cancel {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.form-cancel:hover {
  background: #e5e7eb;
}

/* ---------------------------------------------------------------------------
   Trip action buttons
   --------------------------------------------------------------------------- */

.trip-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trip-action-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s;
}

.trip-action-btn:hover {
  background: #f3f4f6;
}

.upload-label {
  cursor: pointer;
}

.trip-action-danger {
  color: #dc2626;
  border-color: #fca5a5;
}

.trip-action-danger:hover {
  background: #fee2e2;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .header-subtitle {
    display: none;
  }

  .layer-panel {
    width: calc(100vw - 16px);
    right: 8px;
    left: 8px;
  }

  .trip-panel {
    width: calc(100vw - 16px);
    left: 8px;
    right: 8px;
  }

  .planning-toolbar {
    left: 8px;
    right: 8px;
    transform: none;
    justify-content: center;
  }
}
