/* Kepez Mahalle Haritası */
:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-light: #ccfbf1;
    --text: #1f2937;
    --muted: #5b6472;
    --border: #e5e7eb;
    --bg: #f8fafc;
    --panel: #ffffff;
    --topbar-h: 60px;
    --panel-w: 340px;
    --shadow: 0 4px 20px rgba(15, 23, 42, .12);
    --focus: 0 0 0 3px rgba(15, 118, 110, .35);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

a { color: var(--primary); }
button, input, select { font: inherit; color: inherit; }
svg { fill: currentColor; }
.muted { color: var(--muted); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
    position: absolute; left: 8px; top: -60px; z-index: 5000;
    background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { top: 8px; }

/* Üst bar ------------------------------------------------------------ */
.topbar {
    flex: 0 0 var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    background: var(--primary);
    color: #fff;
    z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 1.1rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { margin: 0; font-size: .8rem; opacity: .85; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.icon-btn {
    display: grid; place-items: center; flex: none;
    width: 40px; height: 40px; border-radius: 10px;
    border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer;
}
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, .6); }
.home-btn { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .35); }
.home-btn svg { width: 24px; height: 24px; }
.home-btn:hover { background: rgba(255, 255, 255, .25); }

/* Butonlar ----------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 8px 14px;
    border: 1px solid transparent; border-radius: 10px;
    background: var(--primary); color: #fff;
    font-size: .9rem; font-weight: 600; text-decoration: none;
    cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-light { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .35); }
.btn-light:hover { background: rgba(255, 255, 255, .25); }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.topbar .menu-btn { display: none; } /* Sadece mobilde */

/* Mobil menü (yalnızca mobilde açılır) */
.mobile-menu, .menu-backdrop { display: none; }

/* Yerleşim ----------------------------------------------------------- */
.layout { flex: 1; display: flex; min-height: 0; position: relative; }

.panel {
    width: var(--panel-w);
    flex: none;
    display: flex; flex-direction: column;
    background: var(--panel);
    border-right: 1px solid var(--border);
    min-height: 0;
    z-index: 1000;
}

.map-wrap { flex: 1; position: relative; min-width: 0; }
#harita { position: absolute; inset: 0; background: #e5e7eb; }
.map-loading {
    position: absolute; inset: 0; display: grid; place-items: center;
    background: rgba(248, 250, 252, .85); font-weight: 600; color: var(--muted);
    z-index: 900; pointer-events: none;
}
.map-loading[hidden] { display: none; }

.sheet-handle { display: none; }

/* Sekmeler ----------------------------------------------------------- */
.tabs {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    margin: 12px 12px 0; padding: 4px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
}
.tab {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 38px; border-radius: 9px;
    color: var(--muted); font-size: .9rem; font-weight: 600; text-decoration: none;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.tab:focus-visible { outline: none; box-shadow: var(--focus); }
.tab-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tab-panel[hidden] { display: none; }

/* Tek satır arama + seçim (combo) ------------------------------------ */
.combo {
    position: relative; display: flex; align-items: center;
    margin: 10px 12px 6px; min-height: 46px;
    border: 1px solid var(--border); border-radius: 12px; background: #fff;
}
.combo:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.combo-icon { position: absolute; left: 12px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.combo input {
    flex: 1; min-width: 0; height: 44px;
    padding: 0 4px 0 40px; border: 0; background: transparent; outline: none;
    font-size: 16px; /* iOS'ta otomatik yakınlaştırmayı engeller */
    -webkit-appearance: none; appearance: none;
}
.combo input::-webkit-search-cancel-button { display: none; }
.combo-clear {
    flex: none; display: grid; place-items: center;
    width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent;
    color: var(--muted); cursor: pointer;
}
.combo-clear svg { width: 20px; height: 20px; }
.combo-clear:hover, .combo-clear:focus-visible { background: var(--bg); outline: none; }
.combo-clear[hidden] { display: none; }

/* Sağdaki açılır liste ikonu: üzerinde görünmez bir <select> durur,
   dokununca telefonun kendi seçim listesi açılır */
.combo-toggle {
    position: relative; flex: none; align-self: stretch;
    display: grid; place-items: center; width: 46px;
    border-left: 1px solid var(--border); color: var(--primary);
    border-radius: 0 12px 12px 0;
}
.combo-toggle svg { width: 28px; height: 28px; pointer-events: none; }
.combo-toggle:hover { background: var(--primary-light); }
.combo-toggle select {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer; border: 0; font-size: 16px;
}
.combo-toggle:focus-within { background: var(--primary-light); }

.result-count { margin: 2px 16px 6px; font-size: .8rem; color: var(--muted); }

/* Liste -------------------------------------------------------------- */
.list {
    list-style: none; margin: 0; padding: 0 8px 8px;
    overflow-y: auto; flex: 1; min-height: 0;
    -webkit-overflow-scrolling: touch;
}
.list-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--text); text-decoration: none;
}
.list-pin { width: 18px; height: 18px; color: #94a3b8; flex: none; }
.list-item:hover { background: var(--bg); }
.list-item:focus-visible { outline: none; box-shadow: var(--focus); }
.list-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.list-item.active .list-pin { color: var(--primary); }
.list-item mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }
.empty { margin: 16px; color: var(--muted); text-align: center; }

