/*
Theme Name: EGCC Customizr
Version: 2.1 - Complete and Verified
*/

/* ===================================================================
   Pagination Styles
=================================================================== */
.route-pagination {
    margin: 30px 0;
    text-align: center;
}

.pagination-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 8px 12px;
    margin: 0 2px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.2s ease;
    display: inline-block;
    text-decoration: none;
    min-width: 40px;
    box-sizing: border-box;
}

.pagination-btn:hover:not(.disabled):not(.pagination-current) {
    background: #e9ecef;
    border-color: #adb5bd;
    text-decoration: none;
}

.pagination-btn.pagination-current {
    background: #007cba;
    border-color: #007cba;
    color: white;
    cursor: default;
    font-weight: bold;
}

.pagination-btn.disabled {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination-ellipsis {
    padding: 8px 4px;
    color: #6c757d;
    display: inline-block;
}

.pagination-info {
    font-size: 14px;
    color: #666;
    margin-top: 10px;
}

/* Mobile responsive pagination */
@media (max-width: 768px) {
    .pagination-btn {
        padding: 6px 8px;
        font-size: 12px;
        margin: 0 1px;
        min-width: 32px;
    }
    
    .route-pagination {
        margin: 20px 0;
    }
    
    .pagination-info {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .pagination-btn {
        padding: 4px 6px;
        font-size: 11px;
        margin: 0 1px;
        min-width: 28px;
    }
}

/* ===================================================================
   General Filter Container & Header
=================================================================== */
/* Filter Presets Bar */
.filter-presets-bar a:hover {
    background: rgba(255,255,255,0.35) !important;
    text-decoration: none;
}

.filter-presets-bar a:active {
    background: rgba(255,255,255,0.45) !important;
}

.route-filter-container {
    max-width: 100%;
    margin: 0 auto 20px auto;
    background-color: var(--rfcc-filter-background-color, #7A8D7B);
    padding: 12px 18px;
    border-radius: 8px;
    color: #fff;
    position: relative;
    box-sizing: border-box;
    container-type: inline-size; /* Enable container queries */
}
.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.route-filter-container h2 {
    color: #fff;
    font-size: 1.3rem;
    margin: 0;
    flex-grow: 1;
}
.filter-toggle-arrow {
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
    margin-left: 10px;
}

/* Bottom rollup arrow - positioned at bottom left, only visible when expanded */
.filter-bottom-arrow {
    position: absolute;
    bottom: 10px;
    left: 15px;
    pointer-events: auto;
}

.filter-toggle-arrow-bottom {
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
    color: #fff;
    opacity: 0.8;
}

.filter-toggle-arrow-bottom:hover {
    opacity: 1;
    transform: translateY(-1px);
}

/* Hide bottom arrow when filter is collapsed */
.route-filter-container.collapsed .filter-bottom-arrow {
    display: none;
}

.filter-content {
    padding-top: 8px;
    position: relative; /* To contain the absolute positioned bottom arrow */
}
.filter-section {
    margin-bottom: 10px; /* Reduced vertical space */
}
.filter-section:last-of-type {
    margin-bottom: 0;
}

/* Collapsible section styles */
.collapsible-section .section-header {
    cursor: pointer;
    display: block;
    user-select: none;
    transition: opacity 0.2s ease;
}
.collapsible-section .section-header:hover {
    opacity: 0.8;
}
.collapsible-section .toggle-arrow {
    font-size: 0.9em;
    margin-left: 4px;
    transition: transform 0.2s ease;
}
.collapsible-section .section-header.collapsed .toggle-arrow {
    transform: rotate(0deg);
}
.collapsible-section .filter-preview {
    display: none;
    font-weight: normal;
    opacity: 0.7;
    margin-left: 4px;
}
.collapsible-section .section-header.collapsed .filter-preview {
    display: inline;
}
.collapsible-section .section-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}
.collapsible-section .section-content.collapsing {
    max-height: 0;
    opacity: 0;
}
.filter-section label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 6px;
    font-weight: 600;
    color: #fff;
}

/* Sort dropdown styling - match translucent theme like inactive climbing buttons */
.sort-dropdown, #sort-results {
    background-color: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.9rem; /* Match other font sizes in filter box */
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 35px;
}

