/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w:  260px;
    --bg-sidebar: #1a2637;
    --bg-content: #f4f6f9;
    --accent:     #2e7ddc;
    --accent-dark:#1a5baa;
    --text-light: #e8edf4;
    --text-muted: #8fa0b5;
    --border:     #d0d8e4;
    --card-bg:    #ffffff;
    --shadow:     0 2px 8px rgba(0,0,0,.10);
    --radius:     8px;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 14px; color: #2c3e50; background: var(--bg-content); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
/* A teljes app a viewport magasságát tölti ki; a tartalom belül görget */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Sticky fejléc ────────────────────────────────────────────────────────── */
#top-header {
    display: flex;
    align-items: stretch;      /* logó és kereső-sáv egyenlő magas */
    flex-shrink: 0;
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 200;
    border-bottom: 1px solid rgba(255,255,255,.10);
}

#logo {
    width: var(--sidebar-w);
    flex-shrink: 0;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-right: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
}
#logo img { width: auto; height: 26px; object-fit: contain; border-radius: 5px; }
#logo-text { font-size: 24px; font-weight: 700; letter-spacing: .04em; color: #fff; }

/* ── Fő sor (sidebar + tartalom) ─────────────────────────────────────────── */
#main-row {
    display: flex;
    flex: 1;
    min-height: 0;   /* nélküle a flex gyerekek nem scrollolnak */
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;  /* belső #nav scrollol */
}

/* Sidebar nav – gördíthető terület */
#nav {
    flex: 1;
    padding: 10px 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Szekció felirat */
.sidebar-section-label {
    font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
    color: var(--text-muted); padding: 10px 6px 3px; opacity: .7; flex-shrink: 0;
}

/* Sidebar keresődoboz */
.sidebar-search-wrap { position: relative; margin-bottom: 3px; }
.sidebar-search-wrap input {
    width: 100%; padding: 6px 10px 6px 26px;
    border: 1.5px solid rgba(255,255,255,.12); border-radius: 14px;
    font-size: 12px; background: rgba(255,255,255,.07); color: var(--text-light);
    outline: none; transition: border-color .15s, background .15s;
}
.sidebar-search-wrap input:focus { border-color: var(--accent); background: rgba(255,255,255,.12); }
.sidebar-search-wrap input::placeholder { color: var(--text-muted); }
.sidebar-search-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }

/* Keresési találatok a sávban */
#var-sidebar-results {
    max-height: 200px; overflow-y: auto;
    background: rgba(255,255,255,.05); border-radius: 6px; margin-top: 2px;
}
.sidebar-result-item {
    padding: 5px 9px; font-size: 11.5px; color: var(--text-light);
    cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.04);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: background .1s;
}
.sidebar-result-item:last-child { border-bottom: none; }
.sidebar-result-item:hover { background: rgba(255,255,255,.10); }
.sidebar-result-item.empty { color: var(--text-muted); cursor: default; }

/* Változófa section a sávban */
#vtree-sidebar-section {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    margin-top: 2px;
    /* Scrollbar stílus */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}

/* ── Variable tree ────────────────────────────────────────────────────────── */
#vartree-container { padding: 2px 0; }

.vtree-status { color: var(--text-muted); font-size: 11.5px; padding: 6px 4px; }

.vtree-ul {
    list-style: none; margin: 0; padding-left: 10px; white-space: nowrap;
}
.vtree-ul:first-child { padding-left: 0; }
.vtree-li { margin: 0; }

.vtree-row {
    display: flex; align-items: baseline; gap: 3px;
    padding: 1px 4px; border-radius: 4px; cursor: default;
    transition: background .1s;
}
.vtree-row:hover { background: rgba(255,255,255,.08); }

