/* ------------------------------------------------------------------ */
/* Nomad Path UI — .np-* namespace                                     */
/* ------------------------------------------------------------------ */

/* Panel container — positioned over the map */
.np-panel {
    position: absolute;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    font-family:
        system-ui,
        -apple-system,
        sans-serif;
    font-size: 13px;
    color: #222;
    max-width: 280px;
    min-width: 180px;
    overflow: hidden;
    pointer-events: auto;
}

/* Panel positions */
.np-panel--topleft {
    top: 10px;
    left: 10px;
}
.np-panel--topright {
    top: 10px;
    right: 10px;
}

/* TrackLegend sits below the basemap selector at top-right */
.np-track-legend {
    top: 46px;
}
.np-panel--bottomleft {
    bottom: 30px;
    left: 10px;
}
.np-panel--bottomright {
    bottom: 30px;
    right: 10px;
}

/* Panel header — clickable toggle */
.np-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #555;
    border-bottom: 1px solid #e0e0e0;
}

.np-panel__header:hover {
    background: #f5f5f5;
}

/* Shared collapse toggle arrow — used in panels, day headers, and category headers */
.np-toggle {
    font-size: 10px;
    transition: transform 0.2s;
}

.np-panel--collapsed .np-toggle,
.np-day-header--collapsed .np-toggle,
.np-category-header--collapsed .np-toggle {
    transform: rotate(-90deg);
}

/* Panel body — scrollable content */
.np-panel__body {
    max-height: 300px;
    overflow-y: auto;
    padding: 6px 0;
    transition: max-height 0.2s ease;
}

.np-panel--collapsed .np-panel__body {
    max-height: 0;
    padding: 0;
    overflow: hidden;
}

/* Track row */
.np-track-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    cursor: default;
}

.np-track-row:hover {
    background: #f0f0f0;
}

.np-track-row__swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.np-track-row__checkbox {
    margin: 0;
    cursor: pointer;
}

.np-track-row__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.np-track-row__mode {
    font-size: 11px;
    opacity: 0.6;
    flex-shrink: 0;
}

.np-track-row__action {
    cursor: pointer;
    opacity: 0.5;
    font-size: 13px;
    flex-shrink: 0;
    padding: 0 2px;
    background: none;
    border: none;
    color: inherit;
}

.np-track-row__action:hover {
    opacity: 1;
}

.np-track-row__action:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* Day group header */
.np-day-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 3px;
    font-weight: 600;
    font-size: 11px;
    color: #666;
    cursor: pointer;
    user-select: none;
}

.np-day-header:hover {
    background: #f5f5f5;
}

.np-day-group--collapsed .np-track-row {
    display: none;
}

/* Category header (POI legend) */
.np-category-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 3px;
    font-weight: 600;
    font-size: 11px;
    color: #666;
    cursor: pointer;
    user-select: none;
}

.np-category-header:hover {
    background: #f5f5f5;
}

.np-category-group--collapsed .np-track-row {
    display: none;
}

/* Colour scale (attribute legend) */
.np-colour-bar {
    margin: 6px 10px;
    border-radius: 3px;
    overflow: hidden;
}

.np-colour-bar canvas {
    display: block;
    width: 100%;
    height: 14px;
    border-radius: 3px;
}

.np-range-label {
    padding: 2px 10px 6px;
    font-size: 11px;
    color: #888;
}

.np-attr-select {
    width: calc(100% - 20px);
    margin: 6px 10px;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
}

/* Transport mode swatches (attribute legend, categorical) */
.np-mode-list {
    padding: 4px 10px 6px;
}

.np-mode-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 12px;
}

/* POI swatch */
.np-poi-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4081;
    flex-shrink: 0;
}

/* Map controls overlay — full-size, non-blocking container for fit button and basemap selector */
.np-map-controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* Fit-to-visible button — top-left, near where zoom controls live */
.np-fit-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    pointer-events: auto;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    font-size: 16px;
    cursor: pointer;
    color: #333;
    line-height: 1;
}

.np-fit-btn:hover {
    background: #f5f5f5;
}

/* Basemap selector — top-right, sits above the track legend panel */
.np-basemap-select {
    position: absolute;
    top: 10px;
    right: 10px;
    pointer-events: auto;
    height: 30px;
    padding: 0 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    font-size: 12px;
    color: #333;
    cursor: pointer;
}

/* Mobile hamburger */
.np-mobile-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    font-size: 18px;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
    display: none;
    color: #333;
}

.np-mobile-btn:hover {
    background: #f5f5f5;
}

/* Mobile drawer */
.np-mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.4);
}

.np-mobile-backdrop--open {
    display: block;
}

.np-mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    z-index: 31;
    background: #fff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding: 10px 0;
}

.np-mobile-drawer--open {
    transform: translateX(0);
}

/* In mobile drawer, panels become static blocks */
.np-mobile-drawer .np-panel {
    position: static;
    max-width: none;
    box-shadow: none;
    border-radius: 0;
    border-bottom: 1px solid #e0e0e0;
}

/* Responsive: show hamburger, hide desktop panels on narrow screens */
@media (max-width: 768px) {
    .np-mobile-btn {
        display: block;
    }

    .np-panel:not(.np-mobile-drawer .np-panel) {
        display: none;
    }

    /* Hamburger is at top-left; shift fit button right to sit beside it */
    .np-fit-btn {
        left: 54px;
    }
}
