:root {
    --bg-dark: #050505;
    /* Deep Space Black */
    --surface-dark: #0a0a0a;
    --text-primary: #e0e0e0;
    --text-secondary: #94a3b8;
    --accent: #00f3ff;
    /* Electric Blue/Cyan */
    --accent-glow: rgba(0, 243, 255, 0.4);
    --border-color: #333;
    --sidebar-width: 320px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Rubik', 'Heebo', sans-serif;
    /* Clean tech font */
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    direction: rtl;
}

/* Map Canvas - Clean */
#map {
    width: 100vw;
    height: 100vh;
    background: #000;
}

/* Left Toolbar - The "Physital" Interface */
.left-toolbar {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 2000;
}

.tool-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    /* Circle */
    background: rgba(10, 10, 10, 0.8);
    /* Semi-transparent */
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.tool-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: scale(1.1);
}

.zoom-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

/* Sidebar - Right Side, Sleek */
.sidebar {
    position: absolute;
    top: 20px;
    right: 20px;
    width: var(--sidebar-width);
    bottom: 20px;
    background: rgba(10, 10, 10, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    z-index: 1000;
    padding: 24px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

/* Typography & Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo i {
    font-size: 24px;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
}

.logo h1 {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

h2,
h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin: 20px 0 12px 0;
    font-weight: 600;
}

/* Layer Toggles */
.layer-toggle {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: var(--transition);
}

.layer-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.layer-toggle i {
    color: var(--accent);
    /* Iconic Physital Blue */
    margin-left: 12px;
    width: 20px;
    text-align: center;
}

.layer-toggle span {
    flex: 1;
    font-size: 14px;
    font-weight: 400;
}

/* Switch - Custom */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 18px;
    direction: ltr;
    /* LTR for mechanics */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    border-radius: 18px;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #fff;
    border-radius: 50%;
    transition: .3s;
}

input:checked+.slider {
    background-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

/* Lighting Controls - Minimal */
.lighting-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 10px;
}

.light-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.light-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.light-btn:hover {
    color: var(--text-primary);
}

/* Stats */
.stats-panel {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.stat-card {
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 300;
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Mapbox Popups - Glass */
.mapboxgl-popup-content {
    background: rgba(10, 10, 10, 0.9) !important;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    color: var(--text-primary) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    font-family: 'Rubik', sans-serif;
}

.mapboxgl-popup-close-button {
    color: var(--text-secondary);
}

.mapboxgl-popup-close-button:hover {
    color: var(--accent);
}

/* Hide Default Mapbox Controls (we made our own) */
.mapboxgl-ctrl-top-right,
.mapboxgl-ctrl-top-left {
    display: none !important;
}

/* Search Bar */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-container input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 12px 12px 40px;
    /* Space for icon */
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.search-container input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    background: rgba(0, 0, 0, 0.5);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    /* Fixed centering */
    color: var(--text-secondary);
    pointer-events: none;
}

.search-results {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 2000;
    display: none;
    /* Hidden by default */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.search-results.active {
    display: block;
}

.search-item {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
    font-size: 13px;
}

/* Dashboard Panel (Morphocode Inspired) */
.dashboard-panel {
    position: fixed;
    top: 20px;
    right: -420px;
    /* Hidden start */
    width: 380px;
    /* Precise width */
    height: calc(100vh - 40px);
    /* Floating effect */
    background: #111;
    /* Pitch black / dark grey */
    border: 1px solid #333;
    z-index: 4000;
    transition: right 0.3s cubic-bezier(0.2, 0, 0, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    font-family: 'Inter', sans-serif;
    /* Clean font */
    border-radius: 4px;
    /* Minimal radius */
}

.dashboard-panel.active {
    right: 20px;
    /* Floating margin */
}

.dashboard-content {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
    /* More spacing */
}

/* Scrollbar */
.dashboard-content::-webkit-scrollbar {
    width: 4px;
}

.dashboard-content::-webkit-scrollbar-thumb {
    background: #444;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #222;
    padding-bottom: 15px;
    margin-bottom: 10px;
}

.dashboard-header h2 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #888;
    margin: 0;
    font-weight: 600;
}

.close-dashboard {
    background: none;
    border: none;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.2s;
}

.close-dashboard:hover {
    color: #fff;
}

/* Stats Row (Minimal) */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-card {
    background: transparent;
    /* No background */
    border-left: 2px solid #333;
    /* Left accent only */
    border-radius: 0;
    padding: 5px 15px;
    text-align: left;
    /* Align left */
    transition: border-color 0.3s;
}

.stat-card:hover {
    border-left-color: var(--accent);
}

.stat-value {
    font-size: 28px;
    font-weight: 300;
    /* Light weight */
    color: #fff;
    margin-bottom: 5px;
    line-height: 1;
}

.stat-label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Charts */
.chart-container {
    background: transparent;
    border: 1px solid #222;
    border-radius: 0;
    padding: 20px 0;
    /* Minimal padding */
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.chart-container h3 {
    margin: 0 0 15px 10px;
    color: #ccc;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-left: 2px solid var(--accent);
    padding-left: 10px;
}

/* Stats Cards */
.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Charts */
.chart-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    min-height: 300px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chart-container.large {
    grid-column: span 3;
}

.chart-container h3 {
    margin-top: 0;
    color: var(--text-primary);
    font-size: 16px;
}


.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: rgba(0, 243, 255, 0.1);
}

.search-item-name {
    color: var(--text-primary);
    font-weight: 500;
}


/* Radar Effect */
.radar-marker {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--accent);
    position: relative;
    cursor: pointer;
}

.radar-marker::before,
.radar-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid var(--accent);
    opacity: 0;
    animation: radar-pulse 2s infinite ease-out;
}

.radar-marker::after {
    animation-delay: 1s;
}

@keyframes radar-pulse {
    0% {
        width: 100%;
        height: 100%;
        opacity: 0.8;
        border-width: 1px;
    }

    100% {
        width: 400%;
        height: 400%;
        opacity: 0;
        border-width: 0px;
    }
}

/* Cluster Contols */
.cluster-controls {
    position: absolute;
    left: 50px;
    /* Right of the sidebar/toolbar */
    top: 200px;
    /* Align with button */
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid var(--accent);
    padding: 15px;
    border-radius: 8px;
    width: 200px;
    display: none;
    /* Hidden by default */
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
    z-index: 1000;
}

.cluster-controls.active {
    display: flex;
}

.cluster-controls label {
    color: var(--text-primary);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
}

.cluster-controls input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

/* Admin & Action Buttons */
.admin-btn.active {
    color: var(--accent) !important;
    border-color: var(--accent) !important;
    background: rgba(0, 243, 255, 0.05) !important;
}

.action-btn:hover {
    background: rgba(0, 243, 255, 0.2) !important;
}

/* Editable Popup Components */
.edit-field {
    border: 1px dashed transparent;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s;
    cursor: text;
}

[contenteditable='true'].edit-field:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
}

[contenteditable='true'].edit-field:focus {
    outline: none;
    border-style: solid;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
}

.btn-delete {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
    border: 1px solid rgba(255, 59, 48, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    margin-top: 15px;
    width: 100%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-delete:hover {
    background: rgba(255, 59, 48, 0.2);
    border-color: #ff3b30;
}

body.admin-active #map {
    cursor: crosshair;
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 30px;
    right: 300px;
    /* Offset from sidebar */
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    display: none;
    z-index: 1000;
    max-width: 200px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.map-legend.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.legend-title {
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    color: var(--accent);
    border-bottom: 1px solid rgba(0, 243, 255, 0.2);
    padding-bottom: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    font-size: 12px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Login Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #1a1a1a;
    margin: 15% auto;
    padding: 30px;
    border: 1px solid #333;
    width: 300px;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
    text-align: center;
    direction: rtl;
    color: #fff;
}

.close-modal {
    color: #aaa;
    float: left;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

#login-form input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background: #000;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
    box-sizing: border-box;
}

#login-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-login {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 10px 20px;
    margin-top: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    transition: 0.2s;
}

.btn-login:hover {
    background: #00c4ce;
}