:root {
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
}

/* Tlačítka používají přímo MapLibre .maplibregl-ctrl-group styl */

/* ========== Sdílený popup overlay ========== */

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-panel {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 520px;
    max-height: 80vh;
    width: 90vw;
    display: flex;
    flex-direction: column;
    font-family: var(--font-ui);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 15px;
    font-weight: 700;
}

.popup-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #888;
    line-height: 1;
    padding: 0 4px;
}

.popup-close:hover {
    color: #333;
}

.popup-body {
    padding: 12px 16px;
    overflow-y: auto;
}

/* ========== Wiki hover preview ========== */

.wiki-preview {
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.45;
    color: #222;
    max-width: 260px;
}

.wiki-preview-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: #1a1a1a;
}

.wiki-preview-body {
    color: #444;
}

.wiki-preview-thumb {
    float: right;
    width: 80px;
    max-height: 80px;
    object-fit: cover;
    border-radius: 4px;
    margin: 0 0 6px 8px;
}

/* ========== Popup legendy ========== */

.legend-toolbar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 8px;
}

.legend-section {
    margin-bottom: 12px;
}

.legend-section:last-child {
    margin-bottom: 0;
}

.legend-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 4px;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 4px;
    border-radius: 4px;
    user-select: none;
}

.legend-section-title:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #333;
}

.legend-toggle-all {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.legend-toggle-all:hover {
    background: #e0e0e0;
}

.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px;
    font-size: 13px;
    border-radius: 4px;
    transition: opacity 0.15s;
    user-select: none;
}

.legend-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Skrytá vrstva – ztlumená */
.legend-item-off {
    opacity: 0.35;
}

.legend-icon-wrap {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* ========== Popup zastávek (výběr linky) ========== */

.route-popup-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
}

.route-popup-line {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
}

.route-popup-line:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Reset tlačítko (plovoucí, po aktivaci filtru linky) */
#route-reset-btn {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-ui);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#route-reset-btn:hover {
    background: #f0f0f0;
}

.route-popup-ref {
    font-weight: 700;
    min-width: 28px;
    text-align: center;
    background: #e8e8e8;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 12px;
}

/* ========== Vyhledávání ========== */

.search-ctrl {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
    font-family: var(--font-ui);
    overflow: visible !important;
}

.search-input {
    width: 240px;
    height: 29px;
    border: none;
    padding: 0 10px;
    font-size: 14px;
    font-family: inherit;
    color: #222;
    outline: none;
    background: transparent;
    box-sizing: border-box;
}

.search-results {
    display: none;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    margin-top: 4px;
    max-height: 60vh;
    overflow-y: auto;
}

.search-result {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover {
    background: rgba(0, 0, 0, 0.05);
}

.search-result-name {
    font-size: 13px;
    font-weight: 600;
    color: #222;
}

.search-result-meta {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.search-result-empty,
.search-result-error {
    color: #888;
    font-style: italic;
    cursor: default;
}

.search-result-error {
    color: #c00;
}

/* ========== Routing panel ========== */

.routing-ctrl { overflow: visible !important; }

.rp-wrap {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
    font-family: var(--font-ui);
}

.rp-wrap .rp-title { display: none; }
.rp-wrap .rp-body  { display: none; }

.rp-wrap .rp-header {
    display: flex;
    align-items: center;
}

.rp-wrap .rp-toggle {
    width: 29px;
    height: 29px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #333;
    padding: 0;
}

.routing-ctrl.rp-open .rp-wrap {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 260px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
}

.routing-ctrl.rp-open .rp-header {
    gap: 6px;
    padding: 10px 14px 10px 10px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 15px;
    font-weight: 700;
}

.routing-ctrl.rp-open .rp-toggle {
    width: 26px;
    height: 26px;
    font-size: 16px;
    color: #555;
    border-radius: 4px;
}
.routing-ctrl.rp-open .rp-toggle:hover { background: rgba(0,0,0,0.06); }

.routing-ctrl.rp-open .rp-title { display: block; }
.routing-ctrl.rp-open .rp-body  { display: block; }

.rp-body { padding: 12px 16px 14px; font-size: 13px; }

.rp-profiles { display: flex; gap: 4px; margin-bottom: 12px; }
.rp-profile-btn {
    flex: 1;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 0;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.rp-profile-btn:hover        { background: #e0e0e0; }
.rp-profile-btn.active       { background: #e91e63; color: #fff; border-color: #e91e63; }
.rp-profile-btn.active:hover { background: #c2185b; }

.rp-wp-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    margin-bottom: 8px;
    box-sizing: border-box;
    font-family: inherit;
    background: #f0f0f0;
    border: 1px solid #ccc;
    transition: background 0.15s;
}
.rp-wp-btn:hover  { background: #e0e0e0; }
.rp-wp-btn.active { background: #fce4ec; border-color: #e91e63; color: #e91e63; font-weight: 600; }

.rp-info { font-size: 13px; line-height: 1.7; margin-bottom: 8px; }
.rp-info strong { color: #e91e63; }

.rp-error {
    font-size: 12px;
    color: #c00;
    background: #fff3f3;
    border: 1px solid #f5c0c0;
    border-radius: 4px;
    padding: 6px 8px;
    margin-bottom: 8px;
}
.rp-loading { font-size: 12px; color: #666; font-style: italic; margin-bottom: 8px; }

.rp-elevation { margin: 0 0 10px; }
.rp-elevation-title {
    font-size: 11px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.rp-elevation svg { display: block; width: 100%; border-radius: 3px; cursor: crosshair; }
.rp-elevation-stats {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    margin-top: 3px;
}

#routing-cursor-hint {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-family: var(--font-ui);
    pointer-events: none;
    z-index: 200;
    display: none;
    white-space: nowrap;
}
