/* ===== AbleLink Brand Palette ===== */
:root {
    --ablelink-teal: #41B6B1;
    --ablelink-dark: #00697B;
    --ablelink-gold: #F9C934;
    --ablelink-purple: #5B3D8C;
    --ablelink-gray: #333333;
    --ablelink-bg: #FFFFFF;
    --ablelink-teal-50: #E9F7F6;
    --ablelink-gold-50: #FFF6D8;
    --ablelink-purple-50: #F1EAFE;
    --ablelink-via: #FD7E14;

    /* Map to Bootstrap tokens */
    --bs-body-bg: var(--ablelink-bg);
    --bs-body-color: var(--ablelink-gray);
    --bs-primary: var(--ablelink-purple);
    --bs-primary-rgb: 91, 61, 140;
    --bs-secondary: var(--ablelink-teal);
    --bs-secondary-rgb: 65, 182, 177;
    --bs-link-color: var(--ablelink-dark);
    --bs-link-hover-color: var(--ablelink-purple);
    --bs-border-color: rgba(0,0,0,.10);
}

/* ===== Base ===== */
body {
    background: var(--ablelink-bg);
    color: var(--ablelink-gray);
    font-family: "Raleway", "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--bs-link-color); }
a:hover { color: var(--bs-link-hover-color); }

/* ===== Headings ===== */
h2 {
    font-size: 2rem !important;
    line-height: 1.25;
    font-weight: 700;
    color: var(--ablelink-dark);
    margin-bottom: 0.75rem;
}

/* ===== Header & Global Nav ===== */
header, #global-nav {
    /*  background-color: var(--ablelink-dark); */
    color: #fff;
}
header a, #global-nav a, #global-nav .navbar-brand {
    color: #fff;
    text-decoration: none;
}
header a:hover, #global-nav a:hover {
    color: var(--ablelink-gold);
}

/* Route Library application header */
.rl-header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 1.25rem;
    min-height: 3.25rem;
}

.rl-brand-context {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    justify-self: start;
}

.rl-brand-title {
    width: fit-content;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.1;
    text-decoration: none;
}

.rl-session-context {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.3rem;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.78rem;
    line-height: 1.2;
}

.rl-session-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
}

.rl-session-item .bi {
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.75rem;
}

.rl-session-separator {
    color: rgba(255, 255, 255, 0.38);
}

.rl-header-middle {
    min-width: 0;
    width: min(100%, 620px);
    justify-self: center;
}

/* Compact route search/filter control for the application header. */
.rl-header-filter {
    display: flex;
    align-items: center;
    width: 100%;
    height: 2rem;
    padding: 0 0.35rem;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 0.45rem;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.rl-header-filter:focus-within {
    border-color: var(--ablelink-gold);
    background: rgba(255, 255, 255, 0.11);
    box-shadow: 0 0 0 0.12rem rgba(249, 201, 52, 0.18);
}

.rl-header-search,
.rl-header-type {
    display: flex;
    align-items: center;
    min-width: 0;
}

.rl-header-search {
    flex: 1 1 205px;
    gap: 0.4rem;
}

.rl-header-search > .bi,
.rl-header-type > .bi:not(.rl-header-type-chevron) {
    flex: 0 0 auto;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.8rem;
}

.rl-header-search-input,
.rl-header-type-filter {
    min-width: 0;
    height: 1.85rem;
    margin: 0;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0;
    background: transparent !important;
    color: #fff !important;
    box-shadow: none !important;
    font-size: 0.8rem;
    line-height: 1.2;
}

.rl-header-search-input {
    width: 100%;
    padding: 0 !important;
}

.rl-header-search-input::placeholder {
    color: rgba(255, 255, 255, 0.58);
    opacity: 1;
}

.rl-header-search-input::-webkit-search-cancel-button {
    display: none;
}

.rl-header-search-clear,
.rl-header-filter-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 1.45rem;
    height: 1.45rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.68rem;
    line-height: 1;
}

.rl-header-search-clear:hover,
.rl-header-search-clear:focus-visible,
.rl-header-filter-clear:hover,
.rl-header-filter-clear:focus-visible {
    background: rgba(255, 255, 255, 0.13);
    color: var(--ablelink-gold);
    outline: 0;
}

.rl-header-filter-divider {
    flex: 0 0 1px;
    width: 1px;
    height: 1.1rem;
    margin: 0 0.45rem;
    background: rgba(255, 255, 255, 0.22);
}

.rl-header-type {
    flex: 0 0 118px;
    gap: 0.35rem;
}

