:root {
    --brand-green: #3d6b35;
    --brand-orange: #d95a2b;
    --brand-bg: #e8e4dc;
    --topbar-height: 64px;
    --mobile-panel-width: min(92vw, 420px);
}

body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

.material-symbols-outlined { 
    vertical-align: middle;
    user-select: none;
}

#map { 
    height: 100%; 
    min-height: 400px;
    border-radius: 8px;
}

/* New layout styles */
.main-container {
    display: flex;
    height: calc(100vh - var(--topbar-height)); /* Full viewport height minus compact header */
}

.left-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 300px; /* Prevent it from getting too small */
}

.resizer {
    flex: 0 0 10px;
    background: #f1f1f1;
    cursor: col-resize;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
}

.right-panel {
    flex: 0 0 420px; /* Wider sidebar to avoid wrapping */
    max-width: 480px;
    overflow-y: auto;
    padding-left: 10px;
    min-width: 320px; /* Prevent it from getting too small */
}

.map-container {
    /* Take up most of the space in the left panel */
    position: relative; /* This is crucial for positioning the spinner inside it */
    flex-grow: 1;
}

.elevation-chart {
    /* Fixed height, does not grow or shrink */
    flex-shrink: 0;
    height: 150px;
    border-radius: 8px;
}

.waypoint-item {
    transition: all 0.2s;
    cursor: pointer;
    padding: 0.5rem !important; /* Make waypoint items more compact */
}

.waypoint-item:hover {
    background-color: #f8f9fa;
    transform: translateX(3px);
}

/* While any suggest dropdown is open, freeze all waypoint items so the
   dropdown doesn't fight with the hover zone of the item below it. */
#waypointsList.has-open-dropdown .waypoint-item {
    pointer-events: none;
    transform: none;
}
/* Re-enable interaction for the dropdown menu itself (absolutely positioned). */
#waypointsList.has-open-dropdown .dropdown-menu {
    pointer-events: auto;
}

.waypoint-item.drag-over {
    background-color: #eef6ff;
    border-left: 3px solid #0d6efd;
}

.waypoint-item.dragging {
    opacity: 0.6;
}

.waypoint-item.active {
    background-color: #e7f3ff;
    border-left: 3px solid #0d6efd;
}

/* Make waypoint icons smaller */
.waypoint-item .material-symbols-outlined {
    font-size: 16px;
}

/* Make waypoint badges smaller */
.waypoint-item .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
}

