/* Page Layout */

.places-page-header {
  margin-bottom: 2rem;
}

.places-page-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.places-page-header p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Two-column split: sidebar (left) + map (right) */
.places-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Sidebar */
.places-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  /* Sidebar scrolls independently on tall screens */
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  padding-right: 4px; /* room for scrollbar */
}

/* Thin styled scrollbar for the sidebar */
.places-sidebar::-webkit-scrollbar {
  width: 4px;
}
.places-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.places-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Add-Place Form Card */
.places-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.places-form-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.places-form-card-title span.icon {
  font-size: 1.15rem;
}

/* Compact form groups inside the panel */
.places-form-group {
  margin-bottom: 0.9rem;
}

.places-form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.places-form-group input,
.places-form-group textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid #334155;
  background: rgba(8, 16, 28, 0.8);
  color: var(--text);
  font-size: 0.875rem;
  transition:
    border-color var(--trans),
    box-shadow var(--trans);
  outline: none;
  font-family: inherit;
}

.places-form-group input:focus,
.places-form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.places-form-group input::placeholder,
.places-form-group textarea::placeholder {
  color: var(--muted);
}

.places-form-group textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

/* Coordinates are read-only and visually distinct */
.places-coords-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.places-coord-input {
  background: rgba(6, 182, 212, 0.06) !important;
  border-color: rgba(6, 182, 212, 0.25) !important;
  color: var(--accent) !important;
  font-size: 0.8rem !important;
  cursor: not-allowed;
}

/* Search-box wrapper (Google Places Autocomplete) */
.places-search-wrapper {
  position: relative;
}

.places-search-wrapper::before {
  content: "🔍";
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 1;
}

.places-search-wrapper input {
  padding-left: 2.1rem !important;
}

/* Hint text below inputs */
.places-input-hint {
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 0.3rem;
  line-height: 1.4;
}

/* Alert messages inside the form card */
.places-alert {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 0.8rem;
  display: none; /* shown via JS */
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.45;
}

.places-alert.show {
  display: flex;
}

.places-alert-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.places-alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* Save button spanning full width */
.places-save-btn {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--grad);
  color: #001 !important;
  font-weight: 700;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all var(--trans);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.2);
  margin-top: 0.5rem;
}

.places-save-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(6, 182, 212, 0.35);
}

.places-save-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Saved Places List */
.places-list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.places-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.places-list-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.places-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 50px;
  background: rgba(6, 182, 212, 0.18);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Empty-state placeholder */
.places-empty {
  text-align: center;
  padding: 1.8rem 1rem;
  color: var(--muted);
}

.places-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.7rem;
  display: block;
  opacity: 0.6;
}

.places-empty p {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Individual saved-place item */
.place-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin-bottom: 0.7rem;
  background: rgba(255, 255, 255, 0.025);
  transition: all var(--trans);
  cursor: pointer;
  position: relative;
}

.place-item:last-child {
  margin-bottom: 0;
}

.place-item:hover {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.05);
  transform: translateX(3px);
}

/* Highlighted when selected on the map */
.place-item.place-item--active {
  border-color: var(--accent);
  background: rgba(6, 182, 212, 0.08);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.place-item-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
  padding-right: 2rem; /* room for delete button */
  line-height: 1.3;
}

.place-item-address {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  line-height: 1.35;
}

.place-item-coords {
  font-size: 0.72rem;
  color: rgba(6, 182, 212, 0.7);
  font-family: "Courier New", monospace;
  margin-bottom: 0.3rem;
}

.place-item-notes {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.35;
  margin-top: 0.3rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.place-item-date {
  font-size: 0.7rem;
  color: #475569;
  margin-top: 0.4rem;
}

/* Delete button — overlaid top-right of each place item */
.place-delete-btn {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: transparent;
  border: none;
  color: #475569;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  line-height: 1;
  transition: all var(--trans);
}

.place-delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* Loading skeleton while fetching */
.places-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.places-skeleton-item {
  height: 72px;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
}

@keyframes skeletonShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Map Panel  */
.places-map-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Google Map container */
.places-map-container {
  width: 100%;
  height: 560px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  background: var(--bg2);
}

/* Shown before the Maps API loads */
.places-map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--bg2);
  z-index: 10;
  transition: opacity 0.4s ease;
}

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

.places-map-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinMap 0.8s linear infinite;
}

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

/* The actual div that Google Maps renders into */
#placesMap {
  width: 100%;
  height: 100%;
}

/* Map tip bar */
.places-map-tip {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.4;
}

.places-map-tip strong {
  color: var(--accent);
}

/* Map Info-Window (custom Google Maps popup) */
.gm-style .places-info-window {
  padding: 0.5rem 0.25rem;
  min-width: 160px;
  max-width: 220px;
}

.places-info-window-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #111827;
  margin-bottom: 0.2rem;
}

.places-info-window-addr {
  font-size: 0.78rem;
  color: #6b7280;
  line-height: 1.35;
}

/* Stats bar */
.places-stats-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.places-stat {
  flex: 1;
  min-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.places-stat-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.places-stat-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.places-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

/* Delete-confirmation modal  */
.places-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.places-modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.places-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-lg);
}

.places-modal-backdrop.show .places-modal {
  transform: scale(1);
}

.places-modal-icon {
  font-size: 2.4rem;
  margin-bottom: 0.75rem;
  display: block;
}

.places-modal h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.places-modal p {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.places-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* Responsive  */
@media (max-width: 900px) {
  .places-layout {
    grid-template-columns: 1fr;
  }

  .places-sidebar {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  /* On mobile the map comes first for visual impact */
  .places-map-panel {
    order: -1;
  }

  .places-map-container {
    height: 380px;
  }
}

@media (max-width: 480px) {
  .places-form-card,
  .places-list-card {
    padding: 1rem;
  }

  .places-map-container {
    height: 300px;
  }

  .places-coords-row {
    grid-template-columns: 1fr;
  }

  .places-stats-bar {
    flex-direction: column;
  }

  .places-modal-actions {
    flex-direction: column;
  }
}