.rl-header-type-filter {
    width: 100%;
    padding: 0 !important;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    text-overflow: ellipsis;
}

.rl-header-type-filter option {
    background: #fff;
    color: var(--ablelink-gray);
}

.rl-header-type-chevron {
    flex: 0 0 auto;
    color: rgba(255, 255, 255, 0.64);
    font-size: 0.65rem;
    pointer-events: none;
}

.rl-header-filter-clear {
    margin-left: 0.2rem;
}

.rl-header-view-divider {
    margin-left: 0.35rem;
    margin-right: 0.35rem;
}

.rl-header-view-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex: 0 0 4.25rem;
    width: 4.25rem;
    height: 1.55rem;
    padding: 0 0.4rem;
    border: 0;
    border-radius: 0.35rem;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
}

.rl-header-view-toggle:hover,
.rl-header-view-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.18);
    color: var(--ablelink-gold);
    outline: 0;
}

.rl-header-view-toggle .bi {
    flex: 0 0 auto;
    font-size: 0.8rem;
}

.rl-header-actions {
    flex: 0 0 auto;
    justify-self: end;
}

.rl-unapproved-count {
    background-color: var(--ablelink-gold);
    color: #332900;
}

@media (max-width: 1199.98px) {
    .rl-header-inner {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .rl-header-middle {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
    }

    .rl-header-filter {
        width: 100%;
        margin-inline: auto;
    }
}

@media (max-width: 575.98px) {
    .rl-header-inner {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.75rem;
    }

    .rl-brand-context,
    .rl-header-middle,
    .rl-header-actions {
        grid-column: 1;
        width: 100%;
        justify-self: stretch;
    }

    .rl-header-actions {
        grid-row: 2;
    }

    .rl-header-middle {
        grid-row: 3;
    }

    .rl-header-filter {
        width: 100%;
    }

    .rl-header-search {
        flex-basis: 150px;
    }

    .rl-header-type {
        flex-basis: 108px;
    }
}

@media (max-width: 419.98px) {
    .rl-header-view-divider {
        margin-left: 0.2rem;
        margin-right: 0.2rem;
    }

    .rl-header-view-toggle {
        flex-basis: 1.85rem;
        width: 1.85rem;
        padding: 0;
    }

    .rl-header-view-toggle-label {
        display: none;
    }
}

/* New Item buttons in header/nav */
header .btn, #global-nav .btn-primary {
    --bs-btn-bg: var(--ablelink-purple);
    --bs-btn-border-color: var(--ablelink-purple);
    --bs-btn-hover-bg: var(--ablelink-teal);
    --bs-btn-hover-border-color: var(--ablelink-teal);
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
}

/* ===== Buttons (General) ===== */
.btn-primary {
    --bs-btn-bg: var(--ablelink-purple);
    --bs-btn-border-color: var(--ablelink-purple);
    --bs-btn-hover-bg: var(--ablelink-dark);
    --bs-btn-hover-border-color: var(--ablelink-dark);
}
.btn-outline-secondary {
    --bs-btn-color: var(--ablelink-dark);
    --bs-btn-border-color: var(--ablelink-dark);
    --bs-btn-hover-bg: var(--ablelink-dark);
    --bs-btn-hover-border-color: var(--ablelink-dark);
    --bs-btn-hover-color: #fff;
}
.btn-gradient {
    background: linear-gradient(90deg, var(--ablelink-purple), var(--ablelink-teal));
    color: #fff; border: none;
}
.btn-gradient:hover { opacity: .9; }

/* ===== Extended Button Colors (Route Builder Specific) ===== */
.btn-outline-primary {
    --bs-btn-color: var(--ablelink-purple);
    --bs-btn-border-color: var(--ablelink-purple);
    --bs-btn-hover-bg: var(--ablelink-purple);
    --bs-btn-hover-border-color: var(--ablelink-purple);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--ablelink-dark);
    --bs-btn-active-border-color: var(--ablelink-dark);
}

/* Mapping "Success" actions (Save/Export) to AbleLink Teal */
.btn-success {
    --bs-btn-bg: var(--ablelink-teal);
    --bs-btn-border-color: var(--ablelink-teal);
    --bs-btn-hover-bg: var(--ablelink-dark);
    --bs-btn-hover-border-color: var(--ablelink-dark);
    --bs-btn-color: #fff;
}
.btn-outline-success {
    --bs-btn-color: var(--ablelink-teal);
    --bs-btn-border-color: var(--ablelink-teal);
    --bs-btn-hover-bg: var(--ablelink-teal);
    --bs-btn-hover-border-color: var(--ablelink-teal);
    --bs-btn-hover-color: #fff;
}

