:root {
    --primary-color: #00bfff; /* Deep Sky Blue - used for accents, active states */
    --secondary-color: #00ffc8; /* Aqua / Cyan - used for highlights, data values */
    --background-dark: #0a0a14; /* Very dark blue/black - main background */
    --surface-dark: #1a1a2e; /* Darker blue/purple - card backgrounds, panels */
    --text-light: #e0e0e0; /* Off-white for general text */
    --text-mid: #a0a0a0; /* Grey for labels, secondary info */
    --red-alert: #ff4d4d; /* For critical alerts */
    --green-status: #00ff8c; /* For success/online status */
    --orange-warning: #ff6b00; /* For warnings, weak signals */
    --purple-strong: #a800ff; /* For WPA3, strong signals */
    --yellow-neutral: #ffec00; /* For vehicle, neutral signals */
    --font-primary: 'Orbitron', sans-serif; /* Futuristic, techy font */
    --font-secondary: 'Roboto', sans-serif; /* Readable sans-serif for body text */
}

body {
    margin: 0;
    font-family: var(--font-secondary);
    background-color: var(--background-dark);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto; /* Allow scrolling for content */
}

.container {
    background: var(--surface-dark);
    border: 1px solid rgba(0, 191, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 191, 255, 0.15);
    width: 100%;
    max-width: 1200px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 90vh; /* Ensure it takes up most of viewport height */
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: linear-gradient(to right, #0d0d1a, #1a1a2e);
    border-bottom: 2px solid var(--primary-color);
    font-family: var(--font-primary);
    font-size: 1.1rem;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 1.5s infinite;
}

.status-dot.scanning {
    background-color: var(--green-status);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 255, 140, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0, 255, 140, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 255, 140, 0); }
}

.app-title {
    color: var(--secondary-color);
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 255, 200, 0.5);
}

.metric-icon {
    margin-left: 20px;
    margin-right: 5px;
    color: var(--primary-color);
}

#accuracy-percent, #accuracy-meters {
    color: var(--secondary-color);
    font-weight: bold;
}

/* Metrics Dashboard */
.metrics-dashboard {
    display: flex;
    justify-content: space-around;
    padding: 20px 0;
    background-color: var(--surface-dark);
    border-bottom: 1px solid rgba(0, 191, 255, 0.1);
}

.metric-card {
    text-align: center;
    flex: 1;
    border-right: 1px solid rgba(0, 191, 255, 0.05);
}

.metric-card:last-child {
    border-right: none;
}

.metric-card .label {
    font-size: 0.8rem;
    color: var(--text-mid);
    text-transform: uppercase;
}

.metric-card .value {
    font-family: var(--font-primary);
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    margin-top: 5px;
}

.metric-card .value.green { color: var(--green-status); }
.metric-card .value.cyan { color: var(--secondary-color); }
.metric-card .unit {
    font-size: 0.9rem;
    color: var(--text-mid);
    margin-left: 5px;
}

/* Navigation */
.app-navigation {
    display: flex;
    background-color: #111122; /* Slightly darker than surface-dark */
    border-bottom: 1px solid var(--primary-color);
}

.nav-btn {
    flex: 1;
    padding: 15px 10px;
    background: transparent;
    border: none;
    color: var(--text-light);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-right: 1px solid rgba(0, 191, 255, 0.05);
}

.nav-btn:last-child {
    border-right: none;
}

.nav-btn:hover {
    background-color: rgba(0, 191, 255, 0.1);
    color: var(--primary-color);
}

.nav-btn.active {
    background-color: var(--primary-color);
    color: var(--background-dark);
    box-shadow: 0 0 15px rgba(0, 191, 255, 0.4);
    position: relative;
    z-index: 1;
}

.nav-btn.active .icon {
    color: var(--background-dark);
}

/* Main Content */
.main-content {
    padding: 25px;
    flex-grow: 1;
    position: relative;
    overflow-y: auto; /* Enable scrolling for views if content overflows */
}