/* Make waypoint input smaller */
.waypoint-item h6 {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.waypoint-item small {
    font-size: 0.75rem;
}

/* Fetching indicator on the waypoint name input */
.waypoint-name-input.name-fetching {
    border-color: #0d6efd;
    color: transparent;
    background-image: linear-gradient(90deg, #0d6efd 0%, #6ea8fe 50%, #0d6efd 100%);
    background-size: 200% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    animation: name-fetch-pulse 1.4s ease-in-out infinite;
}
.waypoint-name-input.name-fetching::placeholder {
    color: #0d6efd;
    opacity: 0.7;
}
@keyframes name-fetch-pulse {
    0%   { border-color: #0d6efd; }
    50%  { border-color: #6ea8fe; }
    100% { border-color: #0d6efd; }
}

/* Visibility badge in topbar */
.visibility-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.25);
    white-space: nowrap;
}
.visibility-badge .material-symbols-outlined {
    font-size: 0.95em;
}
.visibility-private {
    background: rgba(255,255,255,0.12);
    color: #ced4da;
}
.visibility-shared {
    background: rgba(13,110,253,0.25);
    color: #8bb8fd;
    border-color: rgba(13,110,253,0.4);
}
.visibility-public {
    background: rgba(25,135,84,0.3);
    color: #75d4a0;
    border-color: rgba(25,135,84,0.5);
}
.visibility-edited {
    background: rgba(255,193,7,0.2);
    color: #ffc107;
    border-color: rgba(255,193,7,0.5);
}

/* Publish modal checklist */
.publish-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.publish-check {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: #495057;
}
.publish-check-icon {
    font-size: 1.1em;
    color: #adb5bd;
}
.publish-check-pass .publish-check-icon { color: #198754; }
.publish-check-fail .publish-check-icon { color: #dc3545; }
.publish-check-manual .publish-check-icon { color: #6c757d; }

/* Visibility badges in route list */
.route-vis-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}
.route-vis-badge .material-symbols-outlined { font-size: 0.85em; }
.route-vis-private { background: #f1f3f5; color: #6c757d; }
.route-vis-shared   { background: #e7f1ff; color: #0d6efd; }
.route-vis-public   { background: #d1e7dd; color: #198754; }

/* Route cards used in My Routes and Discover modals */
.routes-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.route-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
}
.route-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1;
}
.route-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.route-card-meta {
    font-size: 0.78rem;
    color: #6c757d;
}
.route-card-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* My Routes modal tabs */
#myRoutesModal .nav-tabs {
    border-bottom: 1px solid #dee2e6;
}
.discover-vote-score {
    font-size: 0.82rem;
    font-weight: 600;
    color: #495057;
    min-width: 1.5rem;
    text-align: right;
}

#cloudVisFilter .btn.active {
    background: var(--brand-green);
    border-color: var(--brand-green);
    color: #fff;
}

/* Make buttons in waypoint items more compact */
.waypoint-item .btn-icon {
    padding: 0.1rem 0.3rem;
}

.waypoint-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
}

.waypoint-actions .btn-icon {
    flex: 0 0 auto;
}

.rest-compact {
    color: #ffc107;
    font-weight: 600;
}

.waypoint-actions .rest-btn.active {
    background: #ffc107;
    border-color: #ffc107;
    color: #000;
}

.waypoint-actions .notes-btn.active {
    background: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

.btn-icon {
    padding: 0.25rem 0.5rem;
}

.navbar-compact {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.navbar-compact .navbar-brand {
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-compact .material-symbols-outlined {
    font-size: 20px;
}

.navbar-branding {
    background-color: var(--brand-bg);
}

.navbar {
    position: relative;
    z-index: 1030;
}

.navbar-branding .navbar-brand {
    color: var(--brand-green);
}

.brand-logo {
    height: 30px;
    width: auto;
    display: inline-block;
}

.brand-text {
    font-family: 'Arvo', serif;
    font-size: 1.15rem;
    line-height: 1;
    letter-spacing: 0.2px;
}

.brand-route {
    color: var(--brand-green);
    font-weight: 700;
}

.brand-card {
    color: var(--brand-orange);
    font-weight: 700;
}

.brand-maker {
    color: var(--brand-green);
    font-weight: 600;
}

.topbar-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-hamburger {
    display: none;
}

.auth-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.auth-avatar {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-block;
    object-fit: cover;
}

.auth-avatar-fallback {
    font-size: 20px;
}


.topbar-input {
    width: 160px;
}

.topbar-btn {
    min-height: 30px;
    padding: 0.25rem 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    line-height: 1;
    white-space: nowrap;
    border-color: var(--brand-green);
    color: var(--brand-green);
}

.topbar-btn:hover,
.topbar-btn:focus-visible {
    background-color: var(--brand-green);
    color: #fff;
}

.topbar-btn .material-symbols-outlined {
    font-size: 18px;
}

.modal-header .btn-close {
    background-color: rgba(255, 255, 255, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    opacity: 1;
}

.modal-header .btn-close:hover {
    background-color: rgba(255, 255, 255, 0.6);
}

.modal-close-btn {
    border: 2px solid #0d6efd;
    color: #0d6efd;
    background-color: #eaf2ff;
}

.modal-close-btn:hover {
    background-color: #d8e9ff;
    color: #0b5ed7;
}

.weather-chart {
    min-height: 320px;
    width: 100%;
}

.weather-select {
    max-width: 320px;
}

.weather-summary {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.weather-summary .summary-card {
    background: #f8f9fb;
    border: 1px solid rgba(13, 110, 253, 0.15);
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    color: #223;
}

.weather-summary .summary-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6c757d;
}

.weather-summary .summary-values {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.weather-summary .summary-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
}

.speed-input {
    width: 80px;
}

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
}

canvas {
    border-radius: 8px;
}

/* Add a class for the crosshair cursor */
.crosshair-cursor {
    cursor: crosshair;
}

/* Style for inline waypoint name input */
.waypoint-name-input {
    width: 60%;
}

/* Remove inline styles from buttons */
#routeName {
    width: 160px;
}

/* Collapsible header styles */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
}

/* Hide the open icon by default, show closed icon */
.collapsible-header .collapse-icon-open {
    display: none;
}

.collapsible-header .collapse-icon-closed {
    display: inline-block;
}

/* When the collapse is NOT collapsed (i.e., expanded), show open icon and hide closed icon */
.collapsible-header:not(.collapsed) .collapse-icon-open {
    display: inline-block;
}

.collapsible-header:not(.collapsed) .collapse-icon-closed {
    display: none;
}

/* Make cards in right panel more compact */
.right-panel .card {
    margin-bottom: 0.75rem !important;
}

.right-panel .card-body {
    padding: 0.75rem;
}

.right-panel .card-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* Make the settings form more compact */
#settingsCollapse .row {
    margin-top: 0.5rem !important;
}

#settingsCollapse .form-label {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

#settingsCollapse .form-control {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.settings-inline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.settings-inline-row .distance-toggle {
    margin-bottom: 0;
    flex: 1 1 auto;
}

.settings-inline-row .lock-toggle {
    flex: 0 0 auto;
}
/* Make summary card more compact */
.summary-card .card-body {
    padding: 0.45rem 0.6rem;
}

.summary-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0;
}

.summary-card small {
    font-size: 0.75rem;
}

.summary-card .row {
    align-items: center;
}

.summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.25rem;
}

.summary-header .card-title {
    margin-bottom: 0;
}

.summary-weather {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #ffffff;
    text-align: right;
}

.summary-weather-icon {
    width: 20px;
    height: 20px;
}