.btn-danger {
    --bs-btn-bg: #d9534f;
    --bs-btn-border-color: #d9534f;
    --bs-btn-hover-bg: #c9302c;
    --bs-btn-hover-border-color: #ac2925;
}
.btn-outline-danger {
    --bs-btn-color: #dc3545;
    --bs-btn-border-color: #dc3545;
    --bs-btn-hover-bg: #dc3545;
    --bs-btn-hover-color: #fff;
}

.btn-outline-danger:disabled,
.btn-outline-danger.disabled {
    --bs-btn-color: #6c757d !important;
    --bs-btn-border-color: #6c757d !important;
    opacity: 0.65;
}

/* Route video delete action: use a neutral disabled color instead of the
   branded Bootstrap secondary color (AbleLink teal). */
.dropdown-item.route-video-delete:disabled {
    color: #6c757d !important;
}
/* ===== Route editor toolbars ===== */
.route-map-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.route-map-toolbar .btn-group-sm > .btn {
    font-weight: 600;
}

.route-insert-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.route-insert-toolbar .badge {
    font-weight: 700;
}

.badge.text-bg-primary {
    background-color: var(--ablelink-purple) !important;
    color: #fff !important;
}

.badge.text-bg-warning {
    background-color: var(--ablelink-gold) !important;
    color: var(--ablelink-gray) !important;
}

/* Optional tool-specific button emphasis */
.btn-tool-assist.btn-primary,
.btn-tool-assist.active {
    --bs-btn-bg: var(--ablelink-gold);
    --bs-btn-border-color: var(--ablelink-gold);
    --bs-btn-hover-bg: #e0b320;
    --bs-btn-hover-border-color: #e0b320;
    --bs-btn-color: #222;
}

.btn-tool-instruction.btn-primary,
.btn-tool-instruction.active {
    --bs-btn-bg: var(--ablelink-purple);
    --bs-btn-border-color: var(--ablelink-purple);
    --bs-btn-hover-bg: #4b3274;
    --bs-btn-hover-border-color: #4b3274;
    --bs-btn-color: #fff;
}

.btn-tool-maneuver.btn-primary,
.btn-tool-maneuver.active {
    --bs-btn-bg: var(--ablelink-teal);
    --bs-btn-border-color: var(--ablelink-teal);
    --bs-btn-hover-bg: var(--ablelink-dark);
    --bs-btn-hover-border-color: var(--ablelink-dark);
    --bs-btn-color: #fff;
}

.btn-tool-via.btn-primary,
.btn-tool-via.active {
    --bs-btn-bg: var(--ablelink-via);
    --bs-btn-border-color: var(--ablelink-via);
    --bs-btn-hover-bg: #d96506;
    --bs-btn-hover-border-color: #d96506;
    --bs-btn-color: #fff;
}

/* ===== Form Fields ===== */
label {
    display: block;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--ablelink-gray);
}

/* Inputs, selects, textareas */
input, select, textarea, optgroup,
.form-control, .form-select {
    padding: 8px !important;
    border: 1px solid #ccc;
    border-radius: 0.5rem;
    font-family: inherit;
    color: var(--ablelink-gray);
    width: 100%;
}
.form-control:focus, .form-select:focus,
input:focus, select:focus, textarea:focus {
    border-color: var(--ablelink-teal);
    box-shadow: 0 0 0 0.25rem rgba(65,182,177,.25);
    outline: none;
}

/* Invalid form fields */
.form-control.is-invalid, .form-select.is-invalid {
    border-color: #dc3545;
    padding-right: calc(1.5em + .75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(.375em + .1875rem) center;
    background-size: calc(.75em + .375rem) calc(.75em + .375rem);
}
.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, .25);
}

textarea::placeholder,
input::placeholder,
.form-control::placeholder {
    color: #999999 !important;
    opacity: 1 !important;
}

/* Small utility: tighter helper text */
.form-text {
    color: #6c757d;
    margin-top: 0.25rem;
    font-size: 0.75em;
    line-height: 1.2;
}

/* ===== Cards / Panels / Sidebar ===== */
.card { border-radius: 1rem; border-color: var(--bs-border-color); }
.card-body { background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.05); }

aside {
    background: #fff;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
}

/* ===== Active & Selected Item States ===== */
.border-indigo-400 { border: 2px solid var(--ablelink-gold) !important; }
.bg-indigo-50 { background-color: var(--ablelink-teal-50) !important; color: var(--ablelink-gray) !important; }

