/**
 * Know.Travel — Routes Map KT
 * Theme-aware styles using CSS variables from general.css
 * Layout: FC-style left panel + full-width map
 */

/* Reset: override WP admin-bar margin if present */
html { margin-top: 0 !important; }

/* ============================================================
   BREADCRUMB BAR (above map, consistent with other KT pages)
   ============================================================ */
.rm-breadcrumb-bar {
    padding: 16px 24px 0;
    background: var(--bg-base);
}

/* ============================================================
   WRAPPER — FC-style: left panel + map
   ============================================================ */
.rm-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    width: 100%;
    height: calc(100vh - 100px);
    min-height: 500px;
    background: var(--bg-base);
    overflow: hidden;
}

/* ============================================================
   LEFT PANEL (intro → info + destinations after search)
   ============================================================ */
.rm-panel {
    position: relative;
    z-index: 10;
    width: 320px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border-default);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
.rm-panel::-webkit-scrollbar { width: 4px; }
.rm-panel::-webkit-scrollbar-track { background: transparent; }
.rm-panel::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }

/* Intro (shown before any airport selected) */
.rm-intro {
    padding: 28px 20px 24px;
}
.rm-intro-title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.rm-intro-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 16px;
    line-height: 1.5;
}
.rm-intro-text {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.6;
}

/* Info panel (airport selected) */
.rm-info {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.rm-info-iata {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent-pink);
    letter-spacing: 2px;
    line-height: 1;
    margin-bottom: 4px;
}
.rm-info-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.rm-info-city {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}
.rm-info-stats {
    display: flex;
    gap: 20px;
}
.rm-info-stat-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-blue);
    line-height: 1.1;
}
.rm-info-stat-label {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Header: airport name + back button row */
.rm-info-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.rm-info-text { flex: 1; min-width: 0; }
.rm-info-text .rm-info-city { margin-bottom: 0; }

/* Back-to-hubs button + keyboard hint */
.rm-back-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.rm-btn-back {
    background: transparent;
    border: 1px solid var(--accent-pink);
    color: var(--accent-pink);
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1;
}
.rm-btn-back:hover {
    background: var(--accent-pink-muted, rgba(240,98,146,0.12));
}
.rm-btn-back:active {
    transform: translateY(1px);
}
.rm-hint-esc {
    font-size: 10px;
    color: var(--text-tertiary);
    white-space: nowrap;
    line-height: 1.2;
}
.rm-hint-esc kbd {
    display: inline-block;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 9px;
    font-weight: 600;
    margin-left: 3px;
    line-height: 1.3;
    vertical-align: baseline;
}

/* Hide hint on narrow sidebar (mobile) to save space */
@media (max-width: 480px) {
    .rm-hint-esc { display: none; }
    .rm-btn-back { padding: 5px 8px; font-size: 10px; }
}

/* Destination list */
.rm-dest-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
.rm-dest-list::-webkit-scrollbar { width: 4px; }
.rm-dest-list::-webkit-scrollbar-track { background: transparent; }
.rm-dest-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }

.rm-dest-header {
    padding: 12px 20px 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Sort bar */
.rm-sort-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 20px 8px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 2px;
    position: relative;
}
.rm-sort-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.rm-sort-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}
.rm-sort-chevron {
    font-size: 10px;
    color: var(--text-tertiary);
}
.rm-sort-total {
    color: var(--accent-blue);
    font-size: 11px;
}

/* Sort dropdown */
.rm-sort-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 20px;
    z-index: 1100;
    background: var(--bg-elevated);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    padding: 4px 0;
    min-width: 150px;
    box-shadow: var(--shadow-lg);
}
.rm-sort-dropdown.open { display: block; }

.rm-sort-option {
    padding: 7px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.12s;
}
.rm-sort-option:hover {
    background: var(--accent-blue-muted);
    color: var(--text-primary);
}
.rm-sort-option.active {
    color: var(--accent-blue);
    background: var(--accent-blue-muted);
}

/* Country group */
.rm-country-group.collapsed .rm-dest-item { display: none !important; }

.rm-country-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 20px;
    cursor: pointer;
    transition: background 0.12s;
}
.rm-country-header:hover { background: var(--bg-hover); }

.rm-country-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.rm-country-name img.emoji {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 2px;
}
.rm-country-count {
    font-size: 10px;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 18px;
    text-align: center;
}

/* Destination item */
.rm-dest-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 20px 5px 28px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12px;
}
.rm-dest-item:hover { background: var(--accent-blue-muted); }
.rm-dest-item.highlighted { background: var(--accent-pink-muted, rgba(240,98,146,0.12)); }

