/* ============================================================
   AKMENŲ ARCHYVAS – Pagrindinis stilius
   ============================================================ */

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

:root {
  --green:       #1D9E75;
  --green-light: #E1F5EE;
  --green-dark:  #0F6E56;
  --amber:       #BA7517;
  --amber-light: #FAEEDA;
  --red:         #A32D2D;
  --red-light:   #FCEBEB;
  --purple:      #534AB7;
  --purple-light:#EEEDFE;
  --blue:        #185FA5;
  --blue-light:  #E6F1FB;
  --gray-50:     #f9f9f8;
  --gray-100:    #f1f0ed;
  --gray-200:    #e2e1dc;
  --gray-400:    #9a9890;
  --gray-600:    #6b6960;
  --gray-900:    #1a1a18;
  --border:      rgba(0,0,0,0.1);
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(0,0,0,0.12);
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; overflow: hidden; font-family: var(--font); color: var(--gray-900); background: var(--gray-100); font-size: 14px; }

/* ── TOP BAR ─────────────────────────────────────────────── */
#topbar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px;
  background: white; border-bottom: 1px solid var(--border);
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--gray-900); text-decoration: none; white-space: nowrap; }
.logo-icon { width: 30px; height: 30px; background: var(--green-light); border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
#search-wrap { flex: 1; max-width: 440px; position: relative; }
#search-input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--gray-50); font-size: 13px; outline: none; transition: border-color .15s; }
#search-input:focus { border-color: var(--green); background: white; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 15px; pointer-events: none; }
#search-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 200; display: none; max-height: 280px; overflow-y: auto; }
.search-result-item { padding: 9px 14px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; gap: 8px; }
.search-result-item:hover { background: var(--gray-50); }
.search-result-item:last-child { border-bottom: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); font-size: 13px; cursor: pointer; border: 1px solid var(--gray-200); background: white; color: var(--gray-900); text-decoration: none; transition: background .12s; }
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--green); color: white; border-color: var(--green-dark); }
.btn-primary:hover { background: var(--green-dark); }

/* ── LAYOUT ──────────────────────────────────────────────── */
#app { display: flex; height: calc(100vh - 52px); margin-top: 52px; }

/* ── SIDENAV ─────────────────────────────────────────────── */
#sidenav {
  width: 52px; flex-shrink: 0;
  background: white; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0; gap: 4px; z-index: 100;
}
.snav-btn { width: 38px; height: 38px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--gray-400); font-size: 19px; transition: all .12s; border: none; background: none; position: relative; }
.snav-btn:hover { background: var(--gray-100); color: var(--gray-900); }
.snav-btn.active { background: var(--green-light); color: var(--green); }
.snav-sep { width: 28px; height: 1px; background: var(--border); margin: 4px 0; }
.snav-bottom { margin-top: auto; }

/* ── VIEWS ───────────────────────────────────────────────── */
.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; }

/* ── SIDE PANEL TOGGLE ───────────────────────────────────── */
.side-panel {
  transition: width .25s ease, min-width .25s ease;
  overflow: hidden;
}
.side-panel.collapsed { width: 0 !important; min-width: 0 !important; padding: 0 !important; border: none !important; }