/* Route Step specific states */
.step-instruction {
    background-color: #ebe1ff !important;
    color: var(--ablelink-gray) !important;
}
.step-instruction-selected {
    border: 2px solid var(--ablelink-purple) !important;
}

.step-assist {
    background-color: #f9edc8 !important;
    color: var(--ablelink-gray) !important;
}
.step-assist-selected {
    border: 2px solid var(--ablelink-gold) !important;
}

.step-stop {
    background: #fbe3e6;
    border-color: #dc3545;
}

.step-stop-selected {
    background: #f8d7da;
    border-color: #dc3545;
    box-shadow: inset 0 0 0 1px #dc3545;
}

/* Optional via step/list styling if ever used */
.step-via {
    background-color: #ffe7d1 !important;
    color: var(--ablelink-gray) !important;
}
.step-via-selected {
    border: 2px solid var(--ablelink-via) !important;
}

/* Sidebar Selected State Hook */
.step-selected {
    border: 2px solid var(--ablelink-gold) !important;
    background-color: var(--ablelink-teal-50) !important;
    color: var(--ablelink-gray) !important;
}

/* Map info-window header hooks */
.step-maneuver {
    background-color: var(--ablelink-teal-50);
    color: var(--ablelink-gray);
}
.step-assist {
    background-color: var(--ablelink-gold-50) !important;
    color: var(--ablelink-gray) !important;
}
.step-instruction {
    background-color: var(--ablelink-purple-50) !important;
    color: var(--ablelink-gray) !important;
}
.step-via-header {
    background-color: #ffe7d1;
    color: var(--ablelink-gray);
}

/* ===== Accordions (Form Containers) ===== */
.accordion-button {
    font-weight: 700;
    color: var(--ablelink-dark);
}
.accordion-button:not(.collapsed) {
    background-color: var(--ablelink-teal-50);
    color: var(--ablelink-gray);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,.05);
}
.accordion-body {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* Accordion Progress Indicators */
.progress-pills {
    display: flex;
    gap: 3px;
    align-items: center;
}
.progress-pill {
    width: 12px;
    height: 4px;
    background-color: #999999;
    border-radius: 2px;
    transition: background-color 0.3s ease;
}
.progress-pill.filled {
    background-color: var(--ablelink-teal);
}
.progress-text {
    font-size: .8rem;
    color: #666666;
    font-family: var(--bs-font-monospace);
    margin-right: 6px;
}

/* ===== Sortable states (Step list drag feedback) ===== */
.step-list .btn-light {
    border: 1px solid var(--bs-border-color);
}
.step-list .btn-light:hover {
    background-color: var(--ablelink-teal-50);
}
.sortable-ghost { opacity: .6; }
.sortable-chosen { background-color: var(--ablelink-teal-50); }

/* The item you grabbed */
.step-list .step-item.sb-chosen {
    outline: 2px solid var(--bs-primary);
    background-color: #e7f1ff;
}

/* The “ghost” that shows while dragging */
.step-list .step-item.sb-ghost {
    opacity: 0.4;
    background-color: #ffc10733;
}

/* While actually dragging */
.step-list .step-item.sb-drag {
    cursor: grabbing;
}

/* ===== Media Preview Thumbs ===== */
.media-preview-clickable {
    cursor: pointer;
}
.step-preview-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: #fff;
    cursor: pointer;
}

/* Kill default button styling */
.step-preview-thumb:focus {
    outline: none;
}
.step-preview-thumb:focus-visible {
    outline: 2px solid rgba(13, 110, 253, 0.35);
    outline-offset: 2px;
}

/* The image: preserve aspect ratio, never crop */
.step-preview-thumb-img {
    display: block;
    max-width: 100px;
    max-height: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.375rem;
}

/* ===== Utility Classes ===== */
.font-monospace {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
}

.chip {
    background-color: var(--ablelink-teal);
    color: #fff;
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: .8rem;
    line-height: 1.1;
    font-weight: 600;
    white-space: nowrap;
}
.chip + .chip { margin-left: 0.25rem; }

.badge.rounded-pill.bg-danger {
    padding: .2em .4em;
    font-size: .7em;
    vertical-align: middle;
}