.sort-dropdown:hover, #sort-results:hover {
    background-color: rgba(255,255,255,0.3);
}

.sort-dropdown:focus, #sort-results:focus {
    outline: none;
    background-color: rgba(255,255,255,0.3);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
}

/* Style dropdown options for better visibility */
.sort-dropdown option, #sort-results option {
    background-color: #2c3e50;
    color: #fff;
    padding: 8px;
}

/* ===================================================================
   Inputs, Toggles, and Buttons (with Definitive Layout Fix)
=================================================================== */

/* --- Search Input & Toggle --- */
.search-with-toggle {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
}

/* Enhanced responsive wrapping - triggers when search input gets too narrow */
@container (max-width: 500px) {
    .search-with-toggle {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }
    
    .search-scope-toggle {
        justify-self: center;
        width: auto;
        min-width: 210px;
    }
}

/* More aggressive fallback for browsers without container query support */
@media (max-width: 600px) {
    .route-filter-container .search-with-toggle {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }
    
    .route-filter-container .search-scope-toggle {
        justify-self: center;
        width: auto;
        min-width: 210px;
    }
}

/* Emergency fallback - force wrap on very small screens */
@media (max-width: 400px) {
    .search-with-toggle {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }
    
    .search-scope-toggle {
        justify-self: center !important;
        width: auto !important;
        min-width: 210px !important;
    }
}
#route-search {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-width: 180px; /* Ensure minimum usable width (~20+ characters) */
    max-width: 100%;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.3);
    background-color: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 0.85rem;
    box-sizing: border-box;
}

/* Force minimum width on very narrow screens */
@media (max-width: 400px) {
    #route-search {
        min-width: 200px;
        width: 100%;
    }
}
#route-search::placeholder {
    color: rgba(255,255,255,0.7);
}