.view-section {
    display: none; /* Hidden by default */
    animation: fadeIn 0.5s forwards;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Radar View */
.radar-display-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* Aspect ratio 4:3, or adjust to 100% for square */
    max-width: 800px;
    margin: 0 auto 30px auto;
    background-color: #000;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.5);
}

.radar-display {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, #1a1a2e 0%, #0a0a14 100%);
    overflow: hidden;
}

.radar-center-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 15px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px var(--secondary-color);
}

.radar-sweep {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform-origin: 0% 0%;
    background: linear-gradient(to right, rgba(0, 255, 200, 0) 0%, rgba(0, 255, 200, 0.3) 50%, rgba(0, 255, 200, 0) 100%);
    border-radius: 50%;
    animation: radarSweep 4s linear infinite;
}

@keyframes radarSweep {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.radar-blip {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--green-status); /* Default blip color */
    box-shadow: 0 0 8px var(--green-status);
    transform: translate(-50%, -50%); /* Center blip on its coordinates */
    opacity: 0.9;
    transition: all 0.2s ease-out;
    font-size: 0.6rem; /* For potential labels */
    color: white;
    text-shadow: 0 0 3px black;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none; /* Allows clicks to pass through to underlying radar */
}

.radar-blip.red { background-color: var(--red-alert); box-shadow: 0 0 8px var(--red-alert); }
.radar-blip.orange { background-color: var(--orange-warning); box-shadow: 0 0 8px var(--orange-warning); }
.radar-blip.cyan { background-color: var(--secondary-color); box-shadow: 0 0 8px var(--secondary-color); }
.radar-blip.purple { background-color: var(--purple-strong); box-shadow: 0 0 8px var(--purple-strong); }
.radar-blip.yellow { background-color: var(--yellow-neutral); box-shadow: 0 0 8px var(--yellow-neutral); }


.radar-compass {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
    border-radius: 50%;
    border: 1px solid rgba(0, 191, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-primary);
    font-size: 0.8rem;
    color: var(--primary-color);
}

.radar-compass span {
    position: absolute;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 191, 255, 0.5);
}

.radar-compass .north { top: 5%; }
.radar-compass .east { right: 5%; transform: translateY(-50%); }
.radar-compass .south { bottom: 5%; }
.radar-compass .west { left: 5%; transform: translateY(-50%); }

.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.zoom-btn {
    background-color: rgba(0, 191, 255, 0.2);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background-color: var(--primary-color);
    color: var(--background-dark);
    box-shadow: 0 0 10px var(--primary-color);
}


.compass-display {
    text-align: center;
    margin-top: 20px;
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid var(--secondary-color);
    margin: 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px rgba(0, 255, 200, 0.3);
}

.compass-needle {
    position: absolute;
    width: 2px;
    height: 50%; 
    background: linear-gradient(to top, var(--red-alert) 0%, var(--red-alert) 50%, var(--text-light) 50%, var(--text-light) 100%);
    transform-origin: bottom center;
    z-index: 2;
    transition: transform 0.5s ease-out;
}

.compass-text {
    position: absolute;
    font-family: var(--font-primary);
    font-size: 1.5rem;
    color: var(--secondary-color);
    z-index: 3;
    text-shadow: 0 0 5px rgba(0, 255, 200, 0.5);
}

.compass-label {
    position: absolute;
    bottom: 10px;
    font-size: 0.8rem;
    color: var(--text-mid);
    z-index: 3;
}


/* Map View */
.map-placeholder {
    background-color: var(--surface-dark);
    border: 1px dashed var(--primary-color);
    padding: 50px;
    text-align: center;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-mid);
    font-size: 1.2rem;
    border-radius: 10px;
}

/* List View */
.device-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    background-color: var(--surface-dark);
    border: 1px solid var(--primary-color);
    border-radius: 5px;
    color: var(--primary-color);
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background-color: rgba(0, 191, 255, 0.15);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: var(--background-dark);
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.5);
}

.device-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.device-item {
    background-color: #111122;
    border: 1px solid rgba(0, 255, 200, 0.2);
    border-radius: 8px;
    padding: 15px;
    transition: transform 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
}

.device-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 255, 200, 0.2);
}

.device-item h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--secondary-color);
    font-family: var(--font-primary);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px; /* Spacing between icon and title */
}