/* ===== Footer / Bottom Action Bar ===== */
footer { background: var(--ablelink-dark); color: #fff; }

.sticky-action-bar {
    background-color: #fff;
    border-top: 1px solid var(--bs-border-color);
    padding: 1rem 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/* Fix Google Places Autocomplete dropdown z-index inside Bootstrap modals */
.pac-container {
    z-index: 1060 !important;
}

/* Small-screen toolbar cleanup */
@media (max-width: 576px) {
    .route-insert-toolbar {
        align-items: stretch;
    }

    .route-insert-toolbar .btn-group {
        width: 100%;
        flex-wrap: wrap;
    }

    .route-insert-toolbar .btn-group > .btn {
        flex: 1 1 48%;
    }

    .route-map-toolbar .btn-group {
        width: 100%;
    }

    .route-map-toolbar .btn-group > .btn {
        flex: 1 1 auto;
    }
}


/* Route Library admin and public page layout */
.library-category-thumb,
.public-library-category-thumb {
  width: 84px;
  height: 84px;
  object-fit: cover;
}

.library-category-thumb-sm {
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.library-empty-state,
.public-library-empty-state {
  border: 1px dashed rgba(108, 117, 125, 0.35);
  border-radius: 0.75rem;
  background: rgba(248, 249, 250, 0.7);
}

.library-filter-card .form-label,
.public-library-filter-card .form-label,
.public-library-category-card .form-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
}

.library-status-badges .badge {
  font-weight: 600;
}

.min-width-0 {
  min-width: 0;
}

.library-route-card .card-body {
  min-height: 220px;
}

.library-route-title {
  line-height: 1.25;
}

.library-route-card .dropdown-toggle::after {
  margin-left: 0.35rem;
}

.library-route-card .form-check-input {
  cursor: pointer;
}

.library-route-meta {
  min-height: 1.25rem;
}

.library-route-image-wrap {
  height: 150px;
  background: #f8f9fa;
}

.library-route-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-route-preview {
  min-height: calc(100vh - 220px);
}

.library-route-preview-image-wrap {
  min-height: 420px;
}

.library-route-preview img {
  max-height: calc(100vh - 360px);
  object-fit: contain;
}

.library-route-card-unpublished {
  opacity: 0.72;
  border-style: dashed;
}

.library-route-card-unpublished .library-route-image-wrap {
  filter: grayscale(0.35);
}

.library-status-filter .btn {
  min-width: 130px;
}

#public-route-map {
  min-height: 420px;
  border-radius: 0.75rem;
}

.public-route-preview {
  min-height: 440px;
}

.public-route-preview-image-wrap {
  min-height: 300px;
}

.public-route-preview img {
  max-height: 320px;
  object-fit: contain;
}

/* Google Maps info-window content is assembled with DOM APIs. */
.route-map-info-window {
  min-width: 220px;
  max-width: 280px;
}

.route-map-info-header {
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
  background: #41b6b1;
  color: #fff;
}

.route-map-info-header strong {
  display: block;
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.route-map-info-assist {
  background: #f9c934;
  color: #333;
}

.route-map-info-instruction {
  background: #5b3d8c;
}

.route-map-info-stop {
  background: #dc3545;
}

.route-map-info-transit_stop {
  background: #00697b;
}

.route-map-info-body {
  display: flex;
  gap: 10px;
}

.route-map-info-image {
  width: 70px;
  height: 70px;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid #dee2e6;
  border-radius: 4px;
}

.route-map-info-description {
  max-height: 60px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.3;
}


/* ===== Route Library: category tiles ===== */
.library-category-toggle-bar {
  min-height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid var(--bs-border-color);
  border-bottom: 1px solid var(--bs-border-color);
}

.library-category-toggle {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0;
  border: 0;
  background: transparent;
  color: #6c757d;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
}

.library-category-toggle:hover,
.library-category-toggle:focus-visible {
  color: var(--ablelink-gray);
}

.library-category-toggle:focus-visible,
.library-category-tile-new:focus-visible {
  outline: 2px solid var(--ablelink-teal);
  outline-offset: 2px;
}

.library-category-toggle .bi {
  width: 0.8rem;
  flex: 0 0 0.8rem;
  font-size: 0.65rem;
  text-align: center;
}

.library-category-toggle-count {
  font-weight: 400;
  color: #999;
}

.library-category-selection {
  padding-top: 0.75rem;
}

.library-tile-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.library-category-tile {
  position: relative;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
}

.library-category-tile:focus-within {
  border-color: var(--ablelink-teal);
  box-shadow: 0 0 0 0.25rem rgba(65, 182, 177, .25);
}

/* The whole tile navigates, except where an action sits on top of it. */
.library-category-tile-link {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
}

.library-category-tile-link:focus {
  outline: none;
}

.library-category-tile-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--bs-border-color);
}