/* ── FILTERS PANEL ───────────────────────────────────────── */
#filters-panel {
  width: 210px; flex-shrink: 0; background: white;
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 14px 12px;
}
.fp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.fp-head-title { font-size: 11px; font-weight: 600; color: var(--gray-600); letter-spacing: .05em; text-transform: uppercase; }
.fp-clear { font-size: 11px; color: var(--blue); cursor: pointer; background: none; border: none; }
.fp-section { margin-bottom: 16px; }
.fp-section-label { font-size: 11px; font-weight: 600; color: var(--gray-600); margin-bottom: 7px; }
.fp-item { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; cursor: pointer; user-select: none; }
.fp-item-l { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--gray-900); }
.fp-item-l input[type=checkbox] { accent-color: var(--green); width: 14px; height: 14px; cursor: pointer; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.fp-count { font-size: 11px; color: var(--gray-400); }
.fp-select { width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid var(--gray-200); border-radius: var(--radius); background: white; outline: none; color: var(--gray-900); }
.fp-toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.toggle-sw { width: 34px; height: 19px; border-radius: 10px; background: var(--gray-200); position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.toggle-sw.on { background: var(--green); }
.toggle-sw::after { content: ''; width: 15px; height: 15px; border-radius: 50%; background: white; position: absolute; top: 2px; left: 2px; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-sw.on::after { left: 17px; }
.fp-footer { border-top: 1px solid var(--border); padding-top: 12px; font-size: 12px; color: var(--gray-600); display: flex; flex-direction: column; gap: 4px; }
.fp-footer strong { color: var(--gray-900); }

/* ── MAP ─────────────────────────────────────────────────── */
#map-wrap { flex: 1; position: relative; z-index: 1; }
#map { width: 100%; height: 100%; }

/* Leaflet customization */
.leaflet-popup-content-wrapper { border-radius: var(--radius-lg); box-shadow: 0 4px 16px rgba(0,0,0,.15); border: 1px solid var(--border); }
.leaflet-popup-content { margin: 14px 16px; min-width: 180px; }
.popup-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.popup-loc { font-size: 12px; color: var(--gray-600); margin-bottom: 8px; display: flex; align-items: center; gap: 4px; }
.popup-status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 8px; border-radius: 20px; margin-bottom: 10px; }
.popup-btn { display: block; width: 100%; text-align: center; padding: 7px; background: var(--green); color: white; border: none; border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 500; margin-bottom: 5px; }
.popup-btn:hover { background: var(--green-dark); }
.popup-btn-outline { display: block; width: 100%; text-align: center; padding: 6px; background: white; color: var(--blue); border: 1px solid var(--gray-200); border-radius: var(--radius); cursor: pointer; font-size: 11px; font-weight: 500; }
.popup-btn-outline:hover { background: var(--blue-light); }
.stone-name-tooltip { background: white; border: 1px solid var(--gray-200); border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.14); color: var(--gray-900); font-size: 12px; font-weight: 600; padding: 4px 8px; }
.stone-name-tooltip::before { border-top-color: var(--gray-200); }

/* Custom pin icons */
.pin-icon { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid white; box-shadow: 0 1px 5px rgba(0,0,0,.35); }

/* ── STONE LIST PANEL ────────────────────────────────────── */
#stone-list-panel {
  width: 240px; flex-shrink: 0; background: white;
  border-left: 1px solid var(--border);
  display: flex !important; flex-direction: column; overflow: hidden;
}
.slp-head { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.slp-title { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.slp-sort { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.slp-sort label { font-size: 11px; color: var(--gray-600); }
.slp-sort select { font-size: 11px; border: 1px solid var(--gray-200); border-radius: 5px; padding: 3px 6px; flex: 1; outline: none; }
#stone-list { flex: 1; overflow-y: auto; }
.stone-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background .1s; }
.stone-item:hover, .stone-item.active { background: var(--green-light); }
.stone-thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: var(--gray-100); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 16px; overflow: hidden; }
.stone-thumb img { width: 100%; height: 100%; object-fit: cover; }
.stone-info { flex: 1; min-width: 0; }
.stone-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stone-reg { font-size: 11px; color: var(--gray-600); }
.stone-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.slp-pagination { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--gray-600); }
.pg-btn { padding: 3px 8px; border: 1px solid var(--gray-200); border-radius: 5px; cursor: pointer; background: white; font-size: 12px; }
.pg-btn:hover { background: var(--gray-50); }
.pg-btn:disabled { opacity: .4; cursor: default; }

/* ── DETAIL PANEL ────────────────────────────────────────── */
#detail-panel {
  width: 320px; flex-shrink: 0; background: white;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .2s;
}
#detail-panel.hidden { display: none; }
.dp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.dp-back { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--blue); cursor: pointer; background: none; border: none; }
.dp-actions { display: flex; gap: 6px; }
.icon-btn { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--gray-200); border-radius: var(--radius); cursor: pointer; color: var(--gray-600); background: white; font-size: 15px; text-decoration: none; }
.icon-btn:hover { background: var(--gray-50); }
.dp-photo { height: 170px; flex-shrink: 0; position: relative; overflow: hidden; background: var(--gray-200); }
.dp-photo img { width: 100%; height: 100%; object-fit: cover; }
.dp-photo-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 40px; }
.dp-photo-count { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.55); color: white; font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.dp-body { flex: 1; overflow-y: auto; padding: 0 14px 16px; }
.dp-title { font-size: 17px; font-weight: 600; padding: 12px 0 2px; }
.dp-alt-name { font-size: 12px; color: var(--gray-400); font-style: italic; padding-bottom: 6px; }
.dp-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 9px; border-radius: 20px; margin-bottom: 12px; }
.dp-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 12px; gap: 0; }
.dp-tab { font-size: 11px; padding: 7px 10px; cursor: pointer; color: var(--gray-600); border-bottom: 2px solid transparent; white-space: nowrap; }
.dp-tab.active { color: var(--green); border-bottom-color: var(--green); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.dp-sec-label { font-size: 10px; font-weight: 600; color: var(--gray-400); letter-spacing: .05em; text-transform: uppercase; margin: 12px 0 6px; }
.dp-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 5px 0; border-bottom: 1px solid var(--gray-100); gap: 8px; font-size: 12px; }
.dp-row:last-child { border-bottom: none; }
.dp-k { color: var(--gray-600); flex-shrink: 0; }
.dp-v { color: var(--gray-900); font-weight: 500; text-align: right; }
.dp-desc-text { font-size: 12px; color: var(--gray-600); line-height: 1.65; }
.dp-comment-box { background: var(--gray-50); border-radius: var(--radius); padding: 9px 11px; font-size: 12px; color: var(--gray-600); line-height: 1.65; margin-top: 4px; }
.dp-status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 4px; }
.dp-status-card { background: var(--gray-50); border-radius: var(--radius); padding: 8px 10px; }
.dp-status-lbl { font-size: 10px; color: var(--gray-400); margin-bottom: 3px; }
.dp-status-val { font-size: 11px; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.dp-source-link { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--blue); padding: 5px 0; border-bottom: 1px solid var(--gray-100); text-decoration: none; }
.dp-source-link:hover { text-decoration: underline; }
.dp-source-link:last-child { border-bottom: none; }
.route-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--blue); background: var(--blue-light); padding: 3px 9px; border-radius: 20px; margin: 3px 3px 0 0; }
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); cursor: pointer; }