.rm-dest-flag {
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}
.rm-dest-flag img.emoji,
.rm-dest-item img.emoji {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}
.rm-dest-iata {
    font-weight: 700;
    font-size: 11px;
    color: var(--text-tertiary);
    width: 30px;
    flex-shrink: 0;
    font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}
.rm-dest-city {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rm-dest-time {
    color: var(--text-tertiary);
    font-size: 11px;
    flex-shrink: 0;
}

/* ============================================================
   MAP AREA
   ============================================================ */
.rm-map {
    flex: 1;
    position: relative;
    z-index: 1;
    background: var(--bg-base);
}
/* Fix WordPress img { max-width:100% } breaking Leaflet tiles */
.rm-map img { max-width: none !important; }
.leaflet-tile-pane { will-change: transform; }
.leaflet-tile { outline: 1px solid transparent; }

/* ============================================================
   HEADER SEARCH (fixed in header bar, same as visa-check/airports)
   ============================================================ */
.rm-header-search {
    position: fixed; top: 0; left: 0; right: 0; height: 64px;
    z-index: 1101; pointer-events: none;
    opacity: 0; transition: opacity 0.25s ease;
}
.rm-header-search.visible { opacity: 1; }
.rm-header-search.visible .rm-hs-field { pointer-events: auto; }
.rm-hs-inner {
    max-width: 1200px; margin: 0 auto; height: 64px;
    display: flex; align-items: center;
    padding: 0 320px 0 220px;
}
.rm-hs-field {
    width: 100%; max-width: 460px; margin: 0 auto;
    display: flex; align-items: center;
    border: 1px solid var(--border-default); border-radius: 12px;
    background: var(--bg-card); backdrop-filter: blur(12px);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.rm-hs-field:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-muted);
}
.rm-hs-field svg {
    width: 16px; height: 16px; margin-left: 14px;
    color: var(--text-tertiary); flex-shrink: 0;
}
.rm-hs-field input {
    flex: 1; padding: 10px 8px; border: none; outline: none;
    font-family: 'Outfit', sans-serif; font-size: 14px;
    background: transparent; color: var(--text-primary);
    text-transform: uppercase; letter-spacing: 0.5px;
}
.rm-hs-field input::placeholder { color: var(--text-tertiary); text-transform: none; letter-spacing: 0; }
.rm-hs-btn {
    padding: 7px 16px; margin: 4px 4px 4px 0;
    border: none; border-radius: 8px;
    background: var(--accent-blue); color: #fff;
    font-family: 'Outfit', sans-serif; font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap; transition: filter 0.15s;
}
[data-theme="dark"] .rm-hs-btn { color: #0e0e18; }
[data-theme="sunset"] .rm-hs-btn { color: #1a1410; }
.rm-hs-btn:hover { filter: brightness(1.1); }

/* ============================================================
   SEARCH BAR (overlay on top-center of map)
   ============================================================ */
.rm-search {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-md);
}
.rm-search svg {
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    margin-left: 6px;
}
.rm-search input {
    width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.rm-search input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-muted);
}
.rm-search input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0;
}
.rm-search-btn {
    padding: 8px 16px;
    background: var(--accent-blue);
    color: var(--text-on-accent);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.rm-search-btn:hover { opacity: 0.85; }

/* Dark theme: button text contrast */
[data-theme="dark"] .rm-search-btn { color: #0e0e18; }
[data-theme="sunset"] .rm-search-btn { color: #1a1410; }

.rm-reset-btn {
    padding: 8px 12px;
    background: var(--bg-elevated);
    color: var(--text-tertiary);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}
.rm-reset-btn:hover { color: var(--text-primary); }

/* ============================================================
   PULSING ORIGIN MARKER
   ============================================================ */
.rm-origin-pulse {
    background: none !important;
    border: none !important;
}
.rm-origin-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-pink);
    border: 2px solid rgba(255,255,255,0.4);
    z-index: 10;
    cursor: pointer;
}
.rm-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid var(--accent-pink);
    opacity: 0.6;
    animation: rm-pulse-expand 3s ease-out infinite;
}
.rm-pulse-ring-1 { animation-delay: 0s; }
.rm-pulse-ring-2 { animation-delay: 1.5s; }

@keyframes rm-pulse-expand {
    0%   { width: 16px; height: 16px; opacity: 0.7; }
    100% { width: 70px; height: 70px; opacity: 0; }
}

/* Plane icon */
.rm-plane-icon {
    background: none !important;
    border: none !important;
}
.rm-plane-symbol {
    font-size: 20px;
    color: #ffffff;
    text-shadow: 0 0 6px rgba(0,0,0,0.8);
    line-height: 1;
    filter: drop-shadow(0 0 2px rgba(0,0,0,1)) drop-shadow(0 1px 4px rgba(0,0,0,0.9));
    transform-origin: center center;
    display: block;
}

