/* =========================================================
   Deva İlaç · Hastane Haritası
   ========================================================= */

:root {
  --yellow: #F0B90B;
  --yellow-light: #FCD75A;
  --yellow-deep: #D99E06;
  --ink: #1B1A16;
  --ink-soft: #5C5A50;
  --ink-faint: #8E8B7F;
  --surface: #FFFFFF;
  --surface-2: #F6F5F1;
  --line: #E6E4DC;
  --danger: #C0392B;
  --ok: #2E9E5B;

  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(27, 26, 22, .08), 0 2px 8px rgba(27, 26, 22, .08);
  --shadow-md: 0 4px 14px rgba(27, 26, 22, .12), 0 12px 32px rgba(27, 26, 22, .14);
  --shadow-lg: 0 10px 40px rgba(27, 26, 22, .22);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Harita ---------- */

#map {
  position: fixed;
  inset: 0;
  background: #F4F3EF;
  z-index: 0;
}

.leaflet-container { font-family: var(--font); background: #F4F3EF; }

.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, .75) !important;
  color: var(--ink-faint);
}
.leaflet-control-attribution a { color: var(--ink-soft); }

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-sm) !important;
  border-radius: 12px !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  width: 36px; height: 36px; line-height: 36px;
  color: var(--ink) !important;
  border-bottom-color: var(--line) !important;
}
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; }

/* ---------- Kalp pinleri ---------- */

.pin-wrap { background: none; border: none; }

.pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  cursor: pointer;
}

.pin__label {
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  letter-spacing: .01em;
  color: #26251F;
  white-space: nowrap;
  pointer-events: none;
  text-shadow:
     1px  0 2px #fff,  -1px  0 2px #fff,
     0  1px 2px #fff,   0 -1px 2px #fff,
     0 0 5px #fff;
}

.pin__body {
  position: relative;
  width: var(--pin-size);
  height: var(--pin-size);
}

.pin__heart {
  display: block;
  width: 100%;
  height: 100%;
  fill: url(#heartGrad);
  stroke: var(--yellow-deep);
  stroke-width: .35;
  filter: drop-shadow(0 2px 3px rgba(27, 26, 22, .3));
  transition: transform .16s ease;
}

.pin:hover .pin__heart { transform: scale(1.07); }

.pin__count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 13%;
  font-size: calc(var(--pin-size) * .37);
  font-weight: 800;
  letter-spacing: -.02em;
  color: #3B2D00;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* Yeni kayıt sonrası kısa vurgu */
.pin--pulse .pin__heart { animation: pinPulse .9s ease-out 2; }
@keyframes pinPulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* Küme (cluster) pinleri */
.pin-wrap--cluster .pin__heart { stroke-width: .5; }
.pin-wrap--cluster .pin__count { font-size: calc(var(--pin-size) * .33); }

.marker-cluster { background: none; }

/* ---------- Pin detay balonu ---------- */

.pp-popup .leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0;
  overflow: hidden;
}
.pp-popup .leaflet-popup-content { margin: 0; width: auto !important; }
.pp-popup .leaflet-popup-tip { box-shadow: var(--shadow-sm); }
.pp-popup a.leaflet-popup-close-button {
  color: var(--ink-faint);
  width: 28px; height: 28px;
  font-size: 18px; line-height: 26px;
  padding: 0;
}

.pp__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 34px 12px 14px;
  background: linear-gradient(180deg, #FFFCF0, #FFF7DE);
  border-bottom: 1px solid var(--line);
}
.pp__name { font-size: 14px; font-weight: 700; }
.pp__badge {
  margin-left: auto;
  background: linear-gradient(180deg, var(--yellow-light), var(--yellow));
  color: #3B2D00;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--yellow-deep);
  font-variant-numeric: tabular-nums;
}

.pp__body { max-height: 220px; overflow-y: auto; padding: 6px 0; }
.pp__row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--surface-2);
}
.pp__row:last-child { border-bottom: none; }
.pp__hospital { font-size: 13px; font-weight: 600; line-height: 1.3; }
.pp__meta { font-size: 11.5px; color: var(--ink-faint); }
.pp__note, .pp__loading, .pp__error {
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--ink-faint);
}
.pp__error { color: var(--danger); }

/* ---------- Üst çubuk ---------- */