.library-category-tile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-category-tile-body {
  padding: 0.75rem;
  min-width: 0;
}

.library-category-tile-name {
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.library-category-tile-count {
  font-size: 0.8rem;
  color: #6c757d;
}

/* Per-tile action menu, layered above the navigation button. */
.library-category-tile-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
}

.library-category-tile-actions .btn {
  --bs-btn-padding-x: 0.5rem;
  --bs-btn-padding-y: 0.15rem;
  background: rgba(255, 255, 255, .92);
  border-color: var(--bs-border-color);
  color: var(--ablelink-gray);
}

.library-category-tile-actions .dropdown-toggle::after {
  display: none;
}

.library-category-tile-new {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ablelink-purple);
  border-radius: 0.25rem;
}

.library-category-tile-new:hover:not(:disabled) {
  background: var(--ablelink-purple-50);
}

.library-category-tile-new:disabled {
  opacity: 0.6;
}

.library-category-tile-new .bi {
  font-size: 1.15rem;
  line-height: 1;
}

/* ===== Route Library: breadcrumb as page title ===== */
.library-breadcrumb {
  --bs-breadcrumb-divider-color: #6c757d;
  --bs-breadcrumb-item-padding-x: 0.6rem;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.library-breadcrumb .breadcrumb-item {
  font-size: 1rem;
}

/* Bootstrap floats breadcrumb dividers. That makes the divider before the
   larger current-page heading align to the top of the line instead of its
   text baseline. Keep library dividers inline so every slash tracks the
   adjacent breadcrumb text consistently. */
.library-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  float: none;
  display: inline-block;
  vertical-align: baseline;
}

.library-breadcrumb .breadcrumb-item .btn-link {
  color: var(--bs-link-color);
  vertical-align: baseline;
}

.library-breadcrumb .library-breadcrumb-current {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ablelink-dark);
  margin: 0;
  display: inline;
}

/* ===== Route Library: full-width route rows ===== */
.library-route-row {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
  padding: 1rem;
}

.library-route-row + .library-route-row {
  margin-top: 0.75rem;
}

.library-route-row-selected {
  border-color: var(--ablelink-teal);
  background: var(--ablelink-teal-50);
}

.library-route-row-unapproved {
  border-style: dashed;
}

.library-route-row-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.library-route-row-thumb {
  flex: 0 0 auto;
  width: 168px;
  aspect-ratio: 16 / 10;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #f8f9fa;
  border: 1px solid var(--bs-border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.library-route-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-route-row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.library-route-row-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.library-route-row-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.25rem;
  color: var(--ablelink-dark);
}

.library-route-row-meta {
  font-size: 0.8rem;
  color: #6c757d;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.library-route-row-id {
  word-break: break-all;
}

.library-route-row-description {
  font-size: 0.875rem;
  color: #6c757d;
  margin: 0.5rem 0 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Selection is a column of its own with a target larger than the box, so it
   stays easy to hit without making the whole row clickable. Row clicks are
   deliberately left free: the route ID has to stay selectable for copying, and
   the bar's main action is an irreversible delete. */
.library-route-select {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  padding: 0.35rem 0.5rem 0.75rem 0.25rem;
  margin: 0;
  cursor: pointer;
}

.library-route-select .form-check-input,
.library-route-select-all .form-check-input {
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  cursor: pointer;
  border-width: 2px;
  border-color: #8a8f94;
}

.library-route-select .form-check-input:checked,
.library-route-select-all .form-check-input:checked,
.library-route-select-all .form-check-input:indeterminate {
  background-color: var(--ablelink-purple);
  border-color: var(--ablelink-purple);
}

.library-route-select-all {
  display: flex;
  align-items: center;
  padding: 0.35rem 0.5rem 0.35rem 0.25rem;
}

.library-route-row:hover {
  border-color: #adb5bd;
}

.library-route-row:has(.form-check-input:focus-visible) {
  border-color: var(--ablelink-teal);
  box-shadow: 0 0 0 0.25rem rgba(65, 182, 177, .25);
}

/* Stack on narrow screens. Desktop stays full width. */
@media (max-width: 991.98px) {
  .library-route-row-layout {
    flex-direction: column;
  }

  .library-route-row-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
  }

  .library-route-row-actions {
    width: 100%;
  }

  .library-route-select {
    padding-bottom: 0.25rem;
  }

  .library-route-row-actions .btn {
    flex: 1 1 auto;
  }

  .library-breadcrumb .library-breadcrumb-current {
    font-size: 1.4rem;
  }
}

/* ===== Route Library: selection bar and pager ===== */
/* Anchored to the foot of the list so it stays reachable while rows are being
   picked, and never covers the rows still being read. */
.library-selection-bar {
  /* display set here, not via d-flex: the utility is !important and would
     override the inline display:none that Alpine's x-show applies. */
  display: flex;
  border: 1px solid var(--ablelink-teal);
  background: var(--ablelink-teal-50);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  position: sticky;
  bottom: 0.75rem;
  z-index: 5;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .12);
}