/* ============================================================
   LEGEND
   ============================================================ */
.rm-legend {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 900;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
}
.rm-legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.rm-legend-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}
.rm-legend-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 16px;
    cursor: pointer;
    padding: 0 0 0 12px;
    line-height: 1;
    transition: color 0.15s;
}
.rm-legend-close:hover { color: var(--text-primary); }

.rm-legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 2px 0;
}
.rm-legend-dot {
    display: inline-block;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ============================================================
   LOADER / ERROR
   ============================================================ */
.rm-loader {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    padding: 20px 32px;
    border-radius: 12px;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: 14px;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
}
.rm-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: rm-spin 0.8s linear infinite;
}
@keyframes rm-spin { to { transform: rotate(360deg); } }

.rm-error {
    display: none;
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background: var(--status-error);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: var(--shadow-md);
}

/* ============================================================
   LEAFLET OVERRIDES (theme-aware)
   ============================================================ */
.rm-wrapper .leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-default) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-lg) !important;
    color: var(--text-primary) !important;
}
.rm-wrapper .leaflet-popup-tip {
    background: var(--bg-card) !important;
}
.rm-wrapper .leaflet-popup-close-button { color: var(--text-tertiary) !important; }
.rm-wrapper .leaflet-popup-close-button:hover { color: var(--text-primary) !important; }

.rm-wrapper .leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-default) !important;
}
.rm-wrapper .leaflet-control-zoom a:hover {
    background: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
}

.rm-wrapper .leaflet-control-attribution {
    background: transparent !important;
    color: rgba(255,255,255,0.15) !important;
    font-size: 9px !important;
    line-height: 1 !important;
    padding: 1px 4px !important;
}
.rm-wrapper .leaflet-control-attribution a {
    color: rgba(255,255,255,0.2) !important;
    text-decoration: none !important;
}
[data-theme="light"] .rm-wrapper .leaflet-control-attribution { color: rgba(0,0,0,0.12) !important; }
[data-theme="light"] .rm-wrapper .leaflet-control-attribution a { color: rgba(0,0,0,0.15) !important; }

/* Hub tooltip */
.rm-hub-tooltip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: 6px !important;
    color: var(--text-primary) !important;
    font-size: 12px !important;
    padding: 6px 10px !important;
    box-shadow: var(--shadow-md) !important;
}
.rm-hub-tooltip::before {
    border-top-color: var(--bg-card) !important;
}

/* Map overlay search — desktop hidden (search is in header), mobile only */
@media (min-width: 769px) {
    .rm-search { display: none; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .rm-hs-inner { padding-left: 200px; padding-right: 200px; }
}
/* Map overlay: desktop hidden (header search handles it), mobile only */
@media (min-width: 769px) {
    .rm-search { display: none; }
}

@media (max-width: 768px) {
    .rm-header-search { display: none; }
    .rm-breadcrumb-bar { padding: 12px 16px 0; }

    .rm-wrapper {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .rm-panel {
        width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-default);
        order: 2;
    }

    /* When airport selected, panel becomes scrollable bottom sheet */
    .rm-panel.has-airport {
        max-height: 75vh;
        order: 2;
    }

    .rm-map {
        height: 55vh;
        min-height: 300px;
        order: 1;
    }

    .rm-search {
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 24px);
        max-width: 400px;
    }
    .rm-search input {
        flex: 1;
        width: auto;
        min-width: 0;
        font-size: 13px;
    }

    .rm-intro { padding: 20px 16px 16px; }
    .rm-intro-title { font-size: 20px; }

    .rm-legend {
        bottom: 8px;
        right: 8px;
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .rm-search-btn { display: none; }
    .rm-info-iata { font-size: 22px; }
    .rm-info-stat-value { font-size: 18px; }
}
/* ── Autocomplete dropdown (moved from inline <style> in page-routes-kt.php) ── */
@media (max-width: 1023px) { .rm-search { display: none !important; } }

.rm-ac-dropdown {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 99999;
  max-height: 280px;
  overflow-y: auto;
}
.rm-ac-dropdown.open { display: block; }

.rm-ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.1s;
}
.rm-ac-item:hover { background: var(--bg-hover); }

.rm-ac-iata {
  font-weight: 700;
  color: var(--accent-blue);
  min-width: 36px;
  font-size: 12px;
}
.rm-ac-name { flex: 1; }
.rm-ac-city { color: var(--text-tertiary); font-size: 12px; }