.topbar {
  position: fixed;
  z-index: 600;
  top: calc(10px + var(--safe-t));
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

.topbar__brand { display: flex; align-items: center; gap: 9px; min-width: 0; }

.topbar__logo { width: 26px; height: 26px; flex: none; }
.topbar__logo svg {
  width: 100%; height: 100%;
  fill: url(#heartGrad);
  stroke: var(--yellow-deep);
  stroke-width: .4;
}

.topbar__titles { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar__titles strong { font-size: 15px; font-weight: 800; letter-spacing: .06em; }
.topbar__titles small { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }

.topbar__stats { display: flex; align-items: center; gap: 14px; margin-left: auto; }

.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.stat__value {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.stat__label { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }

.sync {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: none;
  transition: background .25s ease;
}
.sync[data-state="ok"] { background: var(--ok); }
.sync[data-state="error"] { background: var(--danger); }

/* ---------- Ekle butonu ---------- */

.fab {
  position: fixed;
  z-index: 600;
  right: 16px;
  bottom: calc(16px + var(--safe-b));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  padding: 0 20px 0 16px;
  border: 1px solid var(--yellow-deep);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--yellow-light), var(--yellow));
  color: #3B2D00;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform .14s ease, box-shadow .14s ease, opacity .2s ease;
}
.fab svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}
.fab:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.fab:active { transform: translateY(0); }
.fab:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Form paneli ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(27, 26, 22, .42);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fadeIn .18s ease;
}
.backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.sheet[hidden] { display: none; }

.sheet__grabber { display: none; }

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 6px;
}
.sheet__head h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-soft);
  cursor: pointer;
  flex: none;
}
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.icon-btn:hover { background: var(--line); }

.sheet__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 20px calc(20px + var(--safe-b));
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }

.field input,
.field select {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  font-family: inherit;
  font-size: 16px; /* iOS'ta odaklanınca yakınlaştırmayı engeller */
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.field input::placeholder { color: #B6B3A6; }

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235C5A50' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 38px;
}

.field input:focus,
.field select:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(240, 185, 11, .22);
}
.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, .14);
}

.form-error {
  margin: -4px 0 0;
  font-size: 13px;
  color: var(--danger);
}
.form-error[hidden] { display: none; }

.submit {
  position: relative;
  height: 52px;
  margin-top: 2px;
  border: 1px solid var(--yellow-deep);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--yellow-light), var(--yellow));
  color: #3B2D00;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: filter .15s ease, opacity .15s ease;
}
.submit:hover { filter: brightness(1.04); }
.submit:disabled { opacity: .6; cursor: progress; }

.spinner {
  display: none;
  position: absolute;
  top: 50%; left: 50%;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border: 2.5px solid rgba(59, 45, 0, .25);
  border-top-color: #3B2D00;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.submit.is-busy .submit__label { visibility: hidden; }
.submit.is-busy .spinner { display: block; }

/* ---------- Bildirim ---------- */

.toast {
  position: fixed;
  z-index: 1100;
  left: 50%;
  bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  background: var(--ink);
  color: #FFF;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  animation: toastIn .22s ease;
}
.toast[hidden] { display: none; }
.toast[data-kind="error"] { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Açılış ekranı ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  transition: opacity .3s ease, visibility .3s ease;
}
.splash.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.splash__inner { text-align: center; padding: 24px; max-width: 380px; }

.splash__heart {
  width: 58px; height: 58px;
  fill: url(#heartGrad);
  stroke: var(--yellow-deep);
  stroke-width: .35;
  animation: beat 1.5s ease-in-out infinite;
}
@keyframes beat {
  0%, 100% { transform: scale(1); }
  22%      { transform: scale(1.14); }
  40%      { transform: scale(1); }
}

.splash__text { margin: 14px 0 0; font-size: 14.5px; font-weight: 600; color: var(--ink-soft); }
.splash__hint { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-faint); }
.splash__hint[hidden] { display: none; }
.splash__hint code {
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
}

/* =========================================================
   Masaüstü — ortalanmış diyalog
   ========================================================= */

@media (min-width: 641px) {
  .sheet {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 40px));
    border-radius: 18px;
    animation: dialogIn .2s cubic-bezier(.2, .8, .3, 1);
  }
  @keyframes dialogIn {
    from { opacity: 0; transform: translate(-50%, -46%) scale(.97); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  }
}

/* =========================================================
   Mobil — alttan açılan panel
   ========================================================= */

@media (max-width: 640px) {
  .topbar { padding: 7px 10px; gap: 8px; }
  .topbar__titles small { display: none; }
  .topbar__stats { gap: 11px; }
  .stat__value { font-size: 15px; }

  .fab {
    height: 52px;
    padding: 0 18px 0 15px;
    right: 12px;
    bottom: calc(12px + var(--safe-b));
  }

  .sheet {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 88dvh;
    border-radius: 20px 20px 0 0;
    animation: sheetUp .24s cubic-bezier(.2, .8, .3, 1);
    overflow-y: auto;
  }
  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .sheet__grabber {
    display: block;
    width: 38px; height: 4px;
    margin: 9px auto 0;
    border-radius: 999px;
    background: var(--line);
    flex: none;
  }

  .sheet__head { padding-top: 12px; }
  .toast { bottom: calc(78px + var(--safe-b)); }

  .leaflet-control-attribution { font-size: 9px; }
}

/* Çok dar ekranlarda FAB'ı yalnızca ikona indir */
@media (max-width: 380px) {
  .fab { width: 54px; height: 54px; padding: 0; justify-content: center; }
  .fab__text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
