/* MyNotes base tweaks layered on top of Tailwind CDN. */

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

[data-show="false"] { display: none !important; }

/* Sidebar off-canvas (TheSearch pattern) */
#sidebar {
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  will-change: transform;
}
#sidebar.open {
  transform: translateX(0);
}

/* View transitions */
.view { display: none; }
.view.active {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Toast */
.toast {
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
  pointer-events: auto;
}
@keyframes toastIn {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
@keyframes toastOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-10px); }
}

/* Note card label chips */
.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
}

/* Leaflet map picker */
.coord-map {
  height: 200px;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
}
.leaflet-control-zoom a {
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  font-size: 20px !important;
}

/* ── Appointment map container ──────────────────────────────────────────── */
#ap-map-container { margin-top: 8px; margin-bottom: 8px; }

/* ── Full-screen slide-up modals ────────────────────────────────────────── */
.modal-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #fff;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.modal-fullscreen.open  { transform: translateY(0); }
.modal-fullscreen.hidden { display: none; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  background: #fff;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  /* Modest bottom padding so the last field clears the on-screen keyboard,
     without reserving a big empty gap on a short (minimal) form. The footer
     is a flex sibling below, not an overlay, so it needs no extra clearance. */
  padding-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}
/* Tighter vertical rhythm inside forms (overrides Tailwind's space-y-4). */
.modal-body.space-y-4 > * + * { margin-top: 12px !important; }

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 8px 14px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
  background: #fff;
}

/* ── Form elements ──────────────────────────────────────────────────────── */
.form-input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: #1e293b;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.form-input:focus  { border-color: #22c55e; }
.form-textarea     { min-height: 76px; resize: vertical; }

.form-section-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  flex: 1;
  padding: 9px 16px;
  border-radius: 9px;
  background: #22c55e;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}
.btn-primary:active  { background: #16a34a; }
.btn-secondary {
  padding: 9px 16px;
  border-radius: 9px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 500;
  font-size: 14px;
  border: none;
  cursor: pointer;
}
.btn-secondary:active { background: #e2e8f0; }

/* ── Note list ──────────────────────────────────────────────────────────── */
#notes-list { display: flex; flex-direction: column; gap: 8px; }

/* ── Views ──────────────────────────────────────────────────────────────── */
.view {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  /* clear fixed header (~56px) + safe-area top, and fixed footer (~44px) */
  padding-top: calc(56px + env(safe-area-inset-top));
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}
.view.active { display: flex; }

/* ── Search filter tabs ──────────────────────────────────────────────────── */
.search-filter-tab.active { background: #22c55e; color: #fff; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ── Line clamp ─────────────────────────────────────────────────────────── */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Label color swatch — selected ring ─────────────────────────────────── */
.label-color-swatch.selected {
  border-color: #1e293b !important;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1e293b;
}

/* ── Search highlight ───────────────────────────────────────────────────── */
mark { background: #dcfce7; color: #15803d; border-radius: 3px; padding: 0 2px; }

@media (prefers-reduced-motion: reduce) {
  .toast, #sidebar, .modal-fullscreen { animation: none; transition: none; }
}

/* ── Optional fields + add-field dropdown ───────────────────────────────── */
/* Own the display state here so it never fights Tailwind's display utilities. */
.optional-field { display: none; }
.optional-field.shown { display: block; }
.add-field-wrap.hidden { display: none; }
.form-section-label.mb-0 { margin-bottom: 0; }

/* ── Pinned note indicator ──────────────────────────────────────────────── */
.note-pinned { border-color: #22c55e88 !important; }
.pin-badge { color: #16a34a; }

/* ── Clickable links rendered inside note/visit text ────────────────────── */
.note-text a, .visit-text a { color: #16a34a; text-decoration: underline; word-break: break-word; }
.note-text { white-space: pre-wrap; word-break: break-word; }