/* Kijelölt vtree sor */
.vtree-row.vtree-selected { background: rgba(255,210,0,.18); }
.vtree-row.vtree-selected .vtree-label { color: #ffe066; }
.vtree-row.vtree-selected .vtree-code  { color: #ffd000; }

.vtree-toggle {
    font-size: 8px; width: 10px; flex-shrink: 0;
    cursor: pointer; color: var(--text-muted); user-select: none;
}
.vtree-label { font-size: 11.5px; color: #c8d8ec; line-height: 1.3; }
.vtree-leaf  { color: #6db3f2; cursor: pointer; font-weight: 500; }
.vtree-leaf:hover { text-decoration: underline; color: #8ec8ff; }
.vtree-code  { font-family: 'Courier New', monospace; font-size: 10.5px; font-weight: 700; color: #a0b8d0; letter-spacing: .03em; }
.vtree-leaf .vtree-code { color: #5da0e8; }
.vtree-cid   { font-size: 9px; color: rgba(255,255,255,.2); margin-left: 1px; }

/* ── Content area ─────────────────────────────────────────────────────────── */
#content { flex: 1; padding: 20px 15px; overflow-y: auto; min-width: 0; }

/* ── Helykereső sáv – a sticky fejlécen belül, a logó mellett ────────────── */
#sett-top-row {
    flex: 1;
    display: flex; align-items: center; gap: 14px;
    flex-wrap: wrap;
    padding: 10px 20px;
}
/* Dátumválasztó a sávban jobbra tolva */
#sub-date {
    margin-left: auto;
    font-size: 11px; padding: 3px 5px;
    border: 1px solid rgba(255,255,255,.18); border-radius: 4px;
    background: rgba(255,255,255,.07); color: var(--text-light);
    cursor: pointer; color-scheme: dark;
}
#sub-date::-webkit-datetime-edit              { padding: 0; }
#sub-date::-webkit-datetime-edit-fields-wrapper { padding: 0; }
#sub-date::-webkit-datetime-edit-year-field,
#sub-date::-webkit-datetime-edit-month-field,
#sub-date::-webkit-datetime-edit-day-field    { padding: 0; }
#sub-date::-webkit-datetime-edit-text         { padding: 0; }
#sub-date::-webkit-calendar-picker-indicator  { padding: 0; margin-left: 2px; }
#sub-date:focus { outline: none; border-color: var(--accent); }

.search-wrap-small { position: relative; flex-shrink: 0; }
.search-wrap-small input {
    width: 220px; padding: 6px 10px 6px 26px;
    border: 1.5px solid rgba(255,255,255,.12); border-radius: 14px;
    font-size: 12px; background: rgba(255,255,255,.07);
    color: var(--text-light); outline: none;
    transition: border-color .15s, background .15s;
}
.search-wrap-small input:focus { border-color: var(--accent); background: rgba(255,255,255,.12); }
.search-wrap-small input::placeholder { color: var(--text-muted); font-size: 12px; }
.search-icon-small { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }

/* Dropdown – sötét témájú, a sidebar-sávba illik */
.dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #1e2e44; border: 1.5px solid rgba(255,255,255,.15);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,.4); z-index: 100;
    max-height: 280px; overflow-y: auto;
}
.dropdown-item {
    padding: 7px 13px; cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: 12.5px; color: var(--text-light); transition: background .1s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: rgba(255,255,255,.10); }
.sett-dd-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dd-etype-badge {
    font-size: 10px; font-weight: 600; letter-spacing: .04em;
    color: #8fa0b5; background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 4px; padding: 1px 6px; white-space: nowrap; flex-shrink: 0;
}
.dropdown-item.empty { color: var(--text-muted); cursor: default; }

/* Magyarország + hierarchia közös flex-sor, nulla gap → egyenletes spacing */
#sett-hier-row { display: flex; align-items: center; flex-wrap: wrap; }

/* Hierarchia – sötét sávon fehéres szöveg */
#sett-hierarchy {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0;
    font-size: 12.5px; color: var(--text-muted);
}
.hier-sep { margin: 0 6px; color: rgba(255,255,255,.45); user-select: none; }
.hier-item { padding: 1px 0; white-space: nowrap; }
.hier-link { color: #6db3f2; cursor: pointer; font-weight: 500; }
.hier-link:hover { text-decoration: underline; color: #8ec8ff; }
.hier-current { color: var(--text-light); font-weight: 700; }

/* Magyarország gomb a sávon */
#btn-magyarorszag.hier-link  { color: #6db3f2; }
#btn-magyarorszag.hier-link:hover { color: #8ec8ff; text-decoration: underline; }
#btn-magyarorszag.hier-current { color: var(--text-light); font-weight: 700; cursor: default; }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 14px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; color: #1a2637; }

/* ── Névjegy kártya ───────────────────────────────────────────────────────── */
.nevjegy-card { padding: 16px 20px; }
#nevjegy-inner { display: flex; align-items: flex-start; gap: 16px; }
#nevjegy-cimer { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.nevjegy-cimer-img { height: 120px; width: auto; max-width: 200px; object-fit: contain; display: block; }
.cimer-nav { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 11px; color: #555; }
.cimer-nav-btn { cursor: pointer; font-size: 15px; line-height: 1; padding: 0 3px; color: #2e7ddc; user-select: none; }
.cimer-nav-btn:hover { color: #1a4a8a; }
.cimer-nav-btn.disabled { color: #ccc; cursor: default; pointer-events: none; }
.cimer-nav-info { color: #888; font-size: 10px; white-space: nowrap; }
#nevjegy-text { flex: 1; min-width: 0; }
#nevjegy-name { font-size: 21px; font-weight: 700; color: #1a2637; margin-bottom: 5px; line-height: 1.2; }
#nevjegy-type { font-size: 13px; color: #555; margin-bottom: 3px; }
#nevjegy-since { font-size: 12px; color: var(--text-muted); }
/* OSMNX képek a jobb oldalon */
#nevjegy-osmnx { flex-shrink: 0; display: flex; gap: 8px; align-items: flex-start; }

/* Névváltozatok lista */
#nevjegy-names {
    margin-top: 5px;
    max-height: 72px;   /* ~3 sor */
    overflow-y: auto;
    scrollbar-width: thin;
}
#nevjegy-names::-webkit-scrollbar { width: 4px; }
#nevjegy-names::-webkit-scrollbar-thumb { background: #ccd; border-radius: 2px; }
.nevjegy-names-list {
    list-style: none;
    display: flex; flex-wrap: wrap; gap: 2px 14px;
    margin: 0; padding: 0;
}
.nevjegy-names-list li {
    font-size: 12px; color: #555;
    white-space: nowrap;
}

/* Külső linkek a névjegy alatt */
#nevjegy-links { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
#nevjegy-links:empty { display: none; }
.nevjegy-links-title { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 5px; }
.nevjegy-link-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.nevjegy-link-list li { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.nevjegy-link-list a { color: var(--accent); text-decoration: none; display: flex; align-items: center; gap: 5px; }
.nevjegy-link-list a:hover { text-decoration: underline; }
.nevjegy-link-icon { width: 16px; height: 16px; object-fit: contain; flex-shrink: 0; }
/* ── Alárendelt egységek – a névjegy-inner flex-ben ──────────────────────── */
/* A #subordinates-content a #nevjegy-inner flex-sorában van,
   a cimer + szöveg mellett, elválasztóval */
#subordinates-content {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start;
    flex: 2; min-width: 200px;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}
#subordinates-content:empty { display: none; border-left: none; padding-left: 0; }
.sub-box { flex: 1 1 140px; min-width: 120px; }
.sub-box-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-muted);
    margin-bottom: 5px; padding-bottom: 3px;
    border-bottom: 1px solid var(--border);
}
.sub-list { list-style: none; max-height: 120px; overflow-y: auto;
            scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.sub-list li { padding: 1px 0; }
.sub-list a { font-size: 12px; color: var(--accent); text-decoration: none; }
.sub-list a:hover { text-decoration: underline; }

.osmnx-img {
    height: 80px; width: auto; object-fit: contain;
    border-radius: 5px; border: 1px solid var(--border);
    cursor: pointer; transition: opacity .15s;
}
.osmnx-img:hover { opacity: .8; }

/* Hierarchia */
.meta-row { display: flex; gap: 8px; align-items: baseline; margin-bottom: 5px; font-size: 13px; }
.meta-label { color: var(--text-muted); min-width: 100px; flex-shrink: 0; }
.meta-value { color: #2c3e50; font-weight: 500; }

/* ── Idővonal-csúszka ─────────────────────────────────────────────────────── */
.timeline-outer {
    display: flex; flex-direction: column; gap: 0; padding: 4px 0 2px;
}

/* Pálya + rovátkák + csúszka + évtized-feliratok */
.timeline-track-outer {
    position: relative;
    /* slider 22px + rovátka 6px + felirat 13px + rés 2px = ~46px */
    height: 46px;
    display: flex; align-items: flex-start; padding-top: 0;
}

/* Range input – a tetején */
#timeline-slider {
    width: 100%; position: relative; z-index: 2;
    -webkit-appearance: none; appearance: none;
    height: 4px; background: var(--border); border-radius: 2px; outline: none;
    cursor: pointer;
    margin-top: 9px;   /* thumb fele (11px) - pálya fele (2px) = vizuálisan középre */
}
#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 40px; height: 22px;
    background: var(--accent); border-radius: 11px;
    cursor: grab; border: none;
    box-shadow: 0 1px 5px rgba(0,0,0,.25);
}
#timeline-slider::-moz-range-thumb {
    width: 40px; height: 22px;
    background: var(--accent); border-radius: 11px;
    cursor: grab; border: none;
}

/* Év a csúszka közepén – vertikálisan és horizontálisan a thumb-ba igazítva.
   A thumb (22px) a track közepén ül: track margin-top=9, height=4 → center=11px.
   Thumb top = 11-11 = 0px a containertől. */
.timeline-thumb-label {
    position: absolute; z-index: 3;
    transform: translateX(-50%);
    font-size: 11px; font-weight: 700; color: #fff;
    pointer-events: none;
    width: 40px; height: 22px;
    top: 0;
    display: flex; align-items: center; justify-content: center;
}

/* Adatév-rovátkák – a slider alatt.
   left/right = thumb félszélesség (20px), hogy a % pozíció egyezzen a thumbéval. */
.timeline-ticks {
    position: absolute;
    top: 23px;   /* volt 33px → -10px közelebb a csúszkához */
    left: 20px; right: 20px; height: 6px;
}
.timeline-tick {
    position: absolute; top: 0;
    width: 2px; height: 6px;
    background: var(--accent); border-radius: 1px;
    transform: translateX(-50%);
    opacity: .65;
}

/* Évtized-feliratok – a rovátkák alatt, szintén 20px behúzással. */
.timeline-labels {
    position: absolute;
    top: 30px;   /* volt 40px → ticks(23)+6+1 */
    left: 20px; right: 20px; height: 13px;
}
.timeline-label {
    position: absolute;
    transform: translateX(-50%);
    font-size: 10px; color: var(--text-muted); font-weight: 600;
    white-space: nowrap; line-height: 1; top: 0;
}

/* ── Térkép-kártya fejléc (fülgombok + változónév) ───────────────────────── */
.map-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.tab-var-label {
    flex: 1; font-size: 13px; font-weight: 600; color: #1a2637;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0;
}

/* ── Tab-sáv ──────────────────────────────────────────────────────────────── */
.tab-bar {
    display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.tab-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 5px 14px; border: 1.5px solid var(--border);
    border-radius: 16px; background: #fff; cursor: pointer;
    font-size: 12.5px; color: #555; font-weight: 500;
    transition: border-color .15s, color .15s, background .15s;
}
.tab-btn:hover { border-color: var(--accent); color: var(--accent); }
.tab-btn.active {
    background: var(--accent); border-color: var(--accent);
    color: #fff; font-weight: 600;
}
.tab-btn.active svg { stroke: #fff; }
.tab-panel { }

/* ── Idővonal a térkép-fülön belül ───────────────────────────────────────── */
#map-slider-wrap {
    margin-bottom: 10px;
}

/* ── Chart wrap ───────────────────────────────────────────────────────────── */
#chart-wrap { height: 360px; position: relative; }

/* ── Úthálózat panel ──────────────────────────────────────────────────────── */
.network-images {
    display: flex; gap: 16px; flex-wrap: wrap;
    padding: 8px 0; justify-content: center;
}
.network-img-wrap {
    flex: 0 1 auto;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.network-img-wrap span {
    font-size: 11.5px; color: var(--text-muted); font-weight: 600;
}
.network-img-wrap img {
    max-height: 300px; height: 300px; width: auto;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--border); display: block;
}

/* ── Főtérkép ─────────────────────────────────────────────────────────────── */
#main-map {
    width: 100%; height: 560px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
#footer {
    background: #fff; border-top: 1px solid var(--border);
    padding: 9px 24px; display: flex; align-items: center;
    justify-content: flex-end; gap: 10px;
}
.lang-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 4px 11px; border: 1.5px solid var(--border);
    border-radius: 14px; background: #fff; cursor: pointer;
    font-size: 12.5px; color: #555; transition: border-color .15s, color .15s;
}
.lang-btn:hover, .lang-btn.active { border-color: var(--accent); color: var(--accent); }
.lang-btn img { width: 18px; height: 13px; object-fit: cover; border-radius: 2px; }

/* ── Leaflet tooltip ──────────────────────────────────────────────────────── */
.leaflet-tooltip { font-size: 12px; padding: 4px 8px; }

/* ── Térkép overlay panel (rétegkapcsolók) ───────────────────────────────── */
.leaflet-bottom.leaflet-left { margin-left: 0 !important; margin-bottom: 0 !important; }
.leaflet-bottom.leaflet-left .leaflet-control { margin-left: 0 !important; margin-bottom: 0 !important; }
.overlay-panel {
    background: rgba(255,255,255,0.88);
    padding: 0 5px;
    margin: 0;
    font-size: 11px;
    line-height: 1;
    height: 16px;
    display: flex;
    align-items: center;
    gap: 0;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.overlay-toggle {
    cursor: pointer;
    color: #555;
    user-select: none;
    padding-right: 5px;
    font-size: 11px;
}
.overlay-toggle:hover { color: #000; }
.overlay-links { display: none; }
.overlay-links.open { display: inline; }
.overlay-link {
    color: #444;
    text-decoration: none;
    padding: 2px 5px;
    margin: 0 1px;
    border-radius: 2px;
    font-size: 11px;
    cursor: pointer;
}
.overlay-link:hover { background: #ddd; color: #000; }
.overlay-link.ov-active { background: #3a5a8a; color: #fff; }
.overlay-link.ov-disabled { color: #bbb; cursor: default; pointer-events: none; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
/* Leaflet tooltip a settlement rétegeken */
.map-tooltip {
    background: rgba(26,38,55,.88); border: 1px solid rgba(255,255,255,.18);
    color: #e8edf4; font-size: 11px; padding: 2px 7px; border-radius: 4px;
    white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.map-tooltip::before { display: none; }

@media (max-width: 640px) {
    #sidebar { width: 52px; }
    #logo { width: 52px; padding: 5px 8px; }
    #logo-text, .sidebar-section-label, .sidebar-search-wrap, #vtree-sidebar-section { display: none; }
    #content { padding: 12px; }
}
