/* Harita ve Konum Uyarı Sistemi - Stiller */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-dark: #15803d;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: 100vh;
  min-height: 0;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 380px;
  min-width: 280px;
  max-width: 520px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease, min-width 0.2s ease, border-color 0.2s ease;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  border-right: none;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-inner {
  opacity: 0;
  visibility: hidden;
}

.sidebar-inner {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-bottom {
  flex-shrink: 0;
  border-top: 2px solid var(--border);
  background: var(--surface);
  max-height: 55%;
  overflow-y: auto;
}

.sidebar-resizer {
  width: 6px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  margin-left: -3px;
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging {
  background: rgba(37, 99, 235, 0.25);
}

.sidebar.collapsed + .sidebar-resizer {
  display: none;
}

.sidebar-toggle {
  position: absolute;
  left: var(--sidebar-width, 380px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  width: 28px;
  height: 60px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 10px 10px 0;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.12);
  transition: left 0.2s ease, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.sidebar-toggle:hover {
  background: #f8fafc;
  color: var(--primary);
  box-shadow: 2px 0 12px rgba(37, 99, 235, 0.2);
}

.sidebar-toggle .toggle-icon {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

.sidebar.collapsed ~ .sidebar-toggle {
  left: 0;
  border-left: 1px solid var(--border);
  border-radius: 0 10px 10px 0;
  pointer-events: auto;
}

.panel {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-weight: 500;
}

/* Arama */
.search-box {
  display: flex;
  gap: 0.5rem;
}

.search-box input {
  flex: 1;
}

.search-results {
  list-style: none;
  margin-top: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
}

.search-results li {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.35rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.search-results li:hover {
  background: #eff6ff;
  border-color: var(--primary);
}

.search-results .result-name {
  font-weight: 500;
}

.search-results .result-address {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Navigasyon paneli */
.nav-instruction {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: #1e40af;
}

.nav-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.nav-dest-icon {
  background: transparent;
  border: none;
}

.nav-dest-pin {
  width: 18px;
  height: 18px;
  background: #16a34a;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.nav-start-hint {
  margin-bottom: 0.65rem;
}

.route-options {
  list-style: none;
  margin: 0.75rem 0;
  max-height: 200px;
  overflow-y: auto;
}

.route-option {
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.route-option:hover {
  background: #f8fafc;
}

.route-option.selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.route-option .route-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.route-option .route-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.route-option .route-meta {
  font-size: 0.8rem;
  color: #1e40af;
  margin-top: 0.2rem;
}

/* Dönüş talimatı — sidebar üst yanı */
.turn-hint {
  position: fixed;
  top: 10px;
  left: calc(var(--sidebar-width, 380px) + 10px);
  z-index: 1002;
  background: #0f172a;
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  min-width: 88px;
  text-align: center;
  transition: left 0.2s ease;
  pointer-events: none;
}

.turn-hint.hidden {
  display: none;
}

.turn-hint-dir {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.turn-hint-dist {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

.sidebar.collapsed ~ .turn-hint {
  left: 38px;
}

.btn-nav {
  background: #1e40af;
  color: white;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-nav:hover {
  background: #1e3a8a;
}

/* Form */
.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row .form-group {
  flex: 1;
}

.form-save-row {
  align-items: flex-end;
}

.form-save-row .form-group {
  margin-bottom: 0;
}

.form-save-row .form-actions {
  flex-shrink: 0;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input[readonly] {
  background: #f8fafc;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: -0.35rem 0 0.75rem;
}

/* Butonlar */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: var(--success-dark);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-edit {
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-edit:hover {
  background: var(--primary-dark);
}

/* Konum listesi */
.location-list {
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
}

.location-item {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.location-item:hover,
.location-item.active {
  background: #eff6ff;
  border-color: var(--primary);
}

.location-item .item-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.location-item .item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.location-item .item-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

/* Ayarlar / durum */
.settings-panel {
  padding: 0;
  border-bottom: none;
}

.collapsible-panel .collapsible-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  border: none;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
}

.collapsible-panel .collapsible-header:hover {
  background: #f1f5f9;
}

.collapsible-panel .collapsible-header h2 {
  margin-bottom: 0;
  flex: 1;
}

.collapsible-chevron {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  line-height: 1;
}

.collapsible-panel.expanded .collapsible-chevron {
  transform: rotate(90deg);
}

.collapsible-body {
  display: none;
  padding: 0.75rem 1.25rem 1rem;
}

.collapsible-panel.expanded .collapsible-body {
  display: block;
}

.sidebar-bottom .nav-panel {
  border-bottom: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.gps-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: #f8fafc;
  border-radius: var(--radius);
}

.gps-status.active {
  color: var(--success);
  background: #f0fdf4;
}

.gps-status.error {
  color: var(--danger);
  background: #fef2f2;
}

/* Kırmızı marker */
.red-marker-icon {
  background: transparent;
  border: none;
}

.red-marker-pin {
  width: 28px;
  height: 28px;
  background: var(--danger);
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  margin-left: 2px;
}

.red-marker-pin::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.red-marker-pin {
  position: relative;
}

/* Harita alanı */
.map-area {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 420px;
  background: #e2e8f0;
}

.map-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  color: var(--danger);
  background: #fef2f2;
  z-index: 500;
}

/* Uyarı banner */
.alert-banner {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--warning);
  color: #78350f;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 90%;
  animation: slideDown 0.3s ease;
}

.alert-banner.hidden {
  display: none;
}

.alert-banner .alert-dismiss {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #78350f;
  line-height: 1;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Leaflet popup özelleştirme */
.leaflet-popup-content {
  font-family: inherit;
  font-size: 0.875rem;
}

.popup-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.popup-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.popup-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Responsive — mobil: tam ekran harita + alttan panel */
@media (max-width: 768px) {
  :root {
    --mobile-nav-height: 56px;
  }

  body.is-mobile .main-layout {
    flex-direction: row;
  }

  body.is-mobile .map-area {
    position: fixed;
    inset: 0;
    bottom: var(--mobile-nav-height);
    z-index: 1;
  }

  body.is-mobile #map {
    min-height: 0;
  }

  body.is-mobile .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--mobile-nav-height);
    top: auto;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    max-height: none !important;
    height: auto;
    z-index: 1100;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
    transform: translateY(100%);
    transition: transform 0.28s ease;
    pointer-events: auto;
  }

  body.is-mobile .sidebar.mobile-open {
    transform: translateY(0);
  }

  body.is-mobile .sidebar.collapsed {
    transform: translateY(100%);
    width: 100% !important;
    pointer-events: none;
  }

  body.is-mobile .sidebar.collapsed .sidebar-inner {
    opacity: 1;
    visibility: visible;
  }

  body.is-mobile .sidebar-inner {
    max-height: min(78vh, calc(100vh - var(--mobile-nav-height) - 24px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.is-mobile .sidebar-scroll,
  body.is-mobile .sidebar-bottom {
    max-height: none;
    border-top: none;
    overflow: visible;
  }

  body.is-mobile .sidebar-scroll {
    flex: none;
  }

  body.is-mobile .sidebar [data-mobile-tab] {
    display: none;
  }

  body.is-mobile .sidebar.mobile-tab-places [data-mobile-tab="places"],
  body.is-mobile .sidebar.mobile-tab-nav [data-mobile-tab="nav"],
  body.is-mobile .sidebar.mobile-tab-settings [data-mobile-tab="settings"] {
    display: block;
  }

  body.is-mobile .mobile-sheet-header {
    display: flex;
  }

  body.is-mobile .mobile-tab-places .sidebar-bottom,
  body.is-mobile .mobile-tab-nav .sidebar-scroll,
  body.is-mobile .mobile-tab-settings .sidebar-scroll {
    display: none;
  }

  body.is-mobile .mobile-tab-settings .collapsible-body {
    display: block;
  }

  body.is-mobile .mobile-tab-settings .collapsible-header {
    display: none;
  }

  body.is-mobile .settings-panel {
    padding: 0;
  }

  body.is-mobile .settings-panel .collapsible-body {
    padding: 1rem 1.25rem;
  }

  body.is-mobile .sidebar-resizer,
  body.is-mobile .sidebar-toggle {
    display: none !important;
  }

  body.is-mobile .turn-hint {
    left: 10px;
    top: 10px;
    bottom: auto;
  }

  body.is-mobile .alert-banner {
    top: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  body.is-mobile .search-results {
    max-height: 40vh;
  }

  body.is-mobile .route-options {
    max-height: 35vh;
  }

  body.is-mobile .location-list {
    max-height: none;
  }

  body.is-mobile .panel {
    padding: 0.85rem 1rem;
  }

  body.is-mobile .panel h2 {
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
  }

  body.is-mobile .nav-panel h2,
  body.is-mobile .search-panel h2,
  body.is-mobile .list-panel h2,
  body.is-mobile .form-panel h2 {
    display: none;
  }

  .mobile-sheet-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem 0.35rem;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
    border-bottom: 1px solid var(--border);
  }

  .mobile-sheet-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
  }

  .mobile-sheet-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1050;
    opacity: 0;
    transition: opacity 0.28s ease;
    pointer-events: none;
  }

  .mobile-sheet-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-sheet-backdrop[hidden] {
    display: none;
  }

  .mobile-bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--mobile-nav-height);
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 1200;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  }

  body.is-mobile .mobile-bottom-nav {
    display: flex;
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.35rem 0.25rem;
    transition: color 0.15s;
  }

  .mobile-nav-btn.active {
    color: var(--primary);
  }

  .mobile-nav-icon {
    font-size: 1.15rem;
    line-height: 1;
  }

  .mobile-nav-label {
    line-height: 1.1;
  }
}