/* --- Toggles (Metric/Imperial & Title/Desc) --- */
.unit-toggle-section,
.search-scope-toggle {
    width: 210px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.unit-label,
.scope-label {
    flex-basis: 70px;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
    transition: color 0.2s ease;
    white-space: nowrap;
}
.unit-label.unit-label-metric,
.scope-label.scope-title {
    text-align: right;
}
.unit-label.unit-label-imperial,
.scope-label.scope-desc {
    text-align: left;
}
.unit-label.active-unit,
.scope-label.active-unit {
    color: #fff;
}
.unit-toggle-btn,
.scope-toggle-btn {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    width: 44px;
    height: 24px;
    background-color: rgba(255,255,255,0.3);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}
.unit-toggle-btn:hover,
.scope-toggle-btn:hover {
    background-color: rgba(255,255,255,0.4);
}
.toggle-slider {
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.unit-toggle-btn.imperial .toggle-slider,
.scope-toggle-btn.active .toggle-slider {
    transform: translateX(20px);
}


/* --- Filter Button Groups --- */
.grade-buttons,
.club-group-buttons,
.climbing-buttons,
.direction-buttons,
.route-shortcut-buttons,
.activity-type-buttons {
    display: grid;
    gap: 6px;
}
.grade-buttons {
    grid-template-columns: repeat(6, 1fr);
}
.climbing-buttons,
.route-shortcut-buttons,
.activity-type-buttons,
.club-group-buttons,
.direction-buttons {
    /* Auto-fit layout with wrapping as last resort - buttons resize first, then wrap */
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
}

/* Ensure direction buttons can wrap on narrow containers */
@media (max-width: 500px) {
    .direction-buttons {
        display: flex !important;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .direction-buttons .direction-btn,
    .direction-buttons .direction-all-none-btn {
        flex: 0 0 auto;
        min-width: 50px;
    }
}
.grade-btn,
.club-group-btn,
.climbing-btn,
.direction-btn,
.route-shortcut-btn,
.activity-type-btn,
.club-group-all-none-btn,
.direction-all-none-btn,
.activity-type-all-none-btn {
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--rfcc-filter-button-unselected-color, rgba(255,255,255,0.2));
    color: var(--rfcc-filter-button-unselected-text-color, #fff);
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
    text-align: center;
    min-width: 60px; /* Ensures buttons don't get too narrow */
    white-space: nowrap; /* Prevents text wrapping within buttons */
}

/* Special styling for All/None buttons */
.club-group-all-none-btn,
.direction-all-none-btn,
.activity-type-all-none-btn {
    background-color: rgba(255,255,255,0.15);
    font-style: italic;
    border: 1px solid rgba(255,255,255,0.3);
    /* margin-left removed - flexbox gap handles spacing uniformly */
}
.grade-btn:hover,
.club-group-btn:hover,
.climbing-btn:hover,
.direction-btn:hover,
.route-shortcut-btn:hover,
.activity-type-btn:hover,
.club-group-all-none-btn:hover,
.direction-all-none-btn:hover,
.activity-type-all-none-btn:hover {
    background-color: var(--rfcc-filter-button-selected-hover-color, rgba(255,255,255,0.3));
    color: var(--rfcc-filter-button-hover-text-color, #fff);
    transform: translateY(-1px);
}
.grade-btn.active,
.club-group-btn.active,
.climbing-btn.active,
.direction-btn.active,
.route-shortcut-btn.active,
.activity-type-btn.active {
    background-color: var(--rfcc-filter-button-selected-color, rgba(255,255,255,0.9));
    color: var(--rfcc-filter-button-selected-text-color, #333);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Ensure route shortcut, activity type, and climbing profile buttons have consistent font rendering */
.route-shortcut-btn,
.activity-type-btn,
.climbing-btn {
    font-weight: 500 !important;
    font-size: 0.8rem !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.route-shortcut-btn:not(.active),
.activity-type-btn:not(.active),
.climbing-btn:not(.active) {
    color: var(--rfcc-filter-button-unselected-text-color, #fff) !important;
}

.route-shortcut-btn.active,
.activity-type-btn.active,
.climbing-btn.active {
    color: var(--rfcc-filter-button-selected-text-color, #333) !important;
    font-weight: 500 !important;
}

.route-shortcut-btn:hover,
.activity-type-btn:hover,
.climbing-btn:hover {
    color: var(--rfcc-filter-button-hover-text-color, #fff) !important;
}

/* Special styling for "All" type route shortcut buttons */
.route-shortcut-btn.route-shortcut-all {
    border: 1px solid rgba(255,255,255,0.5);
}

/* ===================================================================
   DUAL RANGE SLIDER
=================================================================== */
.range-slider {
    position: relative;
    height: 55px;
    margin: 10px 0;
    background: transparent;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.range-slider input[type=range] {
    position: absolute;
    left: 0;
    top: 20px;
    width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    outline: none;
}
.range-slider input[type=range]:focus {
    outline: none;
}

/* Webkit (Chrome, Safari, Edge) slider styles */
.range-slider input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
    border: 0;
}
.range-slider input[type=range]:focus::-webkit-slider-runnable-track {
    background: rgba(255,255,255,0.5);
}
.range-slider input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--rfcc-slider-thumb-color, #0c55cc);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: all;
    position: relative;
    transition: all 0.2s ease;
}
.range-slider input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Firefox slider styles */
.range-slider input[type=range]::-moz-range-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
    border: 0;
}
.range-slider input[type=range]::-moz-range-thumb {
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--rfcc-slider-thumb-color, #0c55cc);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: all;
    -moz-appearance: none;
    margin-top: 0;
}

/* IE/Edge slider styles */
.range-slider input[type=range]::-ms-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: transparent;
    border: 0;
    color: transparent;
}
.range-slider input[type=range]::-ms-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--rfcc-slider-thumb-color, #0c55cc);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.range-slider input[type=range]::-ms-fill-lower,
.range-slider input[type=range]::-ms-fill-upper {
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
}

/* Range value labels */
.range-values {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 16px;
    pointer-events: none;
    box-sizing: border-box;
}
.value-label {
    position: absolute;
    top: 0;
    font-size: 0.75rem;
    color: #fff;
    font-weight: 600;
    background: rgba(0,0,0,0.6);
    padding: 3px 6px;
    border-radius: 3px;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    border: none;
    min-width: 40px;
    text-align: center;
    max-width: calc(100% - 10px);
    box-sizing: border-box;
}
.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #fff;
    font-weight: 500;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}
.slider-labels span {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    outline: none;
}

/* Range fill - the colored area between min and max values */
.range-fill {
    position: absolute;
    height: 4px;
    background: var(--rfcc-slider-fill-color, #0c55cc);
    border-radius: 2px;
    top: 20px;
    pointer-events: none;
    transition: all 0.1s ease;
    z-index: 1;
    left: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Base z-index for range sliders - will be dynamically managed by JavaScript */
.range-slider input[type=range]:nth-of-type(1) {
    z-index: 3;
}
.range-slider input[type=range]:nth-of-type(2) {
    z-index: 2;
}

/* Fix for range inputs that might be invisible */
.range-slider input[type=range] {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Ensure sliders are interactive and visible with correct layering */
.range-slider input[type=range]:nth-of-type(1) {
    pointer-events: all;
}
.range-slider input[type=range]:nth-of-type(2) {
    pointer-events: all;
}

/* Ensure proper slider container layout */
.range-slider {
    padding: 5px;
    margin-left: 0;
    margin-right: 0;
}

/* Ensure parent container doesn't allow overflow */
.filter-section {
    overflow: hidden;
    box-sizing: border-box;
}

/* Make sure value labels are visible and properly positioned */
.value-label {
    background: rgba(0,0,0,0.8) !important;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Ensure range fill is always visible when it should be */
.range-fill {
    min-width: 2px; /* Ensure even very small ranges show something */
}


/* ===================================================================
   Action Buttons & Grid/Table Styles
=================================================================== */

.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 16px;
}
.btn {
    -webkit-appearance: none;
    appearance: none;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    font-weight: 600;
}
.btn-primary {
    background-color: #0c55cc;
    color: #fff;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.btn-primary:hover {
    background-color: #0a4ba8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.btn-secondary {
    background-color: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}
.btn-secondary:hover {
    background-color: rgba(255,255,255,0.3);
}

.filter-results, #loading-more, .route-count, .no-routes-found {
    text-align: center;
}
.route-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    padding: 20px 0;
    width: 100%;
    box-sizing: border-box;
}
.route-item {
    background: #fff !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08) !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}
.route-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}
.route-item .map-container {
    width: 100%;
    height: 200px;
    overflow: hidden;
    border-bottom: 1px solid #eee;
}
.route-item .map-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.leaflet-map.WPLeafletMap[id^="map_for_"] {
    width: 100%;
    height: 100%;
    background-color: #e0e0e0;
}
.route-item-content {
    padding: 20px !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
}
.route-item-content h3 {
    font-size: 1.3rem !important;
    margin-top: 0 !important;
    margin-bottom: 10px !important;
    color: #333 !important;
    line-height: 1.3 !important;
    font-weight: 600 !important;
}
.route-item-content .grade-badge {
    margin-bottom: 10px;
    display: inline-block;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 20px;
    color: #fff;
}
/*.grade-badge.grade-1 { background: linear-gradient(45deg, #28a745, #20c997); }
.grade-badge.grade-2 { background: linear-gradient(45deg, #17a2b8, #6f42c1); }
.grade-badge.grade-2_5 { background: linear-gradient(45deg, #ffc107, #fd7e14); }
.grade-badge.grade-3 { background: linear-gradient(45deg, #fd7e14, #dc3545); }
.grade-badge.grade-4 { background: linear-gradient(45deg, #dc3545, #6f42c1); }
.grade-badge.grade-5 { background: linear-gradient(45deg, #6f42c1, #495057); }*/


/* Grade badges */
.grade-badge {
  display: inline-block;
  position: relative;
  min-width: 2em;
  padding: 0.2em 0.5em;
  margin-right: 0.3em;
  text-align: center;
  color: #fff;
  border-radius: 0.25em;
  font-weight: bold;
  cursor: help;
}
.grade-badge::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: inherit;
  color: #fff;
  padding: 0.4em;
  white-space: normal;
  border-radius: 0.25em;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  pointer-events: none;
  z-index: 10;
  max-width: 350px;
  min-width: 200px;
}
.grade-badge:hover::after {
  opacity: 1;
  pointer-events: auto;
}
.grade-g1 { background-color: blue; }
.grade-g2 { background-color: darkgreen; }
.grade-g2-5 { background-color: green; }
.grade-g3 { background-color: lightgreen; }
.grade-g4 { background-color: #ffbf00; }
.grade-g5 { background-color: #cc9900; }



/* Grade badges in tables (group output page) */
td .grade-badge,
table .grade-badge {
    display: inline-block !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 0.85em !important;
    font-weight: bold !important;
    color: white !important;
    margin-right: 4px !important;
    margin-bottom: 2px !important;
    position: relative !important;
    cursor: pointer !important;
}

/* Grade colors for table badges */
td .grade-g1, table .grade-g1 { background-color: blue !important; }
td .grade-g2, table .grade-g2 { background-color: darkgreen !important; }
td .grade-g2-5, table .grade-g2-5 { background-color: green !important; }
td .grade-g3, table .grade-g3 { background-color: lightgreen !important; }
td .grade-g4, table .grade-g4 { background-color: #ffbf00 !important; }
td .grade-g5, table .grade-g5 { background-color: #cc9900 !important; }

/* Tooltip styles for table badges */
td .grade-badge::after,
table .grade-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: inherit;
    color: #fff;
    padding: 0.4em;
    white-space: nowrap;
    border-radius: 0.25em;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 10;
    max-width: 350px;
    white-space: normal;
}

td .grade-badge:hover::after,
table .grade-badge:hover::after {
    opacity: 1;
    pointer-events: auto;
}

/* Club Group badges styling */
.club-group-badge {
    display: inline-block;
    position: relative;
    padding: 4px 8px;
    margin-right: 4px;
    margin-bottom: 2px;
    background-color: #0073aa;
    color: white;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: help;
    text-decoration: none;
}

.club-group-badge:hover {
    background-color: #005a87;
    color: white;
}

/* Club Group badge tooltips */
.club-group-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 0.5em;
    white-space: nowrap;
    border-radius: 0.25em;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 10;
    max-width: 350px;
    white-space: normal;
    font-size: 12px;
    font-weight: normal;
}

.club-group-badge:hover::after {
    opacity: 1;
    pointer-events: auto;
}

/* Club Group badges in tables */
td .club-group-badge,
table .club-group-badge {
    display: inline-block !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 0.85em !important;
    font-weight: bold !important;
    color: white !important;
    background-color: #0073aa !important;
    margin-right: 4px !important;
    margin-bottom: 2px !important;
    position: relative !important;
    cursor: help !important;
}

td .club-group-badge:hover,
table .club-group-badge:hover {
    background-color: #005a87 !important;
    color: white !important;
}

/* Club Group badge tooltips in tables */
td .club-group-badge::after,
table .club-group-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 0.5em;
    white-space: nowrap;
    border-radius: 0.25em;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 10;
    max-width: 350px;
    white-space: normal;
    font-size: 12px;
    font-weight: normal;
}

td .club-group-badge:hover::after,
table .club-group-badge:hover::after {
    opacity: 1;
    pointer-events: auto;
}


.route-item-content .route-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 0;
    flex-wrap: nowrap;
}
.route-item-content .stat {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    gap: 0.3rem;
    white-space: nowrap;
}
.route-item-content .stat-icon {
    font-size: 1rem;
    color: #667eea;
}
.route-item-content .stat-value {
    font-weight: 600;
    color: #555;
    font-size: 0.95rem;
}
.route-item-content p {
    font-size: 0.9rem;
    color: #777;
    line-height: 1.5;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.route-item-content .view-route-button {
    display: inline-block;
    background-color: #0c55cc;
    color: #fff;
    padding: 10px 15px;
    border-radius: 5px;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    margin-top: auto;
    transition: background-color 0.2s ease, transform 0.2s ease;
}
.route-item-content .view-route-button:hover {
    background-color: #0a4ba8;
    transform: translateY(-2px);
}
.route-grid.loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#loading-more {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}
.no-routes-found {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    background: #f9f9f9;
    border-radius: 8px;
}
.table-responsive {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.route-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.9rem;
    min-width: 700px;
    table-layout: fixed;
}
@media (max-width: 768px) {
    .route-table {
        font-size: 0.8rem;
        min-width: 600px;
    }
    .route-table th, .route-table td {
        padding: 8px 6px;
    }
    .route-table th:nth-child(1), .route-table td:nth-child(1) {
        width: 30%;
    }
    .route-table th:nth-child(4), .route-table td:nth-child(4) {
        width: 35%;
    }
    .description-text {
        font-size: 0.8rem;
    }
    .view-route-button.btn-small {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    /* Enhanced wrapping behavior on smaller screens - switch to flexbox for natural wrapping */
    .climbing-buttons,
    .route-shortcut-buttons,
    .activity-type-buttons,
    .club-group-buttons,
    .direction-buttons {
        display: flex !important;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    /* Ensure buttons have consistent sizing and can wrap naturally */
    .climbing-buttons .climbing-btn,
    .route-shortcut-buttons .route-shortcut-btn,
    .activity-type-buttons .activity-type-btn,
    .activity-type-buttons .activity-type-all-none-btn,
    .club-group-buttons .club-group-btn,
    .club-group-buttons .club-group-all-none-btn,
    .direction-buttons .direction-btn,
    .direction-buttons .direction-all-none-btn {
        flex: 0 0 auto;
        min-width: 60px;
    }
}

/* Fix for table view search box */
#route-table-search {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.85rem;
    box-sizing: border-box;
}
#route-table-search::placeholder {
    color: rgba(255, 255, 255, 0.7);
}


/* target only the "area" under the slope chart */
.elevation-control .profile-slope .area {
  fill: url(#linearGradient) !important;
}

/* ===================================================================
   Leaflet Map Control Fixes
=================================================================== */

/* Fix zoom control button text rendering to prevent double-line appearance */
.leaflet-control-zoom a {
    text-decoration: none !important;
    line-height: 26px !important;
    text-align: center !important;
    display: block !important;
}

/* Ensure zoom button icons render correctly */
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    position: relative !important;
}

/* Remove any pseudo-elements that might create double lines */
.leaflet-control-zoom-in::before,
.leaflet-control-zoom-in::after,
.leaflet-control-zoom-out::before,
.leaflet-control-zoom-out::after {
    content: none !important;
}

/* Reset button styling - matches Leaflet controls */
.leaflet-control-reset {
    margin-top: 10px !important;
}

.leaflet-control-reset-button {
    display: block !important;
    width: 26px;
    height: 26px;
    line-height: 26px !important;
    text-align: center !important;
    text-decoration: none !important;
    font-size: 18px !important;
    font-weight: bold !important;
    color: #333 !important;
    background: #fff !important;
    border-bottom: 1px solid #ccc !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, color 0.2s ease !important;
}

.leaflet-control-reset-button:hover {
    background: #f4f4f4 !important;
    color: #000 !important;
}

.leaflet-control-reset-button:last-child {
    border-bottom: none !important;
    border-bottom-left-radius: 4px !important;
    border-bottom-right-radius: 4px !important;
}

/* Dark mode support for reset button */
.rf-dark-mode .leaflet-control-reset-button,
[data-rf-theme="dark"] .leaflet-control-reset-button {
    background-color: rgba(42, 42, 42, 0.95) !important;
    color: #e0e0e0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.rf-dark-mode .leaflet-control-reset-button:hover,
[data-rf-theme="dark"] .leaflet-control-reset-button:hover {
    background-color: rgba(60, 60, 60, 0.95) !important;
    color: #ffffff !important;
}

/* ===================================================================
   Map Attribution Styling - Full Attributions with Smaller Text & Transparency
=================================================================== */

/* Standard attribution control styling - more transparent, smaller text, full attribution display */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.5) !important;
    color: #333 !important;
    font-size: 0.7rem !important;
    line-height: 1.3 !important;
    padding: 2px 5px !important;
    border-radius: 3px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
}

/* Attribution links styling */
.leaflet-control-attribution a {
    color: #0078a8 !important;
    text-decoration: none !important;
    font-size: 0.7rem !important;
}

.leaflet-control-attribution a:hover {
    text-decoration: underline !important;
    color: #005a78 !important;
}

/* Attribution prefix (Leaflet link) styling */
.leaflet-control-attribution .leaflet-control-attribution-flag {
    display: inline !important;
    font-size: 0.7rem !important;
}

/* Specific styling for mini maps - even smaller and more transparent */
.route-item .leaflet-control-attribution,
.route-grid .leaflet-control-attribution,
#routes-map .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.4) !important;
    font-size: 0.6rem !important;
    padding: 1px 3px !important;
    line-height: 1.2 !important;
}

.route-item .leaflet-control-attribution a,
.route-grid .leaflet-control-attribution a,
#routes-map .leaflet-control-attribution a {
    font-size: 0.6rem !important;
}

/* Group maps and large maps - slightly larger but still transparent */
.leaflet-map-wrapper .leaflet-control-attribution,
.group-route-view .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.55) !important;
    font-size: 0.75rem !important;
    padding: 3px 6px !important;
    line-height: 1.3 !important;
}

.leaflet-map-wrapper .leaflet-control-attribution a,
.group-route-view .leaflet-control-attribution a {
    font-size: 0.75rem !important;
}

/* Make sure attribution doesn't interfere with other controls */
.leaflet-control-attribution {
    z-index: 1000 !important;
    max-width: 80% !important; /* Allow more space for full attribution text */
    word-wrap: break-word !important;
    white-space: normal !important; /* Allow wrapping for long attributions */
    overflow: visible !important;
}

/* On very small screens, make attribution even more compact */
@media (max-width: 480px) {
    .leaflet-control-attribution {
        font-size: 0.55rem !important;
        padding: 1px 3px !important;
        max-width: 75% !important; /* Allow more space on mobile too */
        line-height: 1.2 !important;
    }
    
    .leaflet-control-attribution a {
        font-size: 0.55rem !important;
    }
    
    /* Mini maps on mobile */
    .route-item .leaflet-control-attribution,
    .route-grid .leaflet-control-attribution {
        font-size: 0.5rem !important;
        padding: 1px 2px !important;
        line-height: 1.1 !important;
    }
    
    .route-item .leaflet-control-attribution a,
    .route-grid .leaflet-control-attribution a {
        font-size: 0.5rem !important;
    }
}
