:root {
    --bg-color: #e0f2fe;
    --surface-color: #f0f9ff;
    --surface-light: #bae6fd;
    --primary-color: #0284c7; 
    --primary-hover: #0369a1;
    --text-main: #0f172a;
    --text-muted: #475569;
    --danger: #e11d48;
    --success: #16a34a;
    
    --font-family: system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Typography */
h1 { font-size: 1.2rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;}
h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--primary-color); }
.subtitle { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; }

/* Header */
header {
    background-color: var(--surface-color);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--surface-light);
    z-index: 10;
}

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

#gps-indicator {
    font-size: 1.2rem;
}
#gps-indicator.searching { color: var(--text-muted); animation: pulse 1.5s infinite; }
#gps-indicator.locked { color: var(--success); }
#gps-indicator.error { color: var(--danger); }

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* Main Layout */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 80px; /* Space for bottom nav */
}

.tab-content {
    display: none;
    padding: 1rem;
    flex: 1;
}
.tab-content.active {
    display: flex;
    flex-direction: column;
}

.center-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Navigation View Components */
.empty-state {
    text-align: center;
    color: var(--text-muted);
}

.target-header {
    text-align: center;
    margin-bottom: 1rem;
}

#nav-map {
    width: 100%;
    height: 150px;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--surface-light);
    background-color: var(--surface-color);
    z-index: 1; /* Keep leaflet controls below other overlays if any */
}

.custom-leaflet-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    background: none;
    border: none;
}

/* Compass */
.compass-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
}

.compass-dial {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 4px solid var(--surface-light);
    background: radial-gradient(circle, var(--surface-color) 0%, var(--bg-color) 100%);
    position: relative;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1), 0 5px 15px rgba(0,0,0,0.1);
}

.mark {
    position: absolute;
    font-weight: bold;
    color: var(--text-muted);
}
.mark.n { top: 10px; left: 50%; transform: translateX(-50%); color: var(--primary-color); }
.mark.s { bottom: 10px; left: 50%; transform: translateX(-50%); }
.mark.e { right: 10px; top: 50%; transform: translateY(-50%); }
.mark.w { left: 10px; top: 50%; transform: translateY(-50%); }

#bearing-arrow {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    color: var(--primary-color);
    transition: transform 0.3s ease-out;
}
#bearing-arrow i {
    transform: rotate(-45deg); /* Offset fontawesome arrow pointing top-right to point straight up */
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.2));
}

/* Telemetry */
.telemetry {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.data-box {
    flex: 1;
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--surface-light);
}
.data-box .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.data-box .value {
    font-size: 2rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}
.data-box .unit {
    font-size: 1rem;
    color: var(--text-muted);
}

.action-row {
    text-align: center;
    margin-bottom: 1rem;
}

.current-location-banner {
    margin-top: auto;
    background-color: rgba(255,255,255,0.5);
    padding: 0.8rem;
    border-radius: 8px;
    text-align: center;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Waypoints View Components */
.add-waypoint-card {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--surface-light);
}
.help-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}
input[type="text"] {
    flex: 1;
    background-color: var(--bg-color);
    border: 1px solid var(--surface-light);
    color: var(--text-main);
    padding: 0.8rem;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
}
input[type="text"]:focus {
    border-color: var(--primary-color);
}

.status-msg {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    min-height: 1rem;
}

.waypoints-list-container {
    flex: 1;
}

#waypoints-list {
    list-style: none;
}

.waypoint-item {
    background-color: var(--surface-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
}
.waypoint-item.active-target {
    border-color: var(--primary-color);
    background-color: rgba(2, 132, 199, 0.1);
}

.wp-info h4 {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.wp-info h4 i {
    color: var(--primary-color);
}
.wp-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}

.wp-actions {
    display: flex;
    gap: 0.5rem;
}
.btn-icon {
    background: var(--surface-light);
    border: none;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
}
.btn-icon.go { color: var(--primary-color); background: rgba(2, 132, 199, 0.2); }
.btn-icon.del { color: var(--danger); background: rgba(225, 29, 72, 0.2); }

/* Buttons */
.btn {
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:active { background-color: var(--primary-hover); }
.btn-danger { background-color: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:active { background-color: rgba(192, 57, 43, 0.2); }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}
.modal.hidden {
    display: none;
}
.modal-content {
    background-color: var(--surface-color);
    width: 100%;
    height: 80%;
    border-radius: 12px;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
#btn-close-map {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: var(--surface-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
#zoomed-map {
    flex: 1;
    width: 100%;
    background-color: var(--surface-color);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--surface-color);
    display: flex;
    border-top: 1px solid var(--surface-light);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom); /* iOS support */
}

.nav-item {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}
.nav-item i { font-size: 1.3rem; }
.nav-item span { font-size: 0.8rem; font-weight: 500; }
.nav-item.active { color: var(--primary-color); }