:root {
    /* Light Mode Colors (Creme & Soft Purple) */
    --bg-color: #FDFBF7;
    --text-color: #2D2A32;
    --primary-color: #A385C2;
    --primary-light: #D1C4E9;
    --card-bg: rgba(255, 255, 255, 0.7);
    --border-color: rgba(163, 133, 194, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(163, 133, 194, 0.15);
    
    /* Map styling overrides */
    --map-tiles-filter: brightness(0.95) contrast(1.1);
}

[data-theme="dark"] {
    /* Dark Mode Colors (Dark Blue & Light Purple) */
    --bg-color: #0F172A; /* Tailwind slate-900 */
    --text-color: #F8FAFC;
    --primary-color: #C4B5FD; /* Light purple */
    --primary-light: #8B5CF6;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(196, 181, 253, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* Map styling overrides for dark mode (makes OSM look dark) */
    --map-tiles-filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.4s ease, color 0.4s ease;
    overflow: hidden; /* Prevent scrolling, app-like feel */
}

.app-container {
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Utilities */
.glass-header {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000; /* Above the map */
    position: relative;
    padding: 1rem 1.5rem;
}

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
}

/* Header Styles */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-color);
}

.theme-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* Map Area */
.map-wrapper {
    flex: 1;
    position: relative;
}

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

/* Leaflet Dark Mode Support */
.leaflet-layer,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out,
.leaflet-control-attribution {
    filter: var(--map-tiles-filter);
    transition: filter 0.4s ease;
}

/* Custom Marker Styling */
.custom-marker {
    background: none;
    border: none;
}
.pin-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pin-core {
    width: 16px;
    height: 16px;
    background-color: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.pin-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 50%;
    opacity: 0.4;
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Status Card */
.status-card {
    position: absolute;
    bottom: 80px; /* Increased to avoid mobile nav bar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 1rem 1.5rem;
    width: 90%;
    max-width: 350px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background-color: #ef4444; /* Initial red (no data) */
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: pulse-red 2s infinite;
}

.pulse-dot.active {
    background-color: #10b981; /* Green when active */
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-green 2s infinite;
}

.status-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.25rem;
    padding-left: 1.35rem; /* Align with text */
}

.last-updated {
    font-size: 0.85rem;
    opacity: 0.7;
}

.refresh-btn {
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    opacity: 1;
    color: var(--primary-color);
    background: rgba(128, 128, 128, 0.1);
}

.refresh-btn.spinning svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Animations */
@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .status-card {
        bottom: 32px;
        left: 32px;
        transform: none;
    }
}

.model-tooltip {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    font-family: inherit;
    font-weight: 500;
    padding: 4px 8px;
    font-size: 0.8rem;
    backdrop-filter: blur(8px);
}

.model-tooltip::before {
    display: none;
}

/* Collapsible UI */
.status-card {
    transition: all 0.3s ease;
}
.status-card.collapsed {
    padding: 0.5rem 1rem;
    width: auto;
    border-radius: 30px;
}
.status-card.collapsed .collapsible-content {
    display: none !important;
}
.status-card.collapsed #status-text {
    display: none;
}
.collapse-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    opacity: 0.6;
    padding: 2px;
    margin-left: 10px;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
}
.collapse-btn:hover {
    opacity: 1;
}
.status-card.collapsed .collapse-btn {
    transform: rotate(180deg);
}

/* Model Actions */
.model-actions {
    display: flex;
    gap: 6px;
}
.model-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.4;
    padding: 2px;
}
.model-action-btn:hover {
    opacity: 1;
    color: var(--primary-color);
}
.model-action-btn.delete-btn:hover {
    color: #ef4444;
}