.summary-weather-wind {
    color: #f8f9fa;
    font-size: 0.75rem;
}

.summary-warning-icon {
    color: #ffc107;
    font-size: 18px;
}

.collapsible-header {
    align-items: center;
}
.lock-toggle {
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    border-color: transparent;
}

.lock-toggle.btn-outline-secondary:hover,
.lock-toggle.btn-outline-secondary:focus-visible {
    background-color: transparent !important;
    border-color: transparent !important;
    color: inherit !important;
    box-shadow: none !important;
}

.lock-toggle .material-symbols-outlined {
    font-size: 18px;
}

.lock-toggle.locked {
    color: #dc3545;
    border-color: transparent;
    background-color: transparent;
}

.cloud-toggle.cloud-on {
    color: #0dcaf0;
}

.cloud-toggle.btn-outline-secondary:hover,
.cloud-toggle.btn-outline-secondary:focus-visible {
    background-color: transparent !important;
    border-color: transparent !important;
    color: inherit !important;
    box-shadow: none !important;
}

.cloud-toggle.cloud-on:hover,
.cloud-toggle.cloud-on:focus-visible {
    background-color: rgba(13, 202, 240, 0.12);
    border-color: rgba(13, 202, 240, 0.6);
    color: #0dcaf0;
}

.distance-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.distance-toggle .form-check-input {
    cursor: pointer;
}

.distance-toggle .form-check-label {
    font-weight: 600;
    color: #344054;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.distance-toggle .distance-label {
    padding: 0.1rem 0.3rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.distance-toggle .distance-divider {
    color: #98a2b3;
}

.distance-toggle .form-check-input:checked ~ .form-check-label .distance-label-mi {
    background: rgba(13, 202, 240, 0.18);
    color: #0b6e7e;
}

.distance-toggle .form-check-input:not(:checked) ~ .form-check-label .distance-label-km {
    background: rgba(61, 107, 53, 0.12);
    color: #2b5a2f;
}

.settings-divider {
    width: 1px;
    height: 28px;
    background: rgba(13, 110, 253, 0.25);
}

#viewMenuBtn.has-route {
    background-color: var(--brand-orange);
    border-color: var(--brand-orange);
    color: #fff;
    animation: gentle-pulse 2.2s ease-in-out infinite;
}

#viewMenuBtn.has-route:hover {
    background-color: #c64d23;
    border-color: #c64d23;
}

#viewMenuBtn.has-route .material-symbols-outlined {
    color: #fff;
}

@keyframes gentle-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 90, 43, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(217, 90, 43, 0); }
}

.waypoint-badge {
    background-color: #d6f3ff;
    color: #0b5ed7;
    border: 1px solid rgba(13, 110, 253, 0.4);
}

.mobile-map-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1002;
}

.mobile-panel-btn {
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
}

.mobile-panel-btn.active {
    background-color: var(--brand-green);
    border-color: var(--brand-green);
    color: #fff;
}

.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 40, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1030;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.panel-close {
    border-radius: 999px;
    padding: 0.1rem 0.4rem;
    display: none;
}

.panel-close .material-symbols-outlined {
    font-size: 18px;
}

.mobile-panel-topbar {
    display: none;
    justify-content: flex-end;
    padding: 0.25rem 0.25rem 0.5rem;
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 1;
}

body.mobile-panel-open .mobile-overlay {
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 901px) {
    #topbarMenu.collapse {
        display: flex !important;
        height: auto !important;
        visibility: visible;
    }

    .topbar-hamburger {
        display: none;
    }
}

@media (max-width: 900px) {
    .topbar-hamburger {
        display: inline-flex;
    }

    .topbar-controls {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        margin-top: 0.5rem;
        padding: 0.75rem;
        background: var(--brand-bg);
        border-radius: 12px;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
    }

    .topbar-controls .btn-group,
    .topbar-controls .dropdown {
        width: 100%;
    }

    .topbar-controls .topbar-btn {
        width: 100%;
        justify-content: space-between;
    }

    .main-container {
        height: calc(100vh - var(--topbar-height));
    }

    .resizer {
        display: none;
    }

    .right-panel {
        display: none;
        padding-left: 0;
        min-width: 0;
    }

    .elevation-panel {
        display: none;
    }

    .mobile-map-controls {
        display: flex;
    }

    body.mobile-waypoints-open .right-panel {
        display: block;
        position: fixed;
        top: var(--topbar-height);
        right: 0;
        bottom: 0;
        width: var(--mobile-panel-width);
        max-width: 100%;
        background: #f8f9fa;
        z-index: 1040;
        padding: 0.75rem;
        overflow-y: auto;
        box-shadow: -12px 0 24px rgba(15, 23, 42, 0.18);
    }

    .mobile-panel-topbar {
        display: flex;
    }

    body.mobile-elevation-open .elevation-panel {
        display: block;
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 12px;
        height: 220px;
        z-index: 1040;
        box-shadow: 0 12px 28px rgba(15, 23, 42, 0.2);
    }

    .panel-close {
        display: inline-flex;
    }
}
