* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    margin-bottom: 10px;
    font-size: 2.2em;
}

.last-update {
    font-size: 0.9em;
    opacity: 0.9;
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.map-container {
    height: 500px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    background-color: #f0f0f0; /* Add background color to see if container is there */
}

#map {
    width: 100%;
    height: 100%;
    min-height: 500px; /* Ensure minimum height */
}

.car-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.car-card {
    flex: 1;
}

.car-card h3 {
    font-size: 1.5em;
    margin-bottom: 15px;
    color: #333;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 5px 0;
}

.label {
    font-weight: 600;
    color: #666;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-idle {
    background: #fff3cd;
    color: #856404;
}

.status-maintenance {
    background: #f8d7da;
    color: #721c24;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    background: #007bff;
    color: white;
    transition: all 0.3s ease;
}

.btn:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.telemetry-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 15px;
}

.telemetry-card h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.1em;
}

.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.telemetry-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.telemetry-label {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 5px;
}

.telemetry-value {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

/* Warning indicators */
.warning.low {
    background: #ffebee;
    border-color: #f44336;
    color: #c62828;
}

.warning.medium {
    background: #fff8e1;
    border-color: #ff9800;
    color: #e65100;
}

.warning.high {
    background: #ffebee;
    border-color: #f44336;
    color: #c62828;
}

.normal {
    background: #e8f5e8;
    border-color: #4caf50;
    color: #2e7d32;
}

/* Custom car marker styles */
.custom-car-icon {
    background: none !important;
    border: none !important;
}

.car-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4));
    transition: all 0.3s ease;
    cursor: pointer;
}

.car-marker:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
}

.car-marker i {
    transition: all 0.3s ease;
}

/* Status-specific animations */
.car-marker.active i {
    animation: pulse-green 2s ease-in-out infinite;
}

.car-marker.idle i {
    opacity: 0.9;
    animation: gentle-bounce 3s ease-in-out infinite;
}

.car-marker.maintenance i {
    animation: shake-red 1.5s ease-in-out infinite;
}

.car-label {
    font-size: 9px;
    font-weight: bold;
    color: #333;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 3px;
    text-shadow: none;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.car-marker:hover .car-label {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

/* Status-specific label colors */
.car-marker.active .car-label {
    border-left: 3px solid #4CAF50;
}

.car-marker.idle .car-label {
    border-left: 3px solid #FF9800;
}

.car-marker.maintenance .car-label {
    border-left: 3px solid #F44336;
}

/* Custom pedestrian marker styles */
.custom-pedestrian-icon {
    background: none !important;
    border: none !important;
}

.pedestrian-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4));
    transition: all 0.3s ease;
    cursor: pointer;
}

.pedestrian-marker:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.6));
}

.pedestrian-marker i {
    transition: all 0.3s ease;
}

/* Status-specific animations for pedestrians */
.pedestrian-marker.moving i {
    animation: walk-animation 1.5s ease-in-out infinite;
}

.pedestrian-marker.idle i {
    opacity: 0.9;
    animation: gentle-bounce 3s ease-in-out infinite;
}

.pedestrian-marker.maintenance i {
    animation: shake-red 1.5s ease-in-out infinite;
}

.pedestrian-label {
    font-size: 9px;
    font-weight: bold;
    color: #333;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 3px;
    text-shadow: none;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.pedestrian-marker:hover .pedestrian-label {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

/* Status-specific label colors for pedestrians */
.pedestrian-marker.moving .pedestrian-label {
    border-left: 3px solid #2E8B57;
}

.pedestrian-marker.idle .pedestrian-label {
    border-left: 3px solid #FF9800;
}

.pedestrian-marker.maintenance .pedestrian-label {
    border-left: 3px solid #F44336;
}

/* Walking animation for active pedestrians */
@keyframes walk-animation {
    0%, 100% { 
        transform: scale(1) rotate(-2deg); 
        opacity: 1; 
    }
    25% { 
        transform: scale(1.05) rotate(2deg); 
        opacity: 0.9; 
    }
    50% { 
        transform: scale(1.1) rotate(-1deg); 
        opacity: 0.8; 
    }
    75% { 
        transform: scale(1.05) rotate(1deg); 
        opacity: 0.9; 
    }
}

/* Animations */
@keyframes pulse-green {
    0%, 100% { 
        transform: scale(1); 
        opacity: 1; 
    }
    50% { 
        transform: scale(1.1); 
        opacity: 0.8; 
    }
}

@keyframes shake-red {
    0%, 100% { 
        transform: translateX(0); 
    }
    25% { 
        transform: translateX(-2px); 
    }
    75% { 
        transform: translateX(2px); 
    }
}

@keyframes gentle-bounce {
    0%, 100% { 
        transform: translateY(0px); 
    }
    50% { 
        transform: translateY(-3px); 
    }
}

/* Enhanced popup styles */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.1);
    max-width: 300px !important;
}

/* Logger panel styles */
#logPanelContainer {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 360px;
    max-height: 340px;
    background: rgba(255,255,255,0.98);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 9999;
}

#logPanelHeader {
    padding: 8px 12px;
    background: linear-gradient(90deg, #2d7d32, #4caf50);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#logPanelHeader .title { font-weight: 700; font-size: 0.95rem; }
/* Ensure header controls are always a compact horizontal group and don't inherit other .controls rules */
#logPanelHeader .controls {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap; /* prevent stacking */
    margin-left: 8px;
}

#logPanel { padding: 10px; overflow-y: auto; font-size: 12px; background: #fafaf5; color: #1b5e20; }
.log-entry { padding: 6px 8px; margin-bottom: 6px; border-radius: 6px; }
.log-entry.log-info { background: rgba(76,175,80,0.08); }
.log-entry.log-warn { background: rgba(255,193,7,0.08); }
.log-entry.log-error { background: rgba(244,67,54,0.06); }
.log-time { color: #666; font-size: 11px; margin-right: 6px; }
.log-level { font-weight: 700; margin-right: 6px; }
.log-msg { color: #133; }

.log-btn {
    background: rgba(255,255,255,0.12);
    border: none;
    color: white;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    line-height: 1;
    min-width: 44px; /* keep buttons reasonably tappable */
    white-space: nowrap;
}
.log-btn:hover { opacity: 0.95; transform: translateY(-1px); }

/* Specific small tweaks for the header buttons on narrow screens */
@media (max-width: 420px) {
    #logPanelHeader { padding: 6px 8px; }
    #logPanelHeader .title { font-size: 0.85rem; }
    #logPanelHeader .controls { gap: 4px; }
    #logPanelHeader .controls .log-btn { padding: 5px 6px; min-width: 36px; font-size: 0.78rem; }
    /* collapse text for the toggle button to save space */
    #toggleLogBtn { padding: 5px 8px; }
}


.leaflet-popup-content {
    margin: 16px 20px;
    line-height: 1.5;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.leaflet-popup-tip {
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Override Leaflet's default popup width constraints */
.leaflet-popup {
    margin-bottom: 20px;
}

/* Responsive design */
@media (max-width: 768px) {
    .car-info {
        flex-direction: column;
        gap: 20px;
    }
    
    .controls {
        flex-direction: row;
        width: 100%;
    }
    
    .btn {
        flex: 1;
    }
    
    .car-marker i {
        font-size: 24px !important;
    }
    
    .car-label {
        font-size: 8px;
        padding: 1px 4px;
    }
}

@media (max-width: 480px) {
    .car-marker i {
        font-size: 20px !important;
    }
    
    .car-label {
        font-size: 7px;
    }
}