* {
    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 */
}

.cow-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);
}

.cow-card {
    flex: 1;
}

.cow-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;
}

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

.behavior-grazing {
    background: #d4edda;
    color: #155724;
}

.behavior-lying-ruminating {
    background: #cce7ff;
    color: #004085;
}

.behavior-lying-resting {
    background: #e1bee7;
    color: #4a148c;
}

.behavior-standing-ruminating {
    background: #fff3cd;
    color: #856404;
}

.behavior-standing-resting {
    background: #e0e0e0;
    color: #424242;
}

.behavior-walking {
    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 cow marker styles */
.custom-cow-icon {
    background: none !important;
    border: none !important;
}

.cow-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;
}

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

.cow-marker i {
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Behavior-specific animations with cow icons */
.cow-marker.grazing i {
    animation: gentle-sway 3s ease-in-out infinite;
}

.cow-marker.lying-ruminating i {
    opacity: 0.9;
    animation: slow-pulse 4s ease-in-out infinite;
    transform: rotate(-15deg); /* Tilted to show lying position */
}

.cow-marker.lying-resting i {
    opacity: 0.8;
    transform: rotate(-20deg);
    animation: gentle-breathing 4s ease-in-out infinite;
}

.cow-marker.standing-ruminating i {
    animation: gentle-bounce 3s ease-in-out infinite;
}

.cow-marker.standing-resting i {
    opacity: 0.9;
    animation: gentle-breathing 5s ease-in-out infinite;
}

.cow-marker.walking i {
    animation: walking-bounce 1.5s ease-in-out infinite;
}

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

/* Behavior-specific label colors */
.cow-marker.grazing .cow-label {
    border-left: 3px solid #4CAF50;
}

.cow-marker.lying-ruminating .cow-label {
    border-left: 3px solid #2196F3;
}

.cow-marker.lying-resting .cow-label {
    border-left: 3px solid #9C27B0;
}

.cow-marker.standing-ruminating .cow-label {
    border-left: 3px solid #FF9800;
}

.cow-marker.standing-resting .cow-label {
    border-left: 3px solid #607D8B;
}

.cow-marker.walking .cow-label {
    border-left: 3px solid #F44336;
}

/* Animations */
@keyframes gentle-sway {
    0%, 100% { 
        transform: rotate(-2deg); 
    }
    50% { 
        transform: rotate(2deg); 
    }
}

@keyframes slow-pulse {
    0%, 100% { 
        opacity: 0.9; 
    }
    50% { 
        opacity: 0.6; 
    }
}

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

/* 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);
}

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

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

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

@media (max-width: 480px) {
    .cow-marker i {
        font-size: 24px !important;
    }
    
    .cow-label {
        font-size: 7px;
        padding: 1px 4px;
        max-width: 80px;
    }
}

/* Add breathing animation for resting cows */
@keyframes gentle-breathing {
    0%, 100% { 
        transform: scale(1); 
    }
    50% { 
        transform: scale(1.05); 
    }
}