/* ========================================================================
   PERIPLUS RESPONSIVE CSS
   Mobil-first tasarim, 360px minimum, portrait + landscape destegi
   ======================================================================== */

/* ============ CSS DEGISKENLERI ============ */
:root {
  /* Responsive boyutlar - Mobil-first */
  --header-height: 44px;
  --subheader-height: 40px;
  /* Mobilde paneller tam ekran degil, kontrol edilebilir genislikte olsun */
  --panel-width: min(320px, 82vw);
  --filter-width: min(320px, 78vw);
  --btn-min-size: 36px;
  --touch-target: 40px;
  
  /* Safe area - iOS notch, Android nav bar */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  
  /* Z-index katmanlari */
  --z-base: 1;
  /* Leaflet pane'ler projede yuksek z-index kullanabiliyor; mobil UI her zaman ustte olmali */
  --z-header: 13000;
  --z-subheader: 12999;
  --z-overlay: 12000;
  --z-filter: 12100;
  --z-panel: 12100;
  --z-modal: 14000;
  --z-toast: 15000;
}

/* Not: Bu dosya index.html'de media="(max-width: 1024px)" ile yuklenir.
   Bu nedenle desktop (>=1025) breakpoints burada yok. */

/* ============ TEMEL RESET ============ */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  touch-action: manipulation;
}

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

body {
  position: fixed;
  inset: 0;
  /* Notch/camera alanında "beyaz bar" oluşmasın:
     safe-top padding'i body'ye vermek yerine header içine alıyoruz. */
  padding-top: 0;
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* Mobil yardimci siniflar */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .mu-hidden { display: none !important; }
}

/* ============ APP CONTAINER ============ */
.app, #app {
  width: 100%;
  height: 100%;
  display: flex !important; /* main.css mobile bloklari !important kullaniyor */
  flex-direction: column !important;
  position: relative;
  overflow: hidden;
  min-height: 0 !important;
}

/* ============ HEADER ============ */
header {
  display: flex;
  align-items: center;
  position: relative; /* z-index calissin, harita ustune cikabilsin */
  /* Safe-top header içine: kamera/notch altında boş beyaz şerit olmasın */
  padding-top: var(--safe-top);
  height: calc(var(--header-height) + var(--safe-top)) !important;
  min-height: calc(var(--header-height) + var(--safe-top)) !important;
  max-height: calc(var(--header-height) + var(--safe-top)) !important;
  padding-left: max(8px, var(--safe-left));
  padding-right: max(8px, var(--safe-right));
  padding-bottom: 0;
  gap: 8px;
  background: var(--card, #ffffff);
  border-bottom: 1px solid var(--hair, #e5e7eb);
  z-index: var(--z-header) !important;
  flex-shrink: 0;
}

/* Brand */
header .brand {
  flex-shrink: 0;
  max-width: 140px;
  overflow: hidden;
}

header .brand-combo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

header .brand-gaus {
  font-size: 20px;
}

header .brand-divider {
  height: 24px;
  width: 2px;
}

header .brand-periplus {
  font-size: 9px;
  letter-spacing: 1px;
}

/* Searchbar */
header .searchbar {
  flex: 1;
  min-width: 0;
  max-width: 190px;
}

header .searchbar input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 36px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--hair, #e5e7eb);
  background: var(--bg, #f8fafc);
}

header .searchbar .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted, #64748b);
}

/* Header Actions */
header .header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Mobilde header butonlarini incelt (896px altinda) */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  header .header-actions .btn {
    min-height: 34px !important;
    height: 34px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
    border-radius: 10px !important;
  }
  header .user-info-container { max-width: 150px; }
  header .user-info-container .user-details { display: none; }

  /* Login/Logout butonlarini ikonlastir (tasmasin) */
  #loginBtn, #logoutBtn {
    width: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
    position: relative !important;
    justify-content: center !important;
  }
  #loginBtn::before {
    content: "☰";
    font-size: 16px;
    line-height: 1;
  }
  #logoutBtn::before {
    content: "⎋";
    font-size: 16px;
    line-height: 1;
  }
}

