/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; font-family: 'Segoe UI', system-ui, sans-serif; overflow: hidden; }

:root {
  --primary:       #2b8a3e;
  --primary-dark:  #1a5a2a;
  --primary-light: #e8f5e9;
  --bg:            #ffffff;
  --text:          #2c2c2c;
  --border:        #e0e0e0;
  --sidebar-w:     380px;
  --speed:         0.28s;
  --z-controls:    1000;
  --z-panels:      1001;
  --z-backdrop:    998;
  --ctrl-h:        42px;
}

/* ===== MAP ===== */
#app-container { position: relative; width: 100%; height: 100%; }
#map { width: 100%; height: 100%; }
.maplibregl-ctrl-attrib { font-size: 10px !important; }

/* ===== BACKDROP ===== */
.panel-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.18);
  z-index: var(--z-backdrop);
  display: none;
  /* Na desktope backdrop nikdy neblokuje mapu */
  pointer-events: none;
}
/* Backdrop sa na desktope vôbec nezobrazuje — len na mobile pre modálne panely */
@media (min-width: 769px) {
  .panel-backdrop.active { display: none !important; }
}
@media (max-width: 768px) {
  .panel-backdrop.active { display: block; pointer-events: auto; }
}

/* ===== DESKTOP TOP BAR ===== */
.top-ui-bar-desktop {
  position: fixed;
  top: 14px; left: 14px; right: 14px;
  z-index: var(--z-controls);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  transition: left var(--speed) ease;
}
.top-ui-bar-desktop.sidebar-open { left: calc(var(--sidebar-w) + 14px); }

.left-controls, .right-controls {
  display: flex; gap: 7px; flex-wrap: wrap;
  pointer-events: auto;
}

/* ── Control button ── */
.control-btn {
  height: var(--ctrl-h);
  padding: 0 14px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(0,0,0,0.09);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,0.11);
  display: flex; align-items: center; gap: 7px;
  white-space: nowrap;
  transition: all 0.16s;
  user-select: none;
}
.control-btn.icon-only { padding: 0; width: var(--ctrl-h); justify-content: center; }
.control-btn i { font-size: 15px; color: var(--primary); }
.control-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(43,138,62,0.2);
}
.control-btn:active { transform: translateY(0); }

/* ── COMPASS tlačidlo ── */
.compass-btn .compass-needle {
  transition: transform 0.3s ease;
  display: block;
}
.compass-btn.rotated {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ===== DESKTOP SIDEBAR ===== */
#desktop-sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100%;
  background: var(--bg);
  box-shadow: 3px 0 20px rgba(0,0,0,0.11);
  z-index: var(--z-panels);
  transition: transform var(--speed) ease;
  display: flex; flex-direction: column; overflow: hidden;
}
#desktop-sidebar.panel-hidden { transform: translateX(-100%); }
#desktop-sidebar-inner { display: flex; flex-direction: column; height: 100%; }