/* ── TABLE VIEW ──────────────────────────────────────────── */
#view-table { flex-direction: column; background: white; }
.tv-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tv-title { font-size: 15px; font-weight: 600; }
.tv-actions { margin-left: auto; display: flex; gap: 8px; }
.tv-table-wrap { flex: 1; overflow: auto; }
.tv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tv-table th { padding: 9px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--gray-600); border-bottom: 1px solid var(--border); background: var(--gray-50); white-space: nowrap; position: sticky; top: 0; cursor: pointer; user-select: none; }
.tv-table th:hover { background: var(--gray-100); }
.tv-table td { padding: 9px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-900); vertical-align: middle; }
.tv-table tr:hover td { background: var(--gray-50); cursor: pointer; }
.tv-thumb { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; background: var(--gray-100); display: flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 14px; }
.tv-thumb img { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; }

/* ── ROUTE VIEW ──────────────────────────────────────────── */
#view-route { }
.rv-panel { width: 280px; flex-shrink: 0; background: white; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.rv-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.rv-head-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rv-title { font-size: 14px; font-weight: 600; }
.rv-select { width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid var(--gray-200); border-radius: var(--radius); margin-bottom: 8px; outline: none; }
.rv-items { flex: 1; overflow-y: auto; }
.rv-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--gray-100); cursor: pointer; }
.rv-item:hover { background: var(--gray-50); }
.rv-num { width: 25px; height: 25px; border-radius: 50%; background: var(--green); color: white; font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rv-info { flex: 1; }
.rv-name { font-size: 13px; font-weight: 500; }
.rv-loc { font-size: 11px; color: var(--gray-600); }
.rv-dist { font-size: 11px; color: var(--gray-400); white-space: nowrap; }
.rv-footer { padding: 12px 14px; border-top: 1px solid var(--border); }
.rv-total { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 10px; }
.rv-map { flex: 1; }
#route-map { width: 100%; height: 100%; }

/* ── STATUS COLORS ───────────────────────────────────────── */
.dot-neaplankyta  { background: var(--gray-400); }
.dot-rastas       { background: var(--amber); }
.dot-nufoto       { background: var(--green); }
.dot-nerastas     { background: var(--red); }
.dot-reikia       { background: var(--purple); }

.badge-neaplankyta { background: var(--gray-100);   color: var(--gray-600); }
.badge-rastas      { background: var(--amber-light); color: var(--amber); }
.badge-nufoto      { background: var(--green-light); color: var(--green-dark); }
.badge-nerastas    { background: var(--red-light);   color: var(--red); }
.badge-reikia      { background: var(--purple-light);color: var(--purple); }

.mat-nera     { color: var(--gray-400); }
.mat-pirmine  { color: var(--amber); }
.mat-saltiniai{ color: var(--blue); }
.mat-viska    { color: var(--green); }

/* ── STATUS PILL ─────────────────────────────────────────── */
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.modal-overlay.hidden { display: none; }
.modal-box { background: white; border-radius: var(--radius-lg); width: 360px; max-width: 92vw; box-shadow: 0 8px 32px rgba(0,0,0,.2); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--gray-400); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); }
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal-body { padding: 16px; }
.modal-route-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; margin-bottom: 12px; }
.modal-route-btn { text-align: left; justify-content: flex-start; }
.modal-divider { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.modal-inline { display: flex; gap: 6px; margin-top: 6px; }
.modal-inline input { flex: 1; padding: 7px 9px; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 12px; outline: none; }
.modal-inline input:focus { border-color: var(--green); }

/* ── TOAST ───────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1a1a18; color: white; padding: 9px 18px; border-radius: var(--radius); font-size: 13px; z-index: 9999; pointer-events: none; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }

/* ── LIGHTBOX ────────────────────────────────────────────── */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9000; display: none; align-items: center; justify-content: center; }
#lightbox.open { display: flex; }
#lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }
#lightbox-close { position: absolute; top: 20px; right: 24px; color: white; font-size: 28px; cursor: pointer; background: none; border: none; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { padding: 40px 20px; text-align: center; color: var(--gray-400); }
.empty-state i { font-size: 36px; margin-bottom: 10px; display: block; }
.empty-state p { font-size: 13px; }

/* ── LOADING ─────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--gray-400); gap: 10px; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 20px; height: 20px; border: 2px solid var(--gray-200); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 700px)  { #detail-panel { width: 100%; position: fixed; inset: 52px 0 0 0; z-index: 500; } }
