body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background-color: #0f172a; /* Slate 900 */
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar styling */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease, left 0.3s ease;
    z-index: 2000;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .speed-control-sidebar input,
.sidebar.collapsed .sidebar-divider,
.sidebar.collapsed .search-container-sidebar input {
    display: none;
}

.sidebar.collapsed .search-container-sidebar {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    justify-content: center;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 20px 10px;
}

.sidebar.collapsed .logo span {
    display: none;
}

.sidebar.collapsed .sidebar-btn {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .sidebar-btn i {
    margin-right: 0;
}

/* Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    gap: 12px;
}

.logo i {
    color: #3b82f6;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
}

.toggle-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Content Area */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
}

/* Custom Scrollbar for sidebar */
.sidebar-content::-webkit-scrollbar { width: 6px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
.sidebar-content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Sections */
.sidebar-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 12px;
    padding: 0 8px;
}

/* Buttons */
.sidebar-btn {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 6px;
    font-family: inherit;
}

.sidebar-btn i {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.sidebar-btn.active {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.sidebar-btn.active i {
    color: #3b82f6;
    opacity: 1;
}

/* Button Variants */
.btn-primary { background: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.btn-primary:hover { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.btn-primary i { color: #60a5fa; }

.btn-warning { background: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.btn-warning:hover { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.btn-warning i { color: #fbbf24; }

.btn-danger { background: rgba(239, 68, 68, 0.1); color: #f87171; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.btn-danger i { color: #f87171; }

.btn-outline-success { border: 1px solid rgba(16, 185, 129, 0.2); color: #34d399; }
.btn-outline-success:hover { background: rgba(16, 185, 129, 0.1); }
.btn-outline-success i { color: #34d399; }

.btn-outline-danger { border: 1px solid rgba(239, 68, 68, 0.2); color: #f87171; }
.btn-outline-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-outline-danger i { color: #f87171; }

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 16px 8px;
}

/* Search Container Sidebar */
.search-container-sidebar {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 4px 12px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.search-container-sidebar:focus-within {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-container-sidebar input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 13px;
    padding: 8px 0;
    outline: none;
    width: 100%;
}

.search-container-sidebar input::placeholder {
    color: #64748b;
}

.search-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover { color: #cbd5e1; }

.hidden { display: none !important; }
.search-loading { margin-right: 8px; }

/* Photon Autocomplete Custom Styling */
.photon-container {
    background-color: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #cbd5e1;
    margin-top: 4px;
    padding: 4px 0;
    max-height: 250px;
    overflow-y: auto;
    z-index: 9999;
}

.photon-container::-webkit-scrollbar { width: 4px; }
.photon-container::-webkit-scrollbar-track { background: transparent; }
.photon-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.photon-item {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.photon-item:hover, .photon-item.selected {
    background-color: rgba(59, 130, 246, 0.15);
}

.photon-item-name {
    color: #f8fafc;
    font-weight: 600;
    font-size: 14px;
}

.photon-item-context {
    color: #94a3b8;
    font-size: 12px;
}

.photon-no-results {
    padding: 12px 16px;
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    font-style: italic;
}

/* Saved Routes Presets */
.save-route-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.route-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    padding: 10px 12px;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.route-input:focus {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.route-input::placeholder {
    color: #64748b;
}

.sidebar.collapsed .route-input {
    display: none;
}

.saved-routes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.saved-routes-list::-webkit-scrollbar { width: 4px; }
.saved-routes-list::-webkit-scrollbar-track { background: transparent; }
.saved-routes-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.route-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.route-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.route-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.route-card-name {
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.route-card-points {
    font-size: 11px;
    color: #64748b;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
}

.route-card-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.route-action-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.route-action-btn i {
    width: 14px;
    height: 14px;
}

.route-action-btn.btn-load:hover { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.route-action-btn.btn-rename:hover { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.route-action-btn.btn-delete:hover { background: rgba(239, 68, 68, 0.2); color: #f87171; }

.sidebar.collapsed .route-card {
    padding: 8px 4px;
    align-items: center;
}

.sidebar.collapsed .route-card-name,
.sidebar.collapsed .route-card-points,
.sidebar.collapsed .btn-rename,
.sidebar.collapsed .btn-delete {
    display: none;
}

.sidebar.collapsed .route-card-actions {
    justify-content: center;
}

/* Speed Control Sidebar */
.speed-control-sidebar {
    padding: 12px 8px;
}

.speed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 12px;
}

.speed-header label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speed-header label i {
    color: #eab308;
}

#speed-display {
    color: #3b82f6;
    font-weight: 600;
}

#speed-slider {
    width: 100%;
    accent-color: #3b82f6;
    cursor: pointer;
}

/* Main Map Area */
.map-container {
    flex: 1;
    position: relative;
    height: 100vh;
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Info Dashboard Panel */
.info-panel {
    position: absolute;
    top: 24px;
    right: 24px; /* Moved to right since sidebar is on left */
    z-index: 1000;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    width: 220px;
    color: #f8fafc;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-row:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.info-label {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.info-value {
    font-size: 14px;
    font-weight: 600;
}

.status-idle { color: #94a3b8; }
.status-running { color: #34d399; }
.status-paused { color: #fbbf24; }

/* Custom Current Location Marker */
.current-loc-icon { background: transparent; border: none; }
.current-loc-pin {
    width: 28px;
    height: 28px;
    background: #10b981;
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.6);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.current-loc-pin::after {
    content: ''; width: 8px; height: 8px; background: #fff; border-radius: 50%;
}

/* Numbered Route Markers */
.numbered-marker-icon { background: transparent; border: none; }
.numbered-pin {
    width: 28px;
    height: 28px;
    background: #1e293b;
    color: #ffffff;
    border: 2px solid #ec4899;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 4px 8px rgba(0,0,0,0.25);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    line-height: 1;
}

/* Live Tracker Marker */
.tracker-icon { background: transparent; border: none; }
.tracker-dot {
    width: 16px; height: 16px; background: #3b82f6; border: 3px solid #ffffff; border-radius: 50%;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.8); position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); z-index: 2;
}
.tracker-pulse {
    width: 32px; height: 32px; background: rgba(59, 130, 246, 0.3); border-radius: 50%;
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    animation: pulse 1.5s infinite ease-out; z-index: 1;
}

@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Leaflet Layer Control Styling */
.leaflet-control-layers {
    background: rgba(15, 23, 42, 0.85) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    color: #f8fafc !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}

.leaflet-control-layers-expanded {
    padding: 10px 14px !important;
}

.leaflet-control-layers-base label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    cursor: pointer;
}

.leaflet-control-layers-base label:last-child {
    margin-bottom: 0;
}

.leaflet-control-layers-selector {
    accent-color: #3b82f6;
    margin-top: 0 !important;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        position: relative;
    }
    
    .sidebar {
        position: absolute;
        height: 100%;
        left: -280px; /* Hidden by default on mobile */
    }
    
    .sidebar.mobile-open {
        left: 0;
    }

    /* Need a mobile hamburger to open sidebar if it's hidden */
    .mobile-nav-toggle {
        display: flex;
        position: absolute;
        top: 20px;
        left: 20px;
        z-index: 1500;
        background: #0f172a;
        color: white;
        border: none;
        padding: 10px;
        border-radius: 8px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    
    .info-panel {
        top: auto;
        bottom: 24px;
        right: 24px;
        width: calc(100vw - 48px);
        padding: 16px;
    }
    
    /* Hide the normal toggle button inside sidebar on mobile since we use off-canvas */
    .toggle-btn {
        display: none;
    }
}

/* Hide mobile toggle on desktop */
@media (min-width: 769px) {
    .mobile-nav-toggle {
        display: none;
    }
}
