:root {
    --bg-color: #1a1a1a;
    --panel-color: #2d2d2d;
    --text-color: #e0e0e0;
    --accent-color: #00ff88;
    --danger-color: #ff4444;
    --warn-color: #ffff00;
}

.conn-row {
    transition: 0.3s;
    opacity: 1;
}

.conn-row.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
}

/* Navbar */
.navbar {
    height: 50px;
    background-color: var(--panel-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.nav-title {
    font-weight: bold;
    letter-spacing: 1px;
}

/* Switch Toggles */
.nav-toggles {
    display: flex;
    gap: 20px;
    align-items: center;
}

/* Toggle Switch styling */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.85em;
    color: #ccc;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    background-color: #555;
    border-radius: 34px;
    transition: .4s;
    margin-right: 10px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

/* Custom Colors for specific sliders */
.danger-slider input:checked+.slider {
    background-color: var(--danger-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.settings-btn {
    background: none;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    padding: 5px 15px;
    cursor: pointer;
    transition: 0.3s;
}

.settings-btn:hover {
    background: var(--text-color);
    color: var(--bg-color);
}

/* Main Layout */
.container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    /* Adjust for navbar + footer */
    position: relative;
}

/* Video Feed */
.video-container {
    flex: 1;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.video-feed {
    height: 100%;
    width: auto;
    max-width: 100%;
}



/* Heads Up Display (Top Left - GPS/Counts only) */
.hud-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    color: var(--accent-color);
    font-family: monospace;
    text-shadow: 1px 1px 2px black;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 4px;
    z-index: 5;
}

/* System Overlay (Top Right) */
.sys-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #ddd;
    font-family: monospace;
    text-shadow: 1px 1px 2px black;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px;
    border-radius: 4px;
    z-index: 5;
    text-align: right;
    border: 1px solid #444;
}

.sys-overlay div {
    margin-bottom: 2px;
}

.sys-overlay span {
    font-weight: bold;
    color: #fff;
}

/* Bottom Status Bar */
.bottom-bar {
    height: 50px;
    background-color: #222;
    border-top: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 20px;
    font-family: monospace;
    font-size: 14px;
    z-index: 100;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.status-label {
    font-size: 10px;
    color: #888;
}

.status-val {
    font-weight: bold;
    color: #fff;
}

/* New Sub-value for actual data */
.status-val-sm {
    font-size: 0.8em;
    color: #aaa;
}

/* Virtual Joystick - Overlay Position */
#joystick-zone {
    width: 180px;
    height: 180px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    position: absolute;
    bottom: 20px;
    right: 20px;
    border: 2px solid #555;
    touch-action: none;
    z-index: 10;
}

#stick {
    width: 50px;
    height: 50px;
    background: var(--accent-color);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px var(--accent-color);
    cursor: pointer;
}

/* Zoom Slider - Overlay Position */
.zoom-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 180px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    padding: 5px;
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 10;
    border-radius: 10px;
}

input[type=range][orient=vertical] {
    writing-mode: bt-lr;
    /* IE */
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    /* WebKit */
    width: 8px;
    height: 150px;
    padding: 0 5px;
}

/* MINIMAP (SATELLITE) */
#minimap-container {
    position: absolute;
    bottom: 20px;
    left: 80px;
    /* To right of zoom slider */
    width: 200px;
    height: 200px;
    background: #000;
    border: 2px solid #555;
    border-radius: 10px;
    overflow: hidden;
    z-index: 20;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    /* Important: Allow dragging/clicking the map */
    pointer-events: auto;
}

#minimap-container:hover {
    border-color: var(--accent-color);
}

#minimap-container.expanded {
    width: 70vh;
    height: 70vh;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    z-index: 2000;
}

#map-leaf {
    width: 100%;
    height: 100%;
    background: #000;
}

/* Map Controls Overlay */
.map-ctrl-btn {
    position: absolute;
    width: 30px;
    height: 30px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 1px solid #555;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    z-index: 1000;
}

.map-ctrl-btn:hover {
    background: #444;
}

#btn-expand {
    top: 5px;
    right: 5px;
}

#btn-zoom-in {
    bottom: 40px;
    right: 5px;
}

#btn-zoom-out {
    bottom: 5px;
    right: 5px;
}

/* Leaflet Overrides */
.leaflet-control-attribution {
    font-size: 8px !important;
}

.drone-icon-div {
    background: transparent;
    border: none;
}

.drone-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 4px #000);
    transition: transform 0.1s linear;
}

/* Settings Sidebar */
.sidebar {
    position: fixed;
    top: 50px;
    right: -350px;
    width: 350px;
    height: calc(100vh - 50px);
    background: #252525;
    border-left: 1px solid #444;
    transition: 0.3s;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 1001;
}

.sidebar.open {
    right: 0;
}

