/* Home visits: the address finder, the "doctor on the way" screen and the doctor's trip screen.
   Works on desktop and phones. Loaded by the patient site and the staff portal. */

/* ============================================================ address finder (booking form) */
.kd-addr { margin-top: 4px; }
.kd-addr .kd-addr-row { display: flex; gap: 8px; align-items: stretch; }
.kd-addr .kd-addr-field { position: relative; flex: 1 1 auto; min-width: 0; }
.kd-addr .kd-addr-field input { width: 100%; }
.kd-addr .kd-addr-here { flex: none; white-space: nowrap; background: var(--teal-wash, #E7F1EE); color: var(--teal-dark, #0B5347); border: 1px solid #bfe0d5;
  border-radius: 8px; padding: 0 12px; font: 600 13.5px Inter, -apple-system, sans-serif; cursor: pointer; min-height: 44px; }
.kd-addr .kd-addr-here:hover { background: #d9eae5; }
.kd-addr-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1200; margin: 0; padding: 4px; list-style: none; background: #fff;
  border: 1px solid var(--line, #E3DFD5); border-radius: 10px; box-shadow: 0 10px 30px rgba(23,38,31,.16); max-height: 260px; overflow-y: auto; }
.kd-addr-list li { padding: 9px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; line-height: 1.3; }
.kd-addr-list li small { display: block; color: var(--ink-soft, #5B6B65); font-size: 12.5px; margin-top: 1px; }
.kd-addr-list li[aria-selected=true], .kd-addr-list li:hover { background: var(--teal-wash, #E7F1EE); }
.kd-addr-list li.kd-none { cursor: default; color: var(--ink-soft, #5B6B65); }
.kd-addr-list li.kd-none:hover { background: none; }
.kd-addr-map { height: 230px; margin-top: 10px; border-radius: 10px; border: 1px solid var(--line, #E3DFD5); overflow: hidden; background: #e8efe9; position: relative; z-index: 0; }
.kd-addr-status { font-size: 13px; margin: 8px 2px 0; color: var(--ink-soft, #5B6B65); min-height: 18px; }
.kd-addr-status.ok { color: var(--teal-dark, #0B5347); font-weight: 600; }
.kd-addr-status.warn { color: #8a5a00; }
.kd-addr .kd-addr-note { margin-top: 2px; }

/* map markers */
.kd-mk { background: none; border: 0; }
.kd-mk .kd-mk-in { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: #fff; border: 2px solid var(--teal, #0F6E5C);
  box-shadow: 0 3px 10px rgba(0,0,0,.25); font-size: 20px; line-height: 1; }
.kd-mk.home .kd-mk-in { background: var(--teal, #0F6E5C); border-color: #fff; }
.kd-mk.veh .kd-mk-in { width: 44px; height: 44px; font-size: 24px; position: relative; }
.kd-mk.veh .kd-mk-in::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid rgba(15,110,92,.45); animation: kd-pulse 1.8s ease-out infinite; }
.kd-mk.me .kd-mk-in { width: 18px; height: 18px; background: #2f6fed; border: 3px solid #fff; font-size: 0; }
.kd-mk.me .kd-mk-in::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; background: rgba(47,111,237,.18); }
.kd-mk.me .kd-mk-in { position: relative; }
@keyframes kd-pulse { from { transform: scale(.7); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .kd-mk.veh .kd-mk-in::after { animation: none; } }

/* ============================================================ full-screen trip view (patient and doctor) */
.kd-trip { position: fixed; inset: 0; z-index: 70; background: rgba(23,38,31,.55); display: flex; align-items: center; justify-content: center; padding: 20px; }
.kd-trip .kd-trip-card { position: relative; width: 100%; max-width: 1000px; height: min(660px, 92vh); background: #fff; border-radius: 16px; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.kd-trip .kd-trip-map { position: relative; z-index: 0; background: #e8efe9; min-height: 0; }
.kd-trip .kd-trip-panel { position: relative; overflow-y: auto; padding: 22px 20px 20px; border-left: 1px solid var(--line, #E3DFD5); background: #fff; }
.kd-trip .kd-trip-x { position: absolute; top: 12px; right: 12px; z-index: 5; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line, #E3DFD5);
  background: #fff; font-size: 16px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.15); color: var(--ink, #17261F); }
.kd-trip .kd-recenter { position: absolute; left: 12px; bottom: 12px; z-index: 5; background: #fff; border: 1px solid var(--line, #E3DFD5); border-radius: 20px; padding: 8px 14px;
  font: 600 13px Inter, -apple-system, sans-serif; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.15); color: var(--ink, #17261F); }

.kd-trip h3 { margin: 0 34px 4px 0; font: 600 20px/1.25 Fraunces, Georgia, serif; color: var(--ink, #17261F); }
.kd-trip .kd-sub { color: var(--ink-soft, #5B6B65); font-size: 14px; margin: 0 0 14px; line-height: 1.45; }
.kd-eta { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 2px; }
.kd-eta b { font: 600 44px/1 Fraunces, Georgia, serif; color: var(--teal-dark, #0B5347); letter-spacing: -.5px; }
.kd-eta span { font-size: 16px; color: var(--ink-soft, #5B6B65); }
.kd-arrive { font-size: 14.5px; color: var(--ink, #17261F); margin-bottom: 12px; }
.kd-chip { display: inline-block; border-radius: 20px; padding: 5px 12px; font-size: 13px; font-weight: 600; background: var(--teal-wash, #E7F1EE); color: var(--teal-dark, #0B5347); margin-bottom: 12px; }
.kd-chip.late { background: #FFF1D6; color: #7a4d00; }
.kd-chip.alert { background: var(--danger-wash, #FBEAE9); color: var(--danger, #B3261E); }
.kd-facts { border: 1px solid var(--line, #E3DFD5); border-radius: 12px; overflow: hidden; margin: 4px 0 14px; }
.kd-facts > div { display: flex; justify-content: space-between; gap: 14px; padding: 10px 12px; font-size: 14px; border-top: 1px solid var(--line, #E3DFD5); }
.kd-facts > div:first-child { border-top: 0; }
.kd-facts span:first-child { color: var(--ink-soft, #5B6B65); flex: none; }
.kd-facts span:last-child { text-align: right; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.kd-note { font-size: 13px; color: var(--ink-soft, #5B6B65); margin: 8px 0; line-height: 1.45; }
.kd-warn { background: #FFF1D6; color: #6d4300; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin: 10px 0; line-height: 1.45; }
.kd-warn.bad { background: var(--danger-wash, #FBEAE9); color: var(--danger, #B3261E); }
.kd-btns { display: grid; gap: 8px; margin-top: 12px; }
.kd-btns a, .kd-btns button { width: auto; margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center; min-height: 46px; padding: 10px 14px; border-radius: 10px;
  font: 600 15px Inter, -apple-system, sans-serif; cursor: pointer; text-decoration: none; border: 1px solid var(--line, #E3DFD5); background: #fff; color: var(--ink, #17261F); }
.kd-btns .primary { background: var(--teal, #0F6E5C); color: #fff; border-color: var(--teal, #0F6E5C); }
.kd-btns .primary:hover { background: var(--teal-dark, #0B5347); }
.kd-btns .danger { color: var(--danger, #B3261E); }
.kd-btns button[disabled] { opacity: .55; cursor: not-allowed; }
.kd-btns.two { grid-template-columns: 1fr 1fr; }
.kd-modes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0 12px; }
.kd-modes button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px 7px; border-radius: 10px; border: 1px solid var(--line, #E3DFD5);
  background: #fff; cursor: pointer; font: 500 11.5px Inter, -apple-system, sans-serif; color: var(--ink-soft, #5B6B65); min-height: 62px; }
.kd-modes button span { font-size: 22px; line-height: 1; }
.kd-modes button.on { border-color: var(--teal, #0F6E5C); background: var(--teal-wash, #E7F1EE); color: var(--teal-dark, #0B5347); font-weight: 600; }
.kd-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--teal-dark, #0B5347); }
.kd-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #1fa56c; animation: kd-blink 1.4s ease-in-out infinite; }
@keyframes kd-blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .kd-live::before { animation: none; } }

/* ---- phones: the map fills the screen and the details slide up from the bottom */
@media (max-width: 760px) {
  .kd-trip { padding: 0; background: #fff; }
  .kd-trip .kd-trip-card { max-width: none; height: 100%; height: 100dvh; border-radius: 0; display: block; box-shadow: none; }
  .kd-trip .kd-trip-map { position: absolute; inset: 0; }
  .kd-trip .kd-trip-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 58%; border-left: 0; border-radius: 18px 18px 0 0; z-index: 4;
    box-shadow: 0 -10px 30px rgba(23,38,31,.2); padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  .kd-trip .kd-trip-panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line, #E3DFD5); margin: -6px auto 12px; }
  .kd-trip .kd-trip-x { top: max(12px, env(safe-area-inset-top)); right: 12px; }
  .kd-trip .kd-recenter { top: max(14px, env(safe-area-inset-top)); bottom: auto; left: 12px; }
  .kd-eta b { font-size: 38px; }
  .kd-addr .kd-addr-row { flex-wrap: wrap; }
  .kd-addr .kd-addr-here { flex: 1 1 100%; }
  .kd-addr-map { height: 250px; }
  .kd-addr input { font-size: 16px; }
}
body.kd-trip-open { overflow: hidden; }