/* Mobilde sadece ikon goster */
@media (max-width: 480px) {
  header .brand {
    max-width: 100px;
  }
  
  header .brand-gaus {
    font-size: 18px;
  }
  
  header .brand-divider {
    height: 20px;
  }
  
  header .brand-periplus {
    font-size: 8px;
  }
  
  header .searchbar {
    max-width: 120px;
  }
  
  header .searchbar input {
    height: 32px;
    font-size: 13px;
    padding-left: 32px;
  }
  
  header .header-actions .btn span:not(.icon):not(.badge):not(.pending-badge) {
    display: none;
  }
  
  header .header-actions .btn {
    min-width: 36px;
    width: 36px;
    padding: 0;
    justify-content: center;
  }
  
  /* User info mobilde gizle */
  header .user-info-container .user-details {
    display: none;
  }
}

/* Buyuk mobil + tablet benzeri (481px - 896px) */
@media (min-width: 481px) and (max-width: 1024px), (hover: none) and (pointer: coarse) {
  header {
    padding: 0 12px;
    gap: 10px;
  }
  
  header .brand {
    max-width: 160px;
  }
  
  header .brand-gaus {
    font-size: 24px;
  }
  
  header .brand-periplus {
    font-size: 10px;
  }
  
  header .searchbar {
    max-width: 180px;
  }
}

/* Desktop breakpoint bu dosyada yok (<=896). */

/* ============ MAIN AREA ============ */
main {
  flex: 1;
  position: relative;
  display: flex;
  overflow: hidden;
  min-height: 0 !important;
}

/* ============ MAP WRAP ============ */
.map-wrap,
section.map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.map,
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ============ FILTER PANEL (Sol) ============ */
.filter,
aside.filter {
  /* main.css bazı mobil bloklarda width/position için !important kullanıyor.
     responsive davranışın bozulmaması için kritik layout kurallarını burada kilitle. */
  position: fixed !important;
  top: var(--header-height) !important;
  left: 0 !important;
  bottom: var(--subheader-height) !important;
  width: var(--filter-width) !important;
  max-width: var(--filter-width) !important;
  background: var(--card, #ffffff);
  border-right: 1px solid var(--hair, #e5e7eb);
  z-index: var(--z-filter);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

.filter.open,
aside.filter.open,
.filter[data-open="true"] {
  transform: translateX(0);
}


/* JS filter paneli "collapsed" sinifi ile yonetiyor.
   Mobilde slide-in davranisi icin open state'i collapsed'a bagla. */
.filter:not(.collapsed),
aside.filter:not(.collapsed) {
  transform: translateX(0) !important;
}

.filter.collapsed,
aside.filter.collapsed {
  transform: translateX(-100%) !important;
}


/* JS filter paneli "collapsed" sinifi ile yonetiyor.
   Mobilde slide-in davranisi icin open state'i collapsed'a bagla. */
.filter:not(.collapsed),
aside.filter:not(.collapsed) {
  transform: translateX(0) !important;
}

.filter.collapsed,
aside.filter.collapsed {
  transform: translateX(-100%) !important;
}

/* Portrait: filtre tek parca tam ekran olsun */
@media (max-width: 1024px) and (orientation: portrait), (hover: none) and (pointer: coarse) and (orientation: portrait) {
  :root {
    --filter-width: 100vw;
  }
  .filter,
  aside.filter {
    width: var(--filter-width) !important;
    max-width: var(--filter-width) !important;
  }
}

/* Mobilde collapsed asla genisligi sifirlamasin */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .filter.collapsed {
    width: var(--filter-width) !important;
    max-width: var(--filter-width) !important;
  }
  .filter.collapsed .filter-content {
    display: flex !important;
  }
}

/* Filter content */
.filter-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* flex layout için gerekli */
  min-height: 0; /* flex item'da overflow çalışması için */
}

.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair, #e5e7eb);
  flex-shrink: 0;
  background: var(--card, #ffffff);
}

.filter-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
  text-align: center;
  padding-left: 34px; /* sol bosluk: center title */
}