.device-item h4 .type-icon {
    color: var(--primary-color);
    font-size: 1.2em;
}

.device-item p {
    margin: 5px 0;
    font-size: 0.9rem;
    color: var(--text-light);
}

.device-item p strong {
    color: var(--text-mid);
    margin-right: 5px;
}

.device-item .rssi-bar-container {
    width: 100%;
    background-color: #0d0d1a;
    border-radius: 3px;
    height: 8px;
    margin-top: 10px;
    overflow: hidden;
}

.device-item .rssi-bar {
    height: 100%;
    width: 0%;
    background-color: var(--green-status); /* Default, will be set by JS */
    border-radius: 3px;
    transition: width 0.5s ease-out;
}

/* Charts View */
#charts-view h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-family: var(--font-primary);
}

.chart-container {
    background-color: var(--surface-dark);
    border: 1px solid rgba(0, 191, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 0 10px rgba(0, 191, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-container h4 {
    color: var(--secondary-color);
    margin-top: 0;
    margin-bottom: 20px;
    font-family: var(--font-primary);
    text-align: center;
}

.pie-chart {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: conic-gradient(
        #ccc 0% 100% /* Placeholder */
    );
    margin: 20px auto;
    position: relative;
}

.pie-chart::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background-color: var(--surface-dark);
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    z-index: 1;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.bar-chart-wrapper {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding-top: 10px;
    border-bottom: 1px solid var(--text-mid);
    padding-bottom: 10px;
}

.bar-chart-label {
    width: 100%;
    display: flex;
    justify-content: space-around;
    font-size: 0.8rem;
    color: var(--text-mid);
    padding-top: 5px;
}

.bar {
    flex-grow: 1;
    background-color: var(--primary-color); /* Default, will be set by JS */
    border-radius: 5px 5px 0 0;
    transition: height 0.5s ease-out;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.bar-value {
    position: absolute;
    top: -20px;
    color: var(--secondary-color);
    font-size: 0.8em;
    font-weight: bold;
}


/* Footer */
.app-footer {
    display: flex;
    justify-content: space-around;
    padding: 15px 25px;
    background: linear-gradient(to right, #0d0d1a, #1a1a2e);
    border-top: 2px solid var(--primary-color);
    font-family: var(--font-primary);
    font-size: 1.1rem;
}

.footer-btn {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.footer-btn:hover {
    color: var(--secondary-color);
    text-shadow: 0 0 10px rgba(0, 255, 200, 0.5);
}

.footer-btn.ai-locate {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    padding: 8px 15px;
    border: 1px solid var(--primary-color);
    border-radius: 20px;
    background-color: rgba(0, 191, 255, 0.1);
}

.footer-btn.ai-locate:hover {
    background-color: var(--primary-color);
    color: var(--background-dark);
}

.footer-btn.power-btn {
    color: var(--red-alert);
}

/* Chat to Edit Button */
.chat-to-edit {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--primary-color);
    color: var(--background-dark);
    border: none;
    border-radius: 30px;
    padding: 15px 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 191, 255, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
}

.chat-to-edit:hover {
    background-color: var(--secondary-color);
    box-shadow: 0 5px 20px rgba(0, 255, 200, 0.6);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-header,
    .metrics-dashboard,
    .app-navigation,
    .app-footer {
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }
    .app-title {
        font-size: 1.5rem;
        width: 100%;
        margin-top: 10px;
    }
    .metric-icon {
        margin-left: 10px;
    }
    .metric-card {
        border-right: none;
        border-bottom: 1px solid rgba(0, 191, 255, 0.05);
        padding: 10px 0;
    }
    .metric-card:last-child {
        border-bottom: none;
    }
    .nav-btn,
    .filter-btn {
        flex: 1 1 auto; /* Allow buttons to wrap */
    }
    .device-list {
        grid-template-columns: 1fr;
    }
    .footer-btn.ai-locate {
        width: 100%;
        margin-top: 10px;
    }
    .chat-to-edit {
        left: 50%;
        transform: translateX(-50%);
        right: auto;
    }
}
