/* ============================================
   Route Planner Panel
   ============================================ */
.route-planner {
    position: absolute;
    top: 90px;
    left: 16px;
    z-index: 1000;
    width: 380px;
    max-width: calc(100% - 32px);
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.18);
    overflow: visible;
    backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.route-planner.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.route-planner-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    cursor: pointer;
    user-select: none;
}

.route-planner-icon {
    font-size: 1.125rem;
}

.route-planner-title {
    flex: 1;
    font-weight: 700;
    font-size: 0.9375rem;
    color: #1a1a2e;
    font-family: var(--font-family);
}

.route-planner-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    font-size: 0.875rem;
    padding: 4px;
    transition: transform var(--transition-fast);
}

.route-planner.collapsed .route-planner-toggle {
    transform: rotate(-90deg);
}

.route-planner-body {
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: max-height var(--transition-base), opacity var(--transition-fast);
    overflow: hidden;
}

.route-planner.collapsed .route-planner-body {
    max-height: 0;
    opacity: 0;
    padding: 0 16px;
}

/* ============================================
   Input Rows — Start & Finish
   ============================================ */
.route-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.route-input-icon {
    font-size: 0.875rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.route-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f0f2f5;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    overflow: hidden;
}

.route-input-wrap:focus-within {
    border-color: var(--color-accent-primary);
    background: #fff;
}

.route-input {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: #1a1a2e;
    outline: none;
    min-width: 0;
}

.route-input::placeholder {
    color: #999;
}

.route-input-clear {
    padding: 4px 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: #bbb;
    font-size: 1.125rem;
    display: none;
    transition: color var(--transition-fast);
}

.route-input-clear.visible {
    display: block;
}

.route-input-clear:hover {
    color: #666;
}

/* GPS Button */
.route-gps-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: 2px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-sm);
    background: rgba(99, 102, 241, 0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.route-gps-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: var(--color-accent-primary);
}

.route-gps-btn.loading {
    animation: pulse-gps 1s ease-in-out infinite;
}

@keyframes pulse-gps {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ============================================
   Swap Row
   ============================================ */
.route-swap-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 0 8px;
    height: 20px;
}

.route-connector {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
}

.route-swap-btn {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: #666;
    transition: all var(--transition-fast);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.route-swap-btn:hover {
    background: var(--color-accent-primary);
    color: #fff;
    border-color: var(--color-accent-primary);
    transform: rotate(180deg);
}

/* ============================================
   Vehicle Selector
   ============================================ */
.vehicle-selector {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.vehicle-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-sm);
    background: #f8f9fb;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
}

.vehicle-btn:hover {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.05);
}

.vehicle-btn.active {
    border-color: var(--color-accent-primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.vehicle-icon {
    font-size: 1.25rem;
}

.vehicle-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.vehicle-btn.active .vehicle-label {
    color: var(--color-accent-primary);
}

/* ============================================
   Search Route Button
   ============================================ */
.route-search-btn {
    margin-top: 8px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--gradient-primary);
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: var(--font-family);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.route-search-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.route-search-btn:active {
    transform: translateY(0);
}

.route-search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   Search Results Dropdown
   ============================================ */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    max-height: 280px;
    overflow-y: auto;
    display: none;
    z-index: 1001;
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: background var(--transition-fast);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

.result-icon {
    color: var(--color-accent-primary);
    font-size: 1.125rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.result-text {
    flex: 1;
    min-width: 0;
}

.result-name {
    font-weight: 600;
    color: #1a1a2e;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-address {
    color: #666;
    font-size: 0.75rem;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-loading {
    padding: 16px;
    text-align: center;
    color: #666;
    font-size: 0.8125rem;
}

/* ============================================
   Route Info Bar
   ============================================ */
.route-info {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background: var(--color-bg-glass);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-lg);
    padding: 16px 24px;
    display: none;
    align-items: center;
    gap: 20px;
    color: var(--color-text-primary);
    max-width: calc(100% - 32px);
}

.route-info.active {
    display: flex;
}

.route-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.route-stat-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text-primary);
}

.route-stat-label {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.route-divider {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
}

.route-clear {
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: var(--font-family);
    font-weight: 600;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.route-clear:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* ============================================
   Traffic Badge
   ============================================ */
.route-traffic-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 700;
    font-family: var(--font-family);
    white-space: nowrap;
}

.traffic-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Traffic Levels */
.route-traffic-badge.lancar {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.route-traffic-badge.lancar .traffic-dot {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.route-traffic-badge.lancar .traffic-text {
    color: #10b981;
}

.route-traffic-badge.ramai {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.route-traffic-badge.ramai .traffic-dot {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.route-traffic-badge.ramai .traffic-text {
    color: #f59e0b;
}

.route-traffic-badge.macet {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.route-traffic-badge.macet .traffic-dot {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
    animation: pulse-traffic 1.5s ease-in-out infinite;
}

.route-traffic-badge.macet .traffic-text {
    color: #ef4444;
}

@keyframes pulse-traffic {

    0%,
    100% {
        box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
    }

    50% {
        box-shadow: 0 0 14px rgba(239, 68, 68, 0.9);
    }
}

/* ============================================
   Route Alt Buttons
   ============================================ */
.route-alts {
    display: flex;
    gap: 6px;
}

.route-alt-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-family: var(--font-family);
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.route-alt-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.route-alt-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.5);
    color: var(--color-accent-primary);
}

/* ============================================
   Highlighted CCTV Markers (on route)
   ============================================ */
.cctv-marker.on-route {
    background: linear-gradient(135deg, #10b981, #34d399);
    box-shadow: 0 2px 16px rgba(16, 185, 129, 0.6);
    animation: pulse-route 2s ease-in-out infinite;
}

@keyframes pulse-route {

    0%,
    100% {
        box-shadow: 0 2px 16px rgba(16, 185, 129, 0.6);
    }

    50% {
        box-shadow: 0 2px 24px rgba(16, 185, 129, 0.9);
    }
}

/* Start marker */
.start-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #10b981, #34d399);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.5);
}

.start-marker-inner {
    transform: rotate(45deg);
    font-size: 16px;
    line-height: 1;
}

/* Destination marker */
.destination-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #ef4444, #f97316);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.5);
}

.destination-marker-inner {
    transform: rotate(45deg);
    font-size: 16px;
    line-height: 1;
}

/* Route line traffic colors */
.route-line-lancar {
    stroke: #10b981;
}

.route-line-ramai {
    stroke: #f59e0b;
}

.route-line-macet {
    stroke: #ef4444;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .route-planner {
        width: calc(100% - 32px);
        top: 86px;
    }

    .route-info {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 16px;
        bottom: calc(20px + env(safe-area-inset-bottom));
        justify-content: center;
        max-width: calc(100% - 24px);
        left: 50%;
        transform: translateX(-50%);
        z-index: 2000;
    }

    .route-divider {
        display: none;
    }
}

@media (max-width: 480px) {
    .route-input {
        padding: 8px 10px;
        font-size: 0.8125rem;
    }

    .route-stat-value {
        font-size: 1rem;
    }

    .vehicle-label {
        font-size: 0.625rem;
    }

    .route-search-btn {
        padding: 10px;
        font-size: 0.875rem;
    }
}