.filter-collapse {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--muted, #64748b);
}

.filter-collapse:hover {
  background: var(--neutral-100, #f1f5f9);
}

.filter-body {
  flex: 1 1 auto;
  min-height: 0; /* flex item'da overflow çalışması için KRITIK */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.filter-group {
  margin-bottom: 12px;
}

.filter-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #64748b);
  margin-bottom: 6px;
}

.filter-group input,
.filter-group select {
  width: 100%;
  height: var(--touch-target);
  padding: 0 12px;
  font-size: 16px; /* iOS zoom onleme */
  border: 1px solid var(--hair, #e5e7eb);
  border-radius: 12px;
  background: var(--card, #ffffff);
  color: var(--fg, #0f172a);
  -webkit-appearance: none;
  appearance: none;
}

.filter-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.filter-actions {
  padding: 12px 12px 8px;
  border-top: 1px solid var(--hair, #e5e7eb);
  flex-shrink: 0;
  /* sticky yerine flex layout kullan - daha güvenilir */
  background: var(--card, #ffffff);
}

.filter-btn {
  width: 100%;
  height: var(--touch-target);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: var(--primary-600, #2563eb);
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.filter-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.filter-btn:not(:disabled):active {
  background: var(--primary-700, #1d4ed8);
  transform: scale(0.98);
}

.filter-meta {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex-shrink: 0;
  /* sticky yerine flex layout kullan - daha güvenilir */
  background: var(--card, #ffffff);
}

.filter-meta button {
  flex: 1 1 0;
  width: auto;
  height: 34px;
  font-size: 11px;
  border: 1px solid var(--hair, #e5e7eb);
  border-radius: 8px;
  background: var(--card, #ffffff);
  cursor: pointer;
}

/* Dropdown listelerini mobilde sidebar akisina dahil et (tek scroll sidebar) */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .filter-options {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    margin-top: 6px !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border-radius: 12px !important;
  }
}

/* Filter panel: mobilde gereksiz/hantal elemanlari gizle */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  #filterTrail,
  .filter-trail,
  .filter-hint,
  .filter-warning {
    display: none !important;
  }
}

/* Filter tab (collapse handle) */
.filter-tab {
  display: none;
}

/* Desktop filter kurallari bu dosyada yok (<=896). */

/* ============ DETAIL PANEL (Sag) ============ */
.panel,
aside.panel {
  /* main.css bazı mobil bloklarda width/min-width için !important kullanıyor.
     responsive davranışın bozulmaması için kritik layout kurallarını burada kilitle. */
  position: fixed !important;
  top: var(--header-height) !important;
  right: 0 !important;
  bottom: var(--subheader-height) !important;
  width: var(--panel-width) !important;
  max-width: var(--panel-width) !important;
  background: var(--card, #ffffff);
  border-left: 1px solid var(--hair, #e5e7eb);
  z-index: var(--z-panel);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

.panel[style*="display: block"],
.panel[style*="display:block"],
.panel[style*="display:flex"],
.panel[style*="display: flex"],
.panel.open,
.panel[data-open="true"] {
  transform: translateX(0);
}

.panel[style*="display: none"],
.panel[style*="display:none"] {
  transform: translateX(100%);
}

/* Panel header */
.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hair, #e5e7eb);
  flex-shrink: 0;
  gap: 12px;
}

.panel-hd .t1,
#panelTitle {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panel body */
.panel-body,
#panelBody {
  flex: 1;
  overflow-y: auto; /* kaydirma geri geldi */
  overflow-x: hidden;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Panel actions */
.panel-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--hair, #e5e7eb);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  background: var(--card, #ffffff);
  z-index: 2;
}

.panel-actions .btn {
  flex: 1;
  min-width: calc(50% - 4px);
  height: var(--touch-target);
  font-size: 12px;
  padding: 0 8px;
}

.panel-actions .btn.fullrow {
  flex-basis: 100%;
  min-width: 100%;
}

/* Desktop panel kurallari bu dosyada yok (<=896). */

/* ============ SUB-HEADER (Alt Toolbar) ============ */
.sub-header,
#subHeader {
  position: fixed;
  /* Footer'ın ÜSTÜNDE dursun (gesture/nav bar alanına oturmasın) */
  bottom: calc(8px + var(--safe-bottom)) !important; /* main.css landscape bloklari bottom'u degistiriyor */
  left: 0;
  right: 0;
  top: auto !important;
  height: var(--subheader-height) !important;
  min-height: var(--subheader-height) !important;
  padding: 0 8px;
  padding-bottom: 0;
  padding-left: max(8px, var(--safe-left));
  padding-right: max(8px, var(--safe-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card, #ffffff);
  border-top: 1px solid var(--hair, #e5e7eb);
  z-index: var(--z-subheader);
  gap: 4px;
}

/* ===== Mobil footer/sub-header: "konteyner yok", sadece tıklanabilir metin ===== */
@media (max-width: 896px), (pointer: coarse) and (max-width: 1024px) {
  :root{
    --subheader-height: 56px;
    --btn-min-size: 44px;
  }

  .sub-header,
  #subHeader{
    height: var(--subheader-height) !important;
    min-height: var(--subheader-height) !important;
    padding: 0 10px !important;
    padding-bottom: var(--safe-bottom);
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    /* "konteyner" hissi olmasın */
    background: transparent !important;
    border-top: none !important;
    backdrop-filter: none !important;
  }

  /* Mobilde hava durumu + dark toggle ASLA görünmesin (ui-weather inline display basabildiği için !important şart) */
  .weather-card,
  #weatherCard,
  .theme-switch{
    display:none !important;
  }

  /* İkonları kapat, metinleri göster */
  .sub-header button svg,
  .sub-header .btn svg,
  #eriadne-triangle{
    display:none !important;
  }

  /* mu-label'lar mobilde görünsün (desktop'ta main.css gizliyor) */
  .mu-label{
    display:inline !important;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .1px;
  }

  /* Eriadne metni kesin görünsün */
  .eriadne-btn-text{ display:inline !important; }

  /* Sub-header butonları artık "link" gibi: arka plan/border yok */
  .sub-header button,
  .sub-header .btn,
  .sub-header-map-select,
  #layerDropdownBtn{
    min-height: var(--btn-min-size) !important;
    height: var(--btn-min-size) !important;
    min-width: auto !important;
    width: auto !important;
    padding: 0 8px !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    color: var(--primary-700, #1E3A8A) !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-decoration: none;
  }
  .sub-header button:active,
  .sub-header .btn:active,
  #layerDropdownBtn:active{
    transform: none !important;
    opacity: 0.75;
  }

  /* Hint (Filtre ile eriadne arası) görünür ve okunur */
  #subHeaderHint{
    display:block !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: var(--muted, #64748b) !important;
    min-width: 120px;
    max-width: 45vw;
  }

  /* Konum butonu loader layout bozmasın */
  .sub-header-locate-loader{ display:none !important; }

  /* Yatay taşma: soldaki/sağdaki gruplar kaydırılabilsin */
  .sub-header-left{
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none;
    gap: 12px !important;
  }
  .sub-header-left::-webkit-scrollbar{display:none}

  .sub-header-right{
    flex: 0 0 auto !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none;
    gap: 12px !important;
  }
  .sub-header-right::-webkit-scrollbar{display:none}

  /* Layer dropdown label çok uzarsa kısalt */
  #layerDropdownLabel{
    max-width: 160px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Dropdown oku ikonla gelmiyorsa küçük caret ekle */
  #layerDropdownBtn::after{
    content: "▾";
    font-weight: 800;
    margin-left: 6px;
    opacity: 0.8;
  }

  /* Zoom +/- metin olarak kalsın */
  #subHeaderZoomIn .mu-label,
  #subHeaderZoomOut .mu-label{
    font-size: 18px;
    font-weight: 800;
  }
}

/* Panel icindeki bloklari gizleme kaldirildi (islev kiriyordu). */

/* Sub-header brand - mobilde gizle */
.sub-header-brand {
  display: none;
}

/* Sub-header left */
.sub-header-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sub-header-left::-webkit-scrollbar {
  display: none;
}

/* Sub-header center - mobilde gizle */
.sub-header-center {
  display: none;
}

/* Sub-header right */
.sub-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Sub-header butonlar */
.sub-header button,
.sub-header .btn,
.sub-header-filter-btn,
.sub-header-tools-btn,
.sub-header-areas-btn,
.sub-header-planning-btn,
.sub-header-locate-btn,
.sub-header-map-btn {
  min-width: var(--btn-min-size);
  min-height: var(--btn-min-size);
  height: var(--btn-min-size);
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--hair, #e5e7eb);
  border-radius: 8px;
  background: var(--card, #ffffff);
  color: var(--fg, #0f172a);
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Mobilde ikon-temelli sub-header: label span'leri kapalı kalsın */
@media (max-width: 896px) {
  .mu-label{ display:none !important; }
  /* Zoom level küçük kalsın */
  #zoomLevelDisplay { font-size: 9px !important; }
}

.sub-header button:active,
.sub-header .btn:active {
  background: var(--neutral-100, #f1f5f9);
  transform: scale(0.95);
}

.sub-header button svg,
.sub-header .btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Eriadne butonu */
.eriadne-btn {
  min-width: auto;
  padding: 0 8px;
  gap: 4px;
}

#eriadne-triangle {
  width: 24px;
  height: 24px;
}

.eriadne-btn-text {
  font-size: 14px;
}

/* Koordinat/ölçüm gibi ikincil şeyleri dokunmatikte gizle.
   NOT: sub-header hover hint (desktop/touch laptop) kaybolmasın; onu sadece küçük ekranda gizleyeceğiz. */
.sub-header-coords-hint,
.sub-header-coords,
.sub-header-measure {
  display: none;
}

@media (max-width: 768px) {
  .sub-header-hint { display: none !important; }
}

/* Loading spinner */
.sub-header-loading {
  display: none;
}

/* Map controls */
.sub-header-map-controls {
  display: flex;
  align-items: center;
  gap: 1px;
}

/* Layer dropdown */
.sub-header-map-select,
#layerDropdownBtn {
  /* HTML inline style min-width:180px'i ezmek icin !important gerekli */
  min-width: 80px !important;
  max-width: 100px !important;
  font-size: 10px;
  padding: 0 6px;
  justify-content: space-between;
}

#layerDropdownLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* Zoom buttons (sadece zoom +/- kompakt kalsın; "Sorgu" butonu metin gösterebilsin) */
#subHeaderZoomIn,
#subHeaderZoomOut {
  width: var(--btn-min-size);
  padding: 0;
}

/* "Haritadan Sorgula" metin modunda auto genişlesin */
#subHeaderMapQuery {
  width: auto !important;
  padding: 0 10px !important;
}

#zoomLevelDisplay {
  font-size: 9px;
  position: absolute;
  right: 2px;
  bottom: 2px;
  background: var(--bg);
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1;
}

/* Weather card + theme switch: mobilde gizle (ui-weather inline display:flex basabildiği için !important şart) */
.weather-card,
#weatherCard,
.theme-switch {
  display: none !important;
}

/* Mobilde desktop statusbar'ı kapat (sol-alt hover hint) */
.statusbar{ display:none !important; }

/* Buyuk mobil + tablet benzeri (481px - 896px) */
@media (min-width: 481px) and (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .sub-header,
  #subHeader {
    padding: 0 12px;
    gap: 6px;
  }
  
  .sub-header-left {
    gap: 6px;
  }
  
  .sub-header-right {
    gap: 6px;
  }
  
  .sub-header-map-select {
    max-width: 140px;
    font-size: 12px;
  }
  
  .eriadne-btn-text {
    display: block;
    font-size: 16px;
  }
}

/* Desktop sub-header kurallari bu dosyada yok (<=896). */

/* ============ OVERLAY (Panel/Filter backdrop) ============ */
.panel-overlay,
.filter-overlay,
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: calc(var(--z-overlay));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.panel-overlay.active,
.filter-overlay.active,
.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Desktop overlay kurallari bu dosyada yok (<=896). */

/* ============ BUTONLAR ============ */
.btn {
  min-height: var(--btn-min-size);
  min-width: var(--btn-min-size);
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--hair, #e5e7eb);
  border-radius: 8px;
  background: var(--card, #ffffff);
  color: var(--fg, #0f172a);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
  opacity: 0.9;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--primary-600, #2563eb);
  color: #ffffff;
  border-color: var(--primary-600, #2563eb);
}

.btn.primary:active:not(:disabled) {
  background: var(--primary-700, #1d4ed8);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover {
  background: var(--neutral-100, #f1f5f9);
}

/* ============ FORM ELEMANLARI ============ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
select,
textarea {
  font-size: 16px; /* iOS zoom onleme */
  min-height: var(--btn-min-size);
  padding: 10px 12px;
  border: 1px solid var(--hair, #e5e7eb);
  border-radius: 8px;
  background: var(--bg, #f8fafc);
  color: var(--fg, #0f172a);
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-500, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============ LEAFLET KONTROLLER ============ */
.leaflet-control-zoom {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  margin: 12px;
}

.leaflet-control-zoom a,
.leaflet-bar a {
  width: var(--touch-target);
  height: var(--touch-target);
  line-height: var(--touch-target);
  font-size: 20px;
  font-weight: 600;
  border-bottom: 1px solid var(--hair, #e5e7eb);
}

.leaflet-control-zoom a:last-child {
  border-bottom: none;
}

.leaflet-control-zoom-in {
  border-radius: 10px 10px 0 0;
}

.leaflet-control-zoom-out {
  border-radius: 0 0 10px 10px;
}

/* Leaflet attribution - mobilde kucult */
.leaflet-control-attribution {
  font-size: 9px;
  padding: 2px 6px;
  max-width: calc(100vw - 100px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Leaflet popup */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
  margin: 14px;
  font-size: 14px;
}

.leaflet-popup-content .btn {
  margin-top: 8px;
}

/* Desktop leaflet kurallari bu dosyada yok (<=896). */

/* ============ KOORDINAT POPUP ============ */
#coordinatePopup {
  position: fixed;
  bottom: calc(var(--subheader-height) + 12px + var(--safe-bottom));
  left: 12px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  border-radius: 10px;
  font-size: 12px;
  z-index: 100;
  max-width: calc(100vw - 24px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Desktop coordinatePopup kurallari bu dosyada yok (<=896). */

/* ============ YATAY (LANDSCAPE) MODU ============ */
@media (max-width: 1024px) and (orientation: landscape), (hover: none) and (pointer: coarse) and (orientation: landscape) {
  :root {
    --header-height: 40px;
    --subheader-height: 38px;
    --btn-min-size: 34px;
    --touch-target: 36px;
    --filter-width: min(280px, 45vw);
    --panel-width: min(300px, 48vw);
  }
  
  header .brand-gaus {
    font-size: 18px;
  }
  
  header .brand-divider {
    height: 18px;
  }
  
  header .brand-periplus {
    font-size: 8px;
  }
  
  .filter,
  aside.filter {
    top: var(--header-height);
    bottom: var(--subheader-height);
    width: var(--filter-width);
  }
  
  .panel,
  aside.panel {
    top: var(--header-height);
    bottom: var(--subheader-height);
    width: var(--panel-width);
  }

  /* Landscape mobilde sub-header dar: sag taraftaki alan tasmasin */
  #layerDropdownBtn {
    min-width: var(--btn-min-size) !important;
    max-width: var(--btn-min-size) !important;
    width: var(--btn-min-size) !important;
    padding: 0 !important;
    justify-content: center !important;
  }
  #layerDropdownLabel {
    display: none !important;
  }

  /* Planlama butonunu ikonlastir (metin tasmasin) */
  .sub-header-planning-btn span {
    display: none !important;
  }
  .sub-header-planning-btn::before {
    content: "📅";
    font-size: 14px;
    line-height: 1;
  }
}

/* ============ COK KUCUK EKRANLAR (360px ve alti) ============ */
@media (max-width: 374px) {
  :root {
    --header-height: 44px;
    --subheader-height: 42px;
    --btn-min-size: 34px;
    --touch-target: 36px;
  }
  
  header {
    padding: 0 6px;
    gap: 4px;
  }
  
  header .brand {
    max-width: 80px;
  }
  
  header .brand-gaus {
    font-size: 16px;
  }
  
  header .brand-divider {
    height: 18px;
    width: 1.5px;
  }
  
  header .brand-periplus {
    font-size: 7px;
  }
  
  header .searchbar {
    max-width: 90px;
  }
  
  header .searchbar input {
    height: 30px;
    font-size: 12px;
    padding-left: 28px;
  }
  
  .sub-header,
  #subHeader {
    padding: 0 6px;
    gap: 3px;
  }
  
  .sub-header button,
  .sub-header .btn {
    min-width: 36px;
    min-height: 36px;
    height: 36px;
    padding: 0 6px;
  }
  
  .sub-header button svg,
  .sub-header .btn svg {
    width: 16px;
    height: 16px;
  }
  
  #eriadne-triangle {
    width: 20px;
    height: 20px;
  }
  
  .eriadne-btn-text {
    display: none;
  }
}

/* ============ DOKUNMATIK CIHAZ OPTIMIZASYONLARI ============ */
@media (hover: none) and (pointer: coarse) {
  /* Touch cihazlarda hover efektleri kaldir */
  .btn:hover {
    background: var(--card, #ffffff);
  }
  
  .btn.primary:hover {
    background: var(--primary-600, #2563eb);
  }
  
  /* Active durumunda geri bildirim */
  .btn:active:not(:disabled),
  button:active:not(:disabled) {
    transform: scale(0.95);
    opacity: 0.85;
  }
  
  /* Scroll optimizasyonu */
  .filter-body,
  .panel-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
  }
  
  /* Harita touch */
  .map,
  #map,
  .leaflet-container {
    touch-action: pan-x pan-y pinch-zoom;
    -webkit-user-select: none;
    user-select: none;
  }
}

/* Mobilde haritaya alan ac: status/hint barlarini gizle (main.css'ten gelebiliyor) */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .statusbar,
  .hint {
    display: none !important;
  }
}

/* ============ HIGH DPI EKRANLAR ============ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .btn,
  .filter-btn,
  input,
  select {
    border-width: 0.5px;
  }
}

/* ============ PRINT MODU ============ */
@media print {
  header,
  .sub-header,
  .filter,
  .panel {
    display: none;
  }
  
  main,
  .map-wrap,
  .map,
  #map {
    position: static;
    width: 100%;
    height: auto;
  }
}

/* ============ BODY SCROLL LOCK ============ */
body.panel-open,
body.filter-open,
body.modal-open {
  overflow: hidden;
}

/* ===== Eski Mobil Davranış: Sidebar açılınca header + sub-header gizle =====
   Kullanıcı akışı: sidebar (filter/panel) tam ekran overlay olur; üst/alt barlar görünmez. */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  body.filter-open header,
  body.panel-open header,
  body.filter-open .sub-header,
  body.panel-open .sub-header,
  body.filter-open #subHeader,
  body.panel-open #subHeader {
    display: none !important;
  }

  /* Header/sub-header gizlenince sidebar'lar tam ekran olsun */
  body.filter-open .filter,
  body.filter-open aside.filter,
  body.panel-open .panel,
  body.panel-open aside.panel {
    /* Android cihazlarda safe-area-inset-top genelde 0 geliyor.
       Sidebar 0'dan başlayınca kamera/status bar arkasında beyaz şerit görünüyor.
       Çözüm: üstte header-height kadar boşluk bırak; o bölgede harita/normal ekran görünsün. */
    top: var(--header-height) !important;
    bottom: 0 !important;
  }

  /* Not: Arka planı koyulaştırmıyoruz; kullanıcı "normal ekran" istiyor. */

  /* Mobil overlay, tam ekran sidebar için biraz daha üstte kalsın */
  .mobile-overlay.active {
    z-index: var(--z-overlay) !important;
  }
}

/* ============ ANIMASYONLAR ============ */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

/* ========================================================================
   MOBIL SUB-HEADER (TEXT-ONLY) — EN SON OVERRIDE
   Amaç: mobilde kutu/konteyner yok, sadece tıklanabilir metin; weather/theme kapalı.
   Bu blok dosyanın EN SONUNDA: önceki kuralları garanti ezer.
   ======================================================================== */
@media (max-width: 1024px), (pointer: coarse) and (max-width: 1400px) {
  /* Mobilde hava durumu + dark toggle asla görünmesin (JS inline display basabilir) */
  .weather-card,
  #weatherCard,
  .theme-switch {
    display: none !important;
  }

  /* Sub-header "konteyner" hissi kaldır */
  .sub-header,
  #subHeader {
    background: transparent !important;
    border-top: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  /* İkonları gizle, metinleri göster */
  .sub-header button svg,
  .sub-header .btn svg,
  #eriadne-triangle {
    display: none !important;
  }

  /* Eriadne metin */
  .eriadne-btn-text {
    display: inline !important;
    font-size: 14px !important;
    font-weight: 800 !important;
  }

  /* Eğer mu-label varsa mobilde aç */
  .mu-label {
    display: inline !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    letter-spacing: 0.1px;
  }

  /* Butonları link gibi yap */
  .sub-header button,
  .sub-header .btn,
  .sub-header-map-select,
  #layerDropdownBtn {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    min-height: 44px !important;
    height: 44px !important;
    min-width: auto !important;
    width: auto !important;
    padding: 0 8px !important;
    color: var(--primary-700, #1E3A8A) !important;
    font-size: 14px !important;
    font-weight: 800 !important;
  }

  /* Basınca feedback */
  .sub-header button:active,
  .sub-header .btn:active,
  #layerDropdownBtn:active {
    opacity: 0.75;
    transform: none !important;
  }

  /* Hint (Filtre ile eriadne arası) mobilde görünür kalsın */
  #subHeaderHint {
    display: block !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: var(--muted, #64748b) !important;
  }

  /* Gruplar taşarsa yatay kaydır */
  .sub-header-left,
  .sub-header-right {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none;
  }
  .sub-header-left::-webkit-scrollbar,
  .sub-header-right::-webkit-scrollbar {
    display: none;
  }

  /* Layer dropdown'a caret ekle (ikon yok) */
  #layerDropdownBtn::after {
    content: "▾";
    font-weight: 900;
    margin-left: 6px;
    opacity: 0.8;
  }
}