.library-selection-clear {
  color: var(--ablelink-dark);
}

.library-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
}

.library-pager .pagination {
  margin-bottom: 0;
}

.library-pager .page-link {
  color: var(--ablelink-dark);
  cursor: pointer;
}

.library-pager .page-item.active .page-link {
  background-color: var(--ablelink-purple);
  border-color: var(--ablelink-purple);
  color: #fff;
}

.library-pager .page-item.disabled .page-link {
  color: #adb5bd;
}

.library-pager-summary {
  font-size: 0.875rem;
  color: #6c757d;
}

.library-route-card-unapproved {
  border-style: dashed;
}

/* ===== Route Library: map overview ===== */
.library-map-status {
  border: 1px solid var(--ablelink-gold);
  background: var(--ablelink-gold-50);
  border-radius: 0.75rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.library-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: stretch;
}

.library-map-canvas-wrap {
  position: relative;
  min-width: 0;
}

.library-map-canvas {
  width: 100%;
  height: calc(100vh - 340px);
  min-height: 460px;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  background: #f8f9fa;
}

.library-map-loading {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  z-index: 2;
}

.library-map-legend {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.9rem;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  z-index: 2;
}

.library-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* The same green start / black end the legacy library used. */
.library-map-key {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
}

.library-map-key-start { background: #008000; }
.library-map-key-end { background: #222222; }

.library-map-panel {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  background: #fff;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 460px;
  max-height: calc(100vh - 340px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
}

.library-map-panel-empty {
  margin: auto;
  text-align: center;
  color: #6c757d;
}

.library-map-panel-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.library-map-panel-item {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.6rem;
  padding: 0.65rem;
}

.library-map-panel-item:hover {
  border-color: var(--ablelink-teal);
  background: var(--ablelink-teal-50);
}

.library-map-panel-meta {
  font-size: 0.75rem;
  color: #6c757d;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
}

.library-map-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-top: 0.3rem;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, .2);
}

@media (max-width: 991.98px) {
  .library-map-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .library-map-canvas {
    height: 55vh;
    min-height: 320px;
  }

  .library-map-panel {
    min-height: 0;
    max-height: none;
  }
}

/* Legend in the legacy shape: an endpoint key and a route type colour key. */
.library-map-legend {
  flex-direction: column;
  gap: 0.4rem;
  max-width: 60%;
}

.library-map-legend-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
}

.library-map-legend-heading {
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #495057;
  width: 100%;
}

.library-map-legend-pin {
  width: 14px;
  height: 26px;
  vertical-align: -6px;
}

.library-map-legend-pin-end {
  width: 11px;
  height: 21px;
  vertical-align: -4px;
}

.library-map-type-swatch {
  display: inline-block;
  width: 26px;
  height: 4px;
  border-radius: 2px;
}

/* Map-view fixes: preserve true coordinates while making shared points usable. */
.route-map-info-group {
  max-width: 320px;
  max-height: 420px;
  overflow-y: auto;
}

.route-map-info-separator {
  margin: 0.75rem 0;
}

.route-map-info-body {
  flex-wrap: wrap;
}

.route-map-info-description {
  flex: 1 1 120px;
}

.route-map-info-meta {
  flex: 1 0 100%;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.15rem 0.5rem;
  margin: 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--bs-border-color);
  font-size: 0.75rem;
}

.route-map-info-meta dt,
.route-map-info-meta dd {
  margin: 0;
}

.library-map-panel-thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 0.35rem;
  border: 1px solid var(--bs-border-color);
  object-fit: cover;
}

.library-map-panel-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* ===== Route Library: map workspace ===== */
body.route-library-map-expanded {
  overflow: hidden;
}

.library-map {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.library-map-toolbar {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.75rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
}

.library-map-toolbar-main,
.library-map-toolbar-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.library-map-toolbar-main {
  align-items: flex-start;
}

.library-map-toolbar-secondary {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--bs-border-color);
}

