/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
}
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 6px 12px;
  border-radius: 6px;
}
button:hover { background: #f9fafb; }

/* Key prompt overlay */
.key-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.key-prompt[hidden] { display: none; }
.key-prompt__box {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}
.key-prompt__box h2 { margin-top: 0; }
.key-prompt__box input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  margin: 8px 0 16px;
}
.key-prompt__buttons { display: flex; gap: 8px; justify-content: flex-end; }
.key-prompt__error { color: #b91c1c; margin-top: 8px; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  height: 56px;
}
.topbar__title { font-weight: 600; font-size: 16px; }
.topbar__stats { color: #6b7280; flex: 1; }
.topbar__buttons { display: flex; gap: 8px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: calc(100vh - 56px);
}
.sidebar {
  overflow-y: auto;
  background: #f9fafb;
  border-right: 1px solid #e5e7eb;
  padding: 12px;
}
.map { width: 100%; height: 100%; }

/* Cards */
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.card--highlight { box-shadow: 0 0 0 2px #1a73e8; transition: box-shadow 0.3s; }
.card__date { font-weight: 600; margin-bottom: 6px; }
.card__leg { color: #6b7280; font-size: 12px; margin-bottom: 6px; }
.card__total { color: #374151; font-size: 12px; font-weight: 600; margin-top: 6px; padding-top: 6px; border-top: 1px solid #e5e7eb; }
.card__pin { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }

/* Shared plan panel */
.shared-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.shared-panel__title { font-weight: 600; margin-bottom: 4px; }
.shared-panel__status { color: #6b7280; font-size: 12px; margin-bottom: 8px; }
.shared-panel__buttons { display: flex; gap: 6px; }
.shared-panel__buttons button {
  font-size: 12px;
  padding: 4px 8px;
  flex: 1;
}
.shared-panel__buttons button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.card__pin-type {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
}
.card__pin-type--stay { background: #dbeafe; color: #1d4ed8; }
.card__pin-type--visit { background: #fef3c7; color: #b45309; }
.card__pin-name { flex: 1; min-width: 120px; }
/* PlaceAutocompleteElement — make it look like a regular input */
.card__pin-autocomplete {
  display: block;
  width: 100%;
}
.card__pin-autocomplete input {
  width: 100%;
  border: 1px solid transparent;
  padding: 4px 6px;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  color: inherit;
}
.card__pin-autocomplete input:focus {
  border-color: #93c5fd;
  background: #fff;
  outline: none;
}
.card__pin-name input { width: 100%; border: 1px solid transparent; padding: 4px 6px; border-radius: 4px; background: transparent; }
.card__pin-name input:focus { border-color: #93c5fd; background: #fff; outline: none; }
.card__pin-notes { width: 100%; border: 1px solid #e5e7eb; padding: 4px 6px; border-radius: 4px; font: inherit; min-height: 28px; resize: vertical; }
.card__pin-time { width: 80px; border: 1px solid #e5e7eb; padding: 4px 6px; border-radius: 4px; font: inherit; }
.card__pin-delete {
  background: transparent;
  border: none;
  color: #b91c1c;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.card__pin-delete:hover { background: #fee2e2; }
.card__add { display: flex; gap: 6px; margin-top: 6px; }
.card__add button { font-size: 12px; padding: 4px 8px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 999;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.toast[hidden] { display: none; }
.toast--error { background: #b91c1c; }

/* Print itinerary */
.print-itinerary { display: none; }
@media print {
  .no-print, .topbar, .layout, .toast, .key-prompt { display: none !important; }
  body { background: #fff; }
  .print-itinerary { display: block; padding: 24px; font-size: 11pt; color: #000; }
  .print-itinerary h1 { margin: 0 0 4px; font-size: 18pt; }
  .print-itinerary .subtitle { color: #555; margin-bottom: 16px; }
  .print-itinerary .day { margin-bottom: 14px; page-break-inside: avoid; }
  .print-itinerary .day__date { font-weight: 600; margin-bottom: 4px; }
  .print-itinerary .day__stay { margin-left: 12px; }
  .print-itinerary .day__visit { margin-left: 24px; font-size: 10pt; }
  .print-itinerary .day__notes { margin-left: 12px; font-style: italic; color: #444; }
  .print-itinerary .day__leg { margin-left: 12px; color: #555; font-size: 10pt; }
  .print-itinerary .day__total { margin-top: 6px; padding-top: 4px; border-top: 1px solid #999; font-weight: 600; font-size: 10pt; }
  .print-itinerary .totals { margin-top: 24px; font-weight: 600; border-top: 1px solid #000; padding-top: 8px; }
}

/* Mobile: bottom drawer */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: calc(100vh - 56px);
  }
  .sidebar {
    order: 2;
    height: 35vh;
    border-right: none;
    border-top: 1px solid #e5e7eb;
  }
  .map { order: 1; }
  .topbar__title { font-size: 14px; }
  .topbar__stats { font-size: 12px; }
  .topbar__buttons button { padding: 4px 8px; font-size: 12px; }
}
