/* ============================================================
   Edit mode + sync UI
   ============================================================ */

/* ---- Hero controls (gear, edit toggle, sync status) ---- */
.hero { position: relative; }
.settings-btn,
.edit-toggle-btn {
  position: absolute;
  top: 12px;
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  z-index: 2;
  font-family: inherit;
  transition: background 0.15s;
}
.settings-btn { right: 12px; padding: 6px 10px; font-size: 16px; line-height: 1; }
.edit-toggle-btn { right: 56px; }
.settings-btn:hover,
.edit-toggle-btn:hover { background: rgba(255,255,255,0.22); }
.edit-toggle-btn.active {
  background: var(--vermilion);
  border-color: var(--vermilion);
}
.sync-status {
  position: absolute;
  top: 50px;
  right: 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  z-index: 2;
  text-align: right;
  min-height: 14px;
  pointer-events: none;
}
.sync-status.error { color: #ffb4b4; }
.sync-status.success { color: #b4ffb4; }

/* ---- Modal foundation ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-panel {
  background: var(--paper);
  border-radius: 14px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header h2 {
  font-size: 17px;
  color: var(--ink);
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--ink-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 18px 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---- Form elements ---- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input[type="text"],
.field input[type="password"],
.field input[type="time"],
.field textarea,
.field select {
  width: 100%;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
}
.field textarea { min-height: 70px; resize: vertical; }
.field .hint {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 4px;
}
.field-row {
  display: flex;
  gap: 10px;
}
.field-row .field { flex: 1; margin-bottom: 14px; }

.radio-group {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.radio-group label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  background: var(--paper);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--ink);
}
.radio-group label:has(input:checked) {
  border-color: var(--indigo);
  background: rgba(26,58,92,0.06);
  color: var(--indigo);
  font-weight: 600;
}
.radio-group input { accent-color: var(--indigo); }

.btn {
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
}
.btn:hover { background: var(--cream); }
.btn.primary {
  background: var(--indigo);
  border-color: var(--indigo);
  color: white;
}
.btn.primary:hover { background: var(--indigo-dark); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.bin-link {
  display: block;
  background: var(--cream);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
  margin-top: 6px;
  color: var(--indigo);
}

/* ---- Edit mode: visual cues for editable elements ---- */
body.edit-mode [data-edit] {
  cursor: text;
  outline: 1px dashed transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s, background 0.15s;
  border-radius: 3px;
}
body.edit-mode [data-edit]:hover {
  outline-color: rgba(194,59,34,0.5);
  background: rgba(244,194,194,0.15);
}
body.edit-mode [data-edit]:focus {
  outline: 2px solid var(--vermilion);
  background: rgba(244,194,194,0.25);
}
body.edit-mode [data-edit][contenteditable="true"] {
  outline-color: rgba(194,59,34,0.4);
}

/* Inline action chips (edit, location, delete) — only visible in edit mode */
.edit-action {
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 10px 4px 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: var(--ink-soft);
  line-height: 1;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.edit-action .ico { font-size: 11px; line-height: 1; }
.edit-action:hover { background: var(--cream); color: var(--indigo); border-color: var(--indigo); }
.edit-action.edit:hover { color: var(--indigo); border-color: var(--indigo); }
.edit-action.coord:hover { color: var(--green); border-color: var(--green); }
.edit-action.delete:hover { background: var(--red); color: white; border-color: var(--red); }

body.edit-mode .edit-action { display: inline-flex; }
body.edit-mode .add-btn { display: flex; }

/* Per-item action chip row — flows at the bottom of each schedule body */
.item-actions {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
body.edit-mode .item-actions { display: flex; }

/* "+ add activity" button */
.add-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  margin-top: 10px;
  background: rgba(26,58,92,0.05);
  border: 2px dashed var(--indigo);
  color: var(--indigo);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
}
.add-btn:hover { background: rgba(26,58,92,0.1); }

/* Day-level actions in detail header */
.day-actions {
  display: none;
  gap: 6px;
  margin-top: 8px;
}
body.edit-mode .day-actions { display: flex; }

/* Add-day button in overview */
.add-day-card {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 2px dashed var(--indigo);
  border-radius: 12px;
  background: rgba(26,58,92,0.03);
  color: var(--indigo);
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  font-family: inherit;
  font-size: 14px;
}
body.edit-mode .add-day-card { display: flex; }
.add-day-card:hover { background: rgba(26,58,92,0.08); }

/* ---- Geocoder results ---- */
.geocoder-results {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  max-height: 250px;
  overflow-y: auto;
  background: var(--paper);
}
.geocoder-result {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
}
.geocoder-result:last-child { border-bottom: none; }
.geocoder-result:hover { background: var(--cream); }
.geocoder-result .name { font-weight: 600; color: var(--ink); }
.geocoder-result .addr { color: var(--ink-muted); font-size: 12px; margin-top: 2px; }
.geocoder-result .coords {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.coord-display {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-muted);
  padding: 6px 10px;
  background: var(--cream);
  border-radius: 5px;
  margin-bottom: 10px;
}

/* ---- Inline edit field for time picker etc. ---- */
.inline-time {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  background: transparent;
  border: none;
  width: 70px;
  padding: 0;
}
body.edit-mode .inline-time {
  background: rgba(244,194,194,0.2);
  border-radius: 3px;
  padding: 2px 4px;
}

@media (max-width: 600px) {
  .edit-toggle-btn { font-size: 11px; padding: 5px 9px; }
  .settings-btn { padding: 5px 8px; }
  .sync-status { font-size: 10px; }
  .modal-panel { max-height: 95vh; }
  .field-row { flex-direction: column; gap: 0; }
}

/* ============================================================
   Google Maps handoff: title link, view button, button row
   ============================================================ */

/* Tappable title — looks like a normal heading, hints at link with a small icon */
.schedule-item h4 a.title-maps-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted rgba(26, 58, 92, 0.3);
  transition: border-color 0.15s, color 0.15s;
}
.schedule-item h4 a.title-maps-link:hover {
  color: var(--indigo);
  border-bottom-color: var(--indigo);
}
.schedule-item h4 a.title-maps-link::after {
  content: " 📍";
  font-size: 0.85em;
  opacity: 0.55;
  border-bottom: none;
}

/* Button row holding the two Google Maps actions */
.schedule-item .map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* The "Open in Google Maps" (search/view) button — outlined */
.view-maps-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: var(--paper);
  color: var(--indigo);
  border: 1px solid var(--indigo);
  transition: background 0.15s, color 0.15s;
}
.view-maps-btn:hover { background: var(--indigo); color: white; }

/* Map popup gets two links now — stack them nicely */
.leaflet-popup-content .popup-link + .popup-link {
  margin-left: 6px;
}

/* In edit mode, the title link should still indicate tap-to-edit; suppress the maps icon hint to avoid confusion */
body.edit-mode .schedule-item h4 a.title-maps-link::after {
  content: " ✏️";
  opacity: 0.7;
}

@media (max-width: 600px) {
  .schedule-item .map-actions { flex-direction: column; }
  .view-maps-btn, .directions-btn { width: 100%; justify-content: center; text-align: center; }
}