.panel-footer {
    margin-top: auto;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    font-size: .72rem; color: var(--muted); line-height: 1.4;
}

/* Mesafe ------------------------------------------------------------- */
.distance-form { display: flex; align-items: center; gap: 6px; margin: 10px 12px 6px; }
.distance-field { position: relative; flex: 1; min-width: 0; }
.distance-field .pin { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.distance-field select {
    width: 100%; height: 46px; padding: 0 8px 0 40px;
    border: 1px solid var(--border); border-radius: 12px; background: #fff; font-size: 16px; cursor: pointer;
    text-overflow: ellipsis;
}
.distance-field select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.pin {
    display: grid; place-items: center;
    width: 24px; height: 24px; border-radius: 50%;
    color: #fff; font-size: .75rem; font-weight: 700; border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.pin-a { background: #16a34a; }
.pin-b { background: #dc2626; }
.swap {
    flex: none; width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--border); background: #fff; color: var(--primary); cursor: pointer;
    display: grid; place-items: center;
}
.swap svg { width: 22px; height: 22px; }
.swap:hover { background: var(--primary-light); }
.swap:focus-visible { outline: none; box-shadow: var(--focus); }
.distance-result {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px;
    margin: 2px 16px 10px; font-size: .9rem; line-height: 1.4;
}
.distance-result strong { font-size: 1.25rem; color: var(--primary-dark); }
.distance-result a { font-weight: 600; white-space: nowrap; }

/* Harita ------------------------------------------------------------- */
.leaflet-container { font: inherit; }
.mahalle-label.leaflet-tooltip {
    background: transparent; border: 0; box-shadow: none; padding: 0;
    font-size: 11px; font-weight: 700; color: #111827;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
    white-space: nowrap; pointer-events: none;
}
.mahalle-label.leaflet-tooltip::before { display: none; }
.hide-labels .mahalle-label { display: none; }
.hover-tip.leaflet-tooltip { font-weight: 600; border-radius: 8px; }
.leaflet-touch .leaflet-bar a { width: 36px; height: 36px; line-height: 36px; }

/* Pin üzerindeki minik bilgi kartı */
.mini-kart .leaflet-popup-content-wrapper { border-radius: 14px; box-shadow: var(--shadow); }
.mini-kart .leaflet-popup-content { margin: 12px 34px 12px 14px; line-height: 1.3; min-width: 150px; width: auto !important; }
.mini-kart .leaflet-popup-close-button { width: 30px !important; height: 30px !important; font-size: 20px !important; line-height: 28px !important; }
.pop-ust { display: block; font-size: .78rem; color: var(--primary); font-weight: 600; margin-bottom: 2px; }
.pop-ad { display: block; font-size: 1.05rem; font-weight: 700; color: var(--text); }
.pop-alt { display: block; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.pop-aks { display: flex; flex-wrap: nowrap; gap: 6px; margin-top: 10px; }
.pop-aks a, .pop-aks button {
    display: inline-flex; align-items: center; min-height: 32px; padding: 4px 10px;
    border-radius: 8px; border: 1px solid var(--primary); background: #fff;
    color: var(--primary); font-size: .8rem; font-weight: 600; text-decoration: none; cursor: pointer;
    white-space: nowrap;
}
.pop-aks a.birincil { background: var(--primary); color: #fff; }
.pop-aks a:focus-visible, .pop-aks button:focus-visible { outline: none; box-shadow: var(--focus); }

/* Harita üzerindeki A/B işaretleri ve mesafe etiketi */
.pin-marker { background: transparent; border: 0; }
.pin-marker .pin { width: 30px; height: 30px; font-size: .85rem; }
.distance-label.leaflet-tooltip {
    background: #111827; color: #fff; border: 0; border-radius: 8px;
    padding: 4px 8px; font-weight: 700; font-size: 12px; box-shadow: var(--shadow);
}
.distance-label.leaflet-tooltip::before { display: none; }

/* Bildirim ----------------------------------------------------------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    max-width: calc(100% - 32px);
    background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px;
    font-size: .9rem; box-shadow: var(--shadow); z-index: 3000;
}
.toast[hidden] { display: none; }

/* Mobil: panel haritanın altında (bottom sheet) ------------------------ */
@media (max-width: 768px) {
    :root { --topbar-h: 54px; }

    .topbar { gap: 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
    .brand { gap: 8px; }
    .brand h1 { font-size: 1rem; }
    .btn-light span { display: none; }  /* Sadece ikon */
    .btn-light { width: 42px; padding: 0; }
    .topbar .menu-btn { display: inline-flex; }
    .menu-btn svg { width: 24px; height: 24px; }

    .layout { display: block; }
    /* --panel-h, JS tarafından kapalı panelin yüksekliğine göre güncellenir */
    .map-wrap {
        position: absolute; inset: 0 0 calc(var(--panel-h, 150px) - 16px) 0;
        z-index: 0; isolation: isolate;
    }

    .panel {
        position: absolute; left: 0; right: 0; bottom: 0;
        width: auto; height: auto; max-height: 100%;
        border-right: 0; border-radius: 18px 18px 0 0;
        box-shadow: 0 -6px 24px rgba(15, 23, 42, .18);
        padding-bottom: env(safe-area-inset-bottom);
        overflow: hidden;
    }
    .panel.expanded { height: min(72%, 600px); }

    .sheet-handle {
        display: flex; justify-content: center; align-items: center;
        width: 100%; height: 20px; padding: 0; border: 0; background: transparent; cursor: pointer;
        flex: none;
    }
    .sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: #cbd5e1; }
    .sheet-handle:focus-visible { outline: none; }
    .sheet-handle:focus-visible .sheet-grip { background: var(--primary); }

    .tabs { margin: 0 12px; }
    .tab { min-height: 36px; }
    .combo, .distance-form { margin: 8px 12px 10px; }

    /* Kapalıyken sadece sekmeler + tek satır görünür */
    .panel:not(.expanded) .list,
    .panel:not(.expanded) .result-count,
    .panel:not(.expanded) .empty,
    .panel:not(.expanded) .panel-footer { display: none; }
    .distance-result { margin-top: 0; }

    .toast { bottom: calc(var(--panel-h, 150px) + 12px); }

    /* Harita panelin 16px altına uzanıyor; telif yazısı görünür kalsın */
    .leaflet-bottom { bottom: 16px; }
    .leaflet-control-scale { display: none; }

    /* Menü çekmecesi */
    .menu-backdrop:not([hidden]) {
        display: block; position: fixed; inset: 0; z-index: 4000;
        background: rgba(15, 23, 42, .45);
    }
    .mobile-menu:not([hidden]) {
        display: flex; flex-direction: column;
        position: fixed; top: 0; right: 0; bottom: 0; z-index: 4001;
        width: min(300px, 86vw);
        background: #fff; box-shadow: var(--shadow);
        padding-bottom: env(safe-area-inset-bottom);
        animation: menu-in .2s ease;
    }
    @keyframes menu-in { from { transform: translateX(100%); } to { transform: none; } }
    .mobile-menu-head {
        display: flex; align-items: center; justify-content: space-between;
        height: var(--topbar-h); padding: 0 8px 0 18px;
        background: var(--primary); color: #fff; font-size: 1.05rem;
    }
    .mobile-menu ul { list-style: none; margin: 0; padding: 8px; flex: 1; overflow-y: auto; }
    .mobile-menu li button, .mobile-menu li a {
        display: flex; align-items: center; gap: 14px; width: 100%;
        min-height: 52px; padding: 12px; border: 0; border-radius: 10px;
        background: transparent; color: var(--text); font-size: 1rem; text-align: left; text-decoration: none; cursor: pointer;
    }
    .mobile-menu li svg { width: 22px; height: 22px; color: var(--primary); flex: none; }
    .mobile-menu li button:hover, .mobile-menu li a:hover { background: var(--bg); }
    .mobile-menu li button:focus-visible, .mobile-menu li a:focus-visible { outline: none; box-shadow: var(--focus); }
    .mobile-menu-foot { margin: 0; padding: 12px 18px; font-size: .75rem; color: var(--muted); border-top: 1px solid var(--border); }
}

@media (max-width: 380px) {
    .subtitle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