.library-map-toolbar-breadcrumb {
  flex: 1 1 260px;
  min-width: 180px;
  padding-top: 0.2rem;
}

.library-map-toolbar-controls {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}

.library-map-search {
  flex: 1 1 260px;
  max-width: 420px;
  min-width: 210px;
}

.library-map-type-filter {
  width: auto;
  min-width: 175px;
}

.library-map-count-summary {
  min-width: 0;
}

.library-map-notices:empty {
  display: none;
}

.library-map-notices .library-map-status:last-child {
  margin-bottom: 0;
}

.library-map-status-error {
  border-color: var(--bs-danger-border-subtle);
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
}

.library-map-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 410px);
  height: clamp(580px, calc(100vh - 245px), 900px);
  min-height: 0;
}

.library-map-layout-panel-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.library-map-canvas-wrap,
.library-map-canvas,
.library-map-panel {
  min-height: 0;
  height: 100%;
}

.library-map-canvas {
  min-height: 0;
}

.library-map-panel {
  max-height: none;
  overflow: hidden;
}

.library-map-panel-group-view,
.library-map-route-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.library-map-panel-list {
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 0.15rem;
}

.library-map-panel-item {
  padding: 0;
  overflow: hidden;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.library-map-panel-item-main {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.7rem;
}

.library-map-panel-item-main:hover,
.library-map-panel-item-main:focus-visible {
  background: var(--ablelink-teal-50);
}

.library-map-panel-item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: 0 0.7rem 0.7rem;
}

.library-map-route-image {
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.6rem;
  background: #f8f9fa;
}

.library-map-legend {
  max-width: min(520px, calc(100% - 1.5rem));
  max-height: min(420px, calc(100% - 1.5rem));
  overflow-y: auto;
}

.library-map-expanded {
  position: fixed;
  inset: 0;
  z-index: 1040;
  height: 100vh;
  padding: 0.75rem;
  background: var(--bs-light);
  overflow: hidden;
}

.library-map-expanded .library-map-toolbar {
  flex: 0 0 auto;
}

.library-map-expanded .library-map-notices {
  flex: 0 0 auto;
}

.library-map-expanded .library-map-layout {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.library-map-expanded .library-map-canvas,
.library-map-expanded .library-map-panel {
  height: 100%;
}

@media (max-width: 1199.98px) {
  .library-map-toolbar-main,
  .library-map-toolbar-secondary {
    align-items: stretch;
    flex-direction: column;
  }

  .library-map-toolbar-controls {
    justify-content: flex-start;
    width: 100%;
  }

  .library-map-search {
    max-width: none;
  }

  .library-map-toolbar-secondary > .d-flex {
    justify-content: flex-start;
  }

  .library-map-layout {
    height: clamp(540px, calc(100vh - 300px), 820px);
  }
}

@media (max-width: 991.98px) {
  .library-map-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .library-map-canvas-wrap,
  .library-map-canvas {
    height: 60vh;
    min-height: 380px;
  }

  .library-map-panel {
    height: auto;
    max-height: 48vh;
    min-height: 220px;
  }

  .library-map-expanded .library-map-layout {
    display: grid;
    grid-template-rows: minmax(0, 1fr) minmax(220px, 38vh);
    height: 100%;
  }

  .library-map-expanded.library-map-panel-is-collapsed .library-map-layout {
    grid-template-rows: minmax(0, 1fr);
  }

  .library-map-expanded .library-map-canvas-wrap,
  .library-map-expanded .library-map-canvas,
  .library-map-expanded .library-map-panel {
    height: 100%;
    min-height: 0;
  }
}

@media (max-width: 575.98px) {
  .library-map-toolbar-controls > *,
  .library-map-toolbar-secondary .btn-group,
  .library-map-search,
  .library-map-type-filter {
    width: 100%;
    max-width: none;
  }

  .library-map-toolbar-controls .btn-group .btn,
  .library-map-toolbar-secondary .btn-group .btn {
    flex: 1 1 0;
  }

  .library-map-expanded {
    padding: 0.4rem;
  }

  .library-map-expanded .library-map-toolbar {
    max-height: 40vh;
    overflow-y: auto;
  }

  .library-map-canvas-wrap,
  .library-map-canvas {
    min-height: 320px;
  }
}


/* Shared-start spider expansion. The number matches the green route marker
   fanned out from a grey + start pin. */
.library-map-route-number {
  align-items: center;
  background: #008000;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex: 0 0 1.65rem;
  font-size: .72rem;
  font-weight: 700;
  height: 1.65rem;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .18);
}

