@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
    --bg-color: #0b0c10;
    --panel-bg: rgba(22, 26, 37, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f4f8;
    --text-secondary: #90a1b5;
    
    --color-accent: #00ff88;      /* Neon Green */
    --color-secondary: #00e5ff;   /* Neon Cyan */
    --color-stop: #ff3366;        /* Neon Red */
    --color-warn: #ffaa00;        /* Gold/Orange */
    
    --shadow-accent: 0 0 15px rgba(0, 255, 136, 0.4);
    --shadow-cyan: 0 0 15px rgba(0, 229, 255, 0.4);
    --shadow-stop: 0 0 15px rgba(255, 51, 102, 0.4);
    --shadow-panel: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: radial-gradient(circle at top right, #1a2238 0%, var(--bg-color) 70%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Container */
.app-container {
    width: 100%;
    max-width: 650px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

/* Glassmorphic Panel */
.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-panel);
    transition: var(--transition-smooth);
}

.panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--color-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Wake Lock & Unit Toggle Badges */
.badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-smooth);
}

.badge.active {
    border-color: var(--color-secondary);
    color: var(--color-secondary);
    background: rgba(0, 229, 255, 0.05);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.1);
}

.badge:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Battery Profile & Segmented Control */
.battery-panel {
    display: flex;
    flex-direction: column;
}

.section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.segmented-control {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 14px;
    padding: 4px;
    border: 1px solid var(--panel-border);
    gap: 4px;
}

.seg-btn {
    flex: 1;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 10px 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.seg-btn.active {
    background: var(--panel-bg);
    color: var(--color-secondary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.seg-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.battery-desc {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: left;
    line-height: 1.45;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.status-dot.active {
    background-color: var(--color-accent);
    box-shadow: 0 0 8px var(--color-accent);
    animation: pulse 1.5s infinite;
}

.status-dot.paused {
    background-color: var(--color-warn);
    box-shadow: 0 0 8px var(--color-warn);
}

/* Interactive Map Panel */
.map-panel {
    padding: 0;
    overflow: hidden;
    height: 320px;
    position: relative;
    border-radius: 20px;
    z-index: 1;
}

#map {
    width: 100%;
    height: 100%;
    background: #191a1a;
}

/* Customizing Leaflet Dark Theme */
.leaflet-container {
    background: #111 !important;
}

.leaflet-tile {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.leaflet-bar {
    border: 1px solid var(--panel-border) !important;
    box-shadow: var(--shadow-panel) !important;
}

.leaflet-bar a {
    background-color: var(--panel-bg) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--panel-border) !important;
}

.leaflet-bar a:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 5px;
}

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

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-unit {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 2px;
}

/* Control Panel Buttons */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.button-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.btn {
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    padding: 14px 20px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--color-accent);
    color: #051a0e;
    flex: 2;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.15);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-accent);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--color-stop);
    color: #f0f4f8;
    flex: 1;
    box-shadow: 0 4px 15px rgba(255, 51, 102, 0.15);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: var(--shadow-stop);
    transform: translateY(-2px);
}

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

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

/* Export Panel */
.export-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Log Panel */
.log-panel {
    max-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.log-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.log-content {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 120px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.log-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.log-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.log-time {
    color: var(--color-secondary);
}

/* Footer / Disclaimer */
footer {
    text-align: center;
    font-size: 12px;
    color: rgba(144, 161, 181, 0.4);
    margin-top: auto;
    padding: 20px 0;
}

footer a {
    color: rgba(0, 229, 255, 0.5);
    text-decoration: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Pulse animation */
@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(0, 255, 136, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0);
    }
}

/* Responsive adjustment */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .map-panel {
        height: 240px;
    }
}