.sidebar h3 {
    border-bottom: 1px solid #555;
    padding-bottom: 10px;
    margin-top: 20px;
    color: var(--accent-color);
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #aaa;
}

.setting-group input[type="text"],
.setting-group input[type="number"],
.setting-group select,
.setting-group input[type="range"] {
    width: 100%;
    background: #333;
    border: 1px solid #555;
    color: white;
    padding: 5px;
    box-sizing: border-box;
}

.color-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
}

.color-row input {
    flex: 1;
    font-size: 0.8em;
}

.btn-save {
    width: 100%;
    padding: 10px;
    background: var(--accent-color);
    border: none;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 50px;
}

.color-list-item {
    background: #333;
    padding: 5px;
    margin-bottom: 5px;
    border: 1px solid #555;
}

.btn-small {
    background: #555;
    color: #fff;
    border: none;
    padding: 2px 5px;
    cursor: pointer;
    font-size: 0.8em;
}

.btn-add {
    background: var(--accent-color);
    color: #000;
    width: 100%;
    margin-top: 5px;
}

/* TABS CSS */
.tabs {
    display: flex;
    border-bottom: 1px solid #444;
    margin-bottom: 15px;
}

.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    background: #222;
    color: #888;
    font-weight: bold;
}

.tab.active {
    background: #333;
    color: var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.servo-inp {
    width: 100% !important;
    padding: 2px !important;
    font-size: 0.8em !important;
    text-align: center;
}

/* Mission Editor */
.wp-item {
    background: #333;
    padding: 5px;
    margin-bottom: 2px;
    font-size: 0.8em;
}

.mission-btn-row {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.mission-btn {
    flex: 1;
    padding: 5px;
    background: #444;
    color: #fff;
    border: 1px solid #555;
    cursor: pointer;
}

.mission-btn:hover {
    background: #666;
}

.mission-btn-primary {
    background: var(--accent-color);
    color: #000;
    font-weight: bold;
}

/* Gamepad Mapper */
.map-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #383838;
    margin-bottom: 8px;
    border-radius: 4px;
    border: 1px solid #555;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.map-val {
    font-family: monospace;
    font-size: 1.1em;
    font-weight: bold;
    color: var(--accent-color);
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 10px;
}

.map-btn {
    background: #505050;
    border: 1px solid #777;
    color: #fff;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: 0.2s;
    min-width: 60px;
    text-align: center;
}

.map-btn:hover {
    background: #666;
    border-color: #999;
}

.map-btn.listening {
    background: #d32f2f;
    border-color: red;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Limit Sliders (Throttle/Steering) - Repositioned to Bottom Center */
.limit-overlay {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #444;
}

.limit-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.limit-group label {
    font-size: 11px;
    color: #ccc;
    font-weight: bold;
    width: 30px;
}

.limit-group span {
    font-size: 11px;
    color: var(--accent-color);
    width: 35px;
    text-align: right;
}

.limit-group input[type=range] {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #555;
    border-radius: 2px;
    outline: none;
}

.limit-group input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

/* Virtual Gamepad */
#virtual-controls {
    display: none;
    /* Hidden by default */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
}

.joystick-zone {
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    position: absolute;
    bottom: 30px;
    z-index: 20;
    touch-action: none;
    pointer-events: auto;
}

.joystick-zone.left {
    left: 40px;
}

.joystick-zone.right {
    right: 40px;
}

.stick {
    width: 60px;
    height: 60px;
    background: var(--accent-color);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    pointer-events: none;
}

/* Virtual Buttons (Right Side) */
.virtual-btn-group {
    position: absolute;
    bottom: 250px;
    /* Moved up from 190px */
    right: 40px;
    width: 150px;
    height: 150px;
    pointer-events: none;
}

/* D-Pad (Left Side) */
.d-pad-group {
    position: absolute;
    bottom: 250px;
    /* Matches Right Side height */
    left: 40px;
    width: 150px;
    height: 150px;
    pointer-events: none;
}

.v-btn {
    width: 45px;
    height: 45px;
    background: rgba(0, 255, 136, 0.2);
    border: 2px solid rgba(0, 255, 136, 0.5);
    border-radius: 50%;
    position: absolute;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    user-select: none;
    pointer-events: auto;
    /* Buttons catch clicks */
    cursor: pointer;
    backdrop-filter: blur(2px);
}

.v-btn:active,
.v-btn.active {
    background: rgba(0, 255, 136, 0.8);
    transform: scale(0.95);
}

/* Diamond Layout & D-Pad Cross */
/* Top: Y (3) & Up (12) */
#v-btn-3,
#v-btn-12 {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Bottom: A (0) & Down (13) */
#v-btn-0,
#v-btn-13 {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Left: X (2) & Left (14) */
#v-btn-2,
#v-btn-14 {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

/* Right: B (1) & Right (15) */
#v-btn-1,
#v-btn-15 {
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}