/* Global Resets & Typography */
:root {
    --bg-dark: #121417;
    --panel-bg: rgba(24, 28, 35, 0.82);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-cyan: #ff4d5a;
    --accent-blue: #d32f2f;
    --accent-green: #00e676;
    --accent-red: #ff3344;
    --font-primary: 'Outfit', 'Plus Jakarta Sans', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --glow-shadow: 0 0 15px rgba(211, 47, 47, 0.45);
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-primary);
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

/* Map Configuration */
#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Leaflet Custom Styles to match Dark Mode */
.leaflet-container {
    background-color: var(--bg-dark) !important;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom-in, .leaflet-control-zoom-out {
    background: var(--panel-bg) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid var(--panel-border) !important;
    color: var(--text-primary) !important;
    transition: var(--transition-smooth);
}

.leaflet-control-zoom-in:hover, .leaflet-control-zoom-out:hover {
    background: rgba(0, 242, 254, 0.2) !important;
    color: var(--accent-cyan) !important;
}

.leaflet-bar a.leaflet-disabled {
    background: rgba(13, 22, 47, 0.4) !important;
    color: var(--text-secondary) !important;
}

/* Dashboard Container */
.dashboard-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to map if needed */
    display: flex;
    flex-direction: column;
    padding: 24px;
}

/* Glassmorphism Panel Base */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    pointer-events: auto; /* Enable clicks inside overlay */
}

/* Sidebar Layout */
.sidebar {
    width: 360px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    color: var(--accent-cyan);
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #b0c4de 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text .subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(5, 255, 176, 0.1);
    border: 1px solid rgba(5, 255, 176, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(5, 255, 176, 0.7);
    animation: pulse 1.6s infinite;
}

.status-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-green);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Section Styling */
.sidebar h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar h2 i {
    color: var(--accent-cyan);
}

/* System Status Info */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-cyan);
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
}

/* Device Selector Custom Dropdown */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    appearance: none;
    cursor: pointer;
    outline: none;
    transition: var(--transition-smooth);
}

.custom-select:hover, .custom-select:focus {
    border-color: var(--accent-cyan);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.15);
}

.custom-select-wrapper::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    transition: var(--transition-smooth);
}

.custom-select-wrapper:hover::after {
    color: var(--accent-cyan);
}

/* Coordinate Details Table */
.coordinate-details {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.coord-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 8px;
}

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

.coord-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.coord-val {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    font-family: monospace;
}

/* Buttons */
.sidebar-footer {
    display: flex;
    gap: 12px;
    margin-top: auto;
}

.btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
    color: #000000;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 242, 254, 0.4);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-secondary.active {
    background: rgba(0, 242, 254, 0.1);
    border-color: rgba(0, 242, 254, 0.3);
    color: var(--accent-cyan);
    box-shadow: inset 0 0 10px rgba(0, 242, 254, 0.1);
}

/* Notification Toast */
.toast {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-left: 4px solid var(--accent-cyan);
    z-index: 100;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(0);
    opacity: 1;
}

.toast.hide {
    transform: translateY(-50px);
    opacity: 0;
    pointer-events: none;
}

.toast-icon {
    color: var(--accent-cyan);
    font-size: 16px;
    text-shadow: 0 0 8px rgba(0, 242, 254, 0.5);
}

.toast-message {
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(5, 255, 176, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(5, 255, 176, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(5, 255, 176, 0);
    }
}

/* Glowing Pulsing Circle Marker for Map */
.gps-glow-marker {
    display: flex;
    justify-content: center;
    align-items: center;
}

.gps-glow-marker::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--accent-cyan);
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.gps-glow-marker::after {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    background: rgba(0, 242, 254, 0.3);
    border-radius: 50%;
    animation: markerPulse 2s infinite ease-out;
    z-index: 1;
}

@keyframes markerPulse {
    0% {
        transform: scale(0.3);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Older tracking markers along the route */
.gps-trail-marker {
    width: 8px !important;
    height: 8px !important;
    background: var(--accent-blue);
    border: 1.5px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.gps-trail-marker:hover {
    background: var(--accent-cyan);
    transform: scale(1.3);
    box-shadow: 0 0 8px var(--accent-cyan);
    transition: var(--transition-smooth);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 12px;
    }
    .sidebar {
        width: 100%;
        max-height: 50vh;
        gap: 16px;
        padding: 16px;
    }
    .toast {
        top: auto;
        bottom: 24px;
        right: 12px;
        left: 12px;
    }
}

/* Monitored Devices List */
.devices-list-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.device-item {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition-smooth);
}

.device-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 242, 254, 0.2);
}

.device-item.active {
    background: rgba(0, 242, 254, 0.08);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}

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

.device-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.device-item-status {
    font-size: 9px;
    font-weight: 700;
    color: var(--accent-cyan);
    background: rgba(0, 242, 254, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
    text-transform: uppercase;
}

.device-item-details {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Override Leaflet default divIcon styling to prevent white boxes */
.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
}

/* Device specific glowing marker colors */
.gps-glow-marker.smartphone-glow::before {
    background: var(--accent-cyan) !important;
}

.gps-glow-marker.smartphone-glow::after {
    background: rgba(0, 242, 254, 0.3) !important;
}

.gps-glow-marker.tablet-glow::before {
    background: #a855f7 !important; /* Purple for tablet */
}

.gps-glow-marker.tablet-glow::after {
    background: rgba(168, 85, 247, 0.3) !important;
}