.sidebar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-header h3 { font-size: 15px; font-weight: 700; }
.btn-close {
  background: none; border: none; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer; font-size: 18px; color: #888;
  transition: all 0.16s;
}
.btn-close:hover { background: #f0f0f0; color: var(--primary); }

.panel-content { padding: 18px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

/* ===== DETAIL ===== */
.panel-img-main { width: 100%; height: 210px; object-fit: cover; border-radius: 10px; margin-bottom: 4px; }
.panel-inner { padding: 14px 0; }

/* Riadok s ikonou a názvom */
.panel-title-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.place-icon-emoji {
  font-size: 26px; line-height: 1; flex-shrink: 0;
}
.panel-title { font-size: 21px; font-weight: 700; color: var(--text); }

.panel-categories { margin-bottom: 14px; }
.tag-kat { display: inline-block; background: var(--primary-light); color: var(--primary); font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px; }
.tag-subkat { display: inline-block; background: #f0f4ff; color: #3a5ccc; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; letter-spacing: 0.3px; margin-left: 5px; }
.panel-info-list { list-style: none; padding: 12px 0; margin: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.panel-info-list li { margin: 7px 0; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.panel-info-list i { color: var(--primary); margin-top: 2px; width: 14px; flex-shrink: 0; }
.panel-info-list a { color: var(--primary); text-decoration: none; font-weight: 500; }
.panel-info-list a:hover { text-decoration: underline; }
.panel-description { font-size: 14px; line-height: 1.65; color: #555; margin-bottom: 18px; }
.section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: #888; margin-bottom: 10px; }
.panel-gallery { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-bottom: 18px; }
.gal-item { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; transition: transform 0.18s; }
.gal-item:hover { transform: scale(1.05); }
.panel-footer { background: var(--primary-light); padding: 14px; border-radius: 10px; }
.gps-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.gps-row span { font-family: monospace; font-size: 11px; color: #444; }
.btn-copy { background: white; border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text); transition: all 0.16s; white-space: nowrap; }
.btn-copy:hover { background: var(--primary); color: white; border-color: var(--primary); }
.btn-route-plan, .btn-share { width: 100%; background: var(--primary); color: white; border: none; padding: 11px; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer; transition: background 0.16s; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-route-plan:hover, .btn-share:hover { background: var(--primary-dark); }

/* Basemap btns */
.basemap-btn { display: block; width: 100%; padding: 12px 14px; margin-bottom: 8px; background: white; border: 2px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; text-align: left; transition: all 0.16s; }
.basemap-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.basemap-btn.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* Route */
.route-section { margin-bottom: 14px; }
.route-section h4 { font-size: 11px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 7px; }
.route-type-select, .route-search-input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; outline: none; background: white; }
.route-type-select:focus, .route-search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.route-search-results { position: absolute; left: 0; right: 0; background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.12); max-height: 160px; overflow-y: auto; z-index: 2000; margin-top: 4px; }
.route-search-item { padding: 9px 12px; border-bottom: 1px solid #f0f0f0; cursor: pointer; font-size: 12px; }
.route-search-item:hover { background: var(--primary-light); }
.route-search-item:last-child { border-bottom: none; }
.route-search-item strong { display: block; font-size: 13px; }
.route-search-item small { color: #888; }
.route-info { background: #f5f5f5; padding: 10px; border-radius: 7px; font-size: 12px; margin-top: 8px; line-height: 1.5; }
.route-waypoints-list { max-height: 130px; overflow-y: auto; margin-top: 8px; }
.route-waypoint-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 8px; background: #f7f7f7; border-radius: 5px; margin-bottom: 5px; font-size: 12px; }
.route-waypoint-remove { background: #e74c3c; color: white; border: none; padding: 3px 8px; border-radius: 4px; cursor: pointer; font-size: 10px; font-weight: 600; }
.route-waypoint-remove:hover { background: #c0392b; }
.route-buttons { display: flex; gap: 8px; margin-top: 12px; }
.route-btn { flex: 1; padding: 10px; border: none; border-radius: 7px; cursor: pointer; font-weight: 700; font-size: 13px; transition: all 0.16s; }
.route-btn-start { background: var(--primary); color: white; }
.route-btn-start:hover { background: var(--primary-dark); }
.route-btn-clear { background: #e74c3c; color: white; }
.route-btn-clear:hover { background: #c0392b; }

/* Search */
.search-results { background: white; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.13); overflow: hidden; z-index: 1501; max-height: 320px; overflow-y: auto; border: 1px solid var(--border); }
.res-item { padding: 10px 14px; border-bottom: 1px solid #f2f2f2; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 13px; transition: background 0.14s; }
.res-item:hover { background: var(--primary-light); }
.res-item:last-child { border-bottom: none; }
.res-item.local { color: var(--primary); }
.res-item.global { color: #555; }
/* Ikona vo výsledku vyhľadávania */
.res-item-icon { font-size: 20px; flex-shrink: 0; line-height: 1; width: 26px; text-align: center; }
.res-item-content { flex: 1; min-width: 0; }
.res-item-content strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-item-content small { display: block; color: #999; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-header { display: flex; justify-content: space-between; align-items: center; padding: 7px 14px 5px; font-size: 10px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1px solid #f0f0f0; }
.history-clear-btn { background: none; border: none; color: #ccc; font-size: 11px; cursor: pointer; }
.history-clear-btn:hover { color: #e74c3c; }
/* Vzdialenosť vo výsledku vyhľadávania */
.res-dist { font-size: 10px; color: var(--primary); font-weight: 700; white-space: nowrap; flex-shrink: 0; margin-left: 6px; background: var(--primary-light); padding: 2px 6px; border-radius: 10px; }
/* Subtitle v paneli (display_name z nominatim) */
.panel-subtitle { font-size: 11px; color: #999; margin-bottom: 12px; line-height: 1.4; }
.filter-label { font-size: 11px; font-weight: 700; color: #888; display: block; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.4px; }
.filter-select { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; outline: none; cursor: pointer; background: white; }
.filter-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== LOADING ===== */
#map-loading {
  position: fixed; inset: 0; z-index: 9999;
  background: #f2ede6;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  transition: opacity 0.4s;
}
#map-loading.done { opacity: 0; pointer-events: none; }
.spinner { width: 38px; height: 38px; border: 3px solid #d4ccc0; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#map-loading p { font-size: 14px; color: #888; font-weight: 500; }

/* ===== MOBILE ===== */
.top-ui-bar-mobile { display: none; }
.mobile-controls { display: none; }
#mobile-bottom-sheet { display: none; }

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .top-ui-bar-desktop { display: none; }

  /* Mobile search bar */
  .top-ui-bar-mobile {
    display: block; position: fixed;
    top: 10px; left: 50%; transform: translateX(-50%);
    z-index: var(--z-controls); width: 90%; max-width: 400px; pointer-events: auto;
  }
  .search-container-mobile { position: relative; }
  #search-input {
    width: 100%; height: 46px; padding: 10px 10px 10px 42px;
    border: none; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.16);
    font-size: 16px; outline: none;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(10px);
  }
  .search-icon { position: absolute; left: 15px; top: 15px; color: #888; font-size: 16px; pointer-events: none; }
  #search-results { position: absolute; top: 52px; left: 0; width: 100%; z-index: 1502; max-height: 300px; overflow-y: auto; }

  /* Mobile controls — ĽAVÁ strana */
  .mobile-controls {
    display: flex;
    position: fixed; left: 12px; bottom: 30px;
    z-index: var(--z-controls);
    flex-direction: column; gap: 9px;
    pointer-events: auto;
  }
  .mobile-control-btn {
    width: 48px; height: 48px;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(0,0,0,0.09);
    border-radius: 50%;
    cursor: pointer; font-size: 18px; color: var(--primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.13);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.16s; padding: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-control-btn:active { background: var(--primary-light); transform: scale(0.92); }
  .compass-btn.rotated { border-color: var(--primary); background: var(--primary-light); }

  /* Mobile panels */
  .mobile-panel { position: fixed; bottom: 0; left: 0; right: 0; background: white; border-radius: 18px 18px 0 0; padding: 18px; max-height: 65vh; overflow-y: auto; box-shadow: 0 -4px 24px rgba(0,0,0,0.14); z-index: 1502; }
  .mobile-panel.hidden { display: none; }
  .mobile-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
  .mobile-panel-header h4 { font-size: 16px; font-weight: 700; }
  .mobile-panel-close { background: none; border: none; font-size: 20px; color: #aaa; cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
  .mobile-panel-close:active { background: #f0f0f0; }
  .mobile-select { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; font-size: 14px; outline: none; }
  .mobile-input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
  .mobile-action-btn { width: 100%; padding: 13px; border: none; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 14px; margin-top: 8px; }
  .mobile-action-btn.primary { background: var(--primary); color: white; }
  .mobile-action-btn.danger { background: #e74c3c; color: white; }
  .basemap-options { display: flex; flex-direction: column; gap: 8px; }
  .basemap-option { padding: 13px 14px; background: white; border: 2px solid var(--border); border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; text-align: left; transition: all 0.16s; }
  .basemap-option:hover { border-color: var(--primary); }
  .basemap-option.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

  /* Mobile bottom sheet */
  #mobile-bottom-sheet {
    display: flex; flex-direction: column;
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: var(--bg); border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.14);
    z-index: var(--z-panels);
    transition: transform var(--speed) ease-out;
    height: 80vh;
  }
  #mobile-bottom-sheet.sheet-hidden { transform: translateY(100%); }
  #mobile-bottom-sheet.sheet-preview-only { transform: translateY(calc(80vh - 80px)); }
  #mobile-bottom-sheet.sheet-expanded { transform: translateY(0); }
  /* Počas dragu odstránime transition cez JS (sheet.style.transition='none') */
  #mobile-bottom-sheet { will-change: transform; touch-action: pan-y; }

  .sheet-drag-handle { width: 100%; height: 22px; display: flex; justify-content: center; align-items: center; cursor: grab; flex-shrink: 0; }
  .sheet-drag-handle span { width: 36px; height: 4px; background: #ddd; border-radius: 2px; }
  .sheet-close-btn { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 20px; cursor: pointer; color: #aaa; z-index: 10; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; transition: color 0.16s; }
  .sheet-close-btn:hover { color: var(--primary); }
  .sheet-preview { height: 64px; padding: 0 20px; display: flex; align-items: center; gap: 14px; cursor: pointer; flex-shrink: 0; }
  .sheet-preview img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
  .sheet-preview h3 { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sheet-content { padding: 16px 20px; overflow-y: auto; flex: 1; border-top: 1px solid #eee; }

  /* Menšia ikona v paneli na mobile */
  .place-icon-emoji { font-size: 22px; }
  .panel-title { font-size: 18px; }
}

/* MapLibre popup */
.maplibregl-popup-content { border-radius: 10px !important; padding: 0 !important; box-shadow: 0 4px 20px rgba(0,0,0,0.16) !important; font-family: inherit !important; min-width: 140px; }
.map-popup { padding: 10px 13px; font-size: 13px; }
.map-popup strong { display: block; font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.map-popup small { color: #888; }

/* ── GPS kruhový marker (pulsujúci) ─────────────────────────── */
.gps-dot-marker { position: relative; width: 20px; height: 20px; }
.gps-dot-core {
  position: absolute; inset: 0; margin: auto;
  width: 14px; height: 14px;
  background: #2b8a3e; border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(43,138,62,0.5);
  z-index: 2;
}
.gps-dot-pulse {
  position: absolute; inset: -8px;
  background: rgba(43,138,62,0.18);
  border-radius: 50%;
  animation: gps-pulse 1.8s ease-out infinite;
  z-index: 1;
}
@keyframes gps-pulse {
  0%   { transform: scale(0.4); opacity: 0.9; }
  70%  { transform: scale(1);   opacity: 0.1; }
  100% { transform: scale(1);   opacity: 0; }
}

/* ── Dočasný pin (vyhľadávanie / long press / klik) ───────────── */
.temp-pin-marker { position: relative; width: 24px; height: 24px; }
.temp-pin-dot {
  position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px;
  background: #3b82f6; border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(59,130,246,0.55);
  z-index: 2;
}
.temp-pin-pulse {
  position: absolute; inset: -7px;
  background: rgba(59,130,246,0.2);
  border-radius: 50%;
  animation: temp-pulse 1.6s ease-out infinite;
  z-index: 1;
}
.temp-pin-tail { display: none; }
@keyframes temp-pulse {
  0%   { transform: scale(0.5); opacity: 0.9; }
  70%  { transform: scale(1);   opacity: 0.1; }
  100% { transform: scale(1);   opacity: 0; }
}

/* ── Podkategória tag ───────────────────────────────────────── */
.tag-subkat {
  display: inline-block; background: #f0f4ff; color: #3a5ccc;
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; letter-spacing: 0.3px; margin-left: 5px;
}
