/* MeshCore Wardrive Map - Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #121212;
    color: #ffffff;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Info Panel */
.info-panel {
    position: absolute;
    top: 70px;
    left: 10px;
    background: rgba(30, 30, 30, 0.95);
    padding: 15px;
    border-radius: 8px;
    z-index: 1000;
    min-width: 250px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    transition: transform 0.3s, opacity 0.3s;
}

.info-panel.hidden {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}

.info-panel h2 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #00e676;
}

.stat {
    margin: 8px 0;
    font-size: 14px;
}

.stat-label {
    color: #aaa;
    display: inline-block;
    width: 120px;
}

.stat-value {
    color: #fff;
    font-weight: 500;
}

/* Layer toggles */
.layer-toggles {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #444;
}

.toggle-item {
    display: flex;
    align-items: center;
    margin: 6px 0;
    cursor: pointer;
    user-select: none;
}

.toggle-item input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.toggle-item label {
    cursor: pointer;
    font-size: 13px;
}

/* Legend */
.legend {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #444;
}

.legend-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #aaa;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 4px 0;
    font-size: 11px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    margin-right: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Loading */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #00e676;
    z-index: 2000;
}

/* Popup styling */
.leaflet-popup-content-wrapper {
    background: #1e1e1e;
    color: #fff;
    border-radius: 8px;
}

.leaflet-popup-tip {
    background: #1e1e1e;
}

.leaflet-popup-content,
.popup-content {
    max-height: 60vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.popup-content {
    padding: 5px;
}

.popup-content div {
    margin: 5px 0;
    font-size: 13px;
}

.popup-label {
    color: #aaa;
    display: inline-block;
    width: 80px;
}

/* Theme toggle button */
.theme-toggle {
    position: absolute;
    top: 10px;
    right: 60px;
    background: rgba(30, 30, 30, 0.95);
    padding: 10px;
    border-radius: 8px;
    z-index: 1000;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    transition: background 0.3s;
}

.theme-toggle:hover {
    background: rgba(50, 50, 50, 0.95);
}

.theme-toggle-icon {
    font-size: 24px;
}

/* Clickable repeater links */
.repeater-link {
    color: #00e676;
    cursor: pointer;
    text-decoration: underline;
    margin: 0 2px;
}

.repeater-link:hover {
    color: #00ff88;
}

/* Modal for repeater details */
.modal {
    display: none;
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

body.modal-open { overflow: hidden; }

.modal.show {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    touch-action: none;
    overscroll-behavior: contain;
}

.modal-content {
    background: #1e1e1e;
    color: #fff;
    padding: 16px 16px 20px 16px;
    border-radius: 12px 12px 0 0;
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: #666;
    border-radius: 2px;
    margin: 0 auto 10px auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #00e676;
}

.modal-close {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: #fff;
}

.signal-entry {
    padding: 10px;
    margin: 8px 0;
    background: rgba(0, 230, 118, 0.1);
    border-radius: 4px;
    border-left: 3px solid #00e676;
}

.signal-entry div {
    margin: 4px 0;
    font-size: 13px;
}

.signal-label {
    color: #aaa;
    display: inline-block;
    width: 80px;
}

/* Resolution select */
.resolution-select {
    width: 100%;
    padding: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.resolution-select option {
    background: #2a2a2a;
    color: #fff;
}

/* Measure tool */
.measure-control {
    position: absolute;
    top: 70px;
    right: 10px;
    background: rgba(30, 30, 30, 0.95);
    padding: 10px;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    min-width: 200px;
    transition: transform 0.3s, opacity 0.3s;
}

.measure-control.hidden {
    transform: translateX(110%);
    opacity: 0;
    pointer-events: none;
}

.measure-btn {
    width: 100%;
    padding: 8px;
    background: #00e676;
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.3s;
}

.measure-btn:hover {
    background: #00c853;
}

.measure-btn.active {
    background: #ff5252;
}

.measure-btn.active:hover {
    background: #ff1744;
}

.unit-selector {
    margin-top: 8px;
    display: flex;
    gap: 4px;
}

.unit-btn {
    flex: 1;
    padding: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s;
}

.unit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.unit-btn.active {
    background: #00e676;
    color: #000;
    border-color: #00e676;
}

.measure-info {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 230, 118, 0.1);
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
    display: none;
}

.measure-info.show {
    display: block;
}

.measure-distance {
    font-size: 18px;
    font-weight: 700;
    color: #00e676;
    margin: 4px 0;
}

/* Mobile-friendly controls */
.menu-button {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(30, 30, 30, 0.95);
    padding: 12px;
    border-radius: 8px;
    z-index: 1001;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    font-size: 24px;
    line-height: 1;
    transition: background 0.3s;
}

.menu-button:hover {
    background: rgba(50, 50, 50, 0.95);
}

.tools-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(30, 30, 30, 0.95);
    padding: 12px;
    border-radius: 8px;
    z-index: 1001;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    font-size: 24px;
    line-height: 1;
    transition: background 0.3s;
}

.tools-button:hover {
    background: rgba(50, 50, 50, 0.95);
}

/* Time-lapse controls */
.timelapse-control {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.95);
    padding: 12px 16px;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    min-width: 320px;
    max-width: calc(100vw - 40px);
    display: none;
}

.timelapse-control.show {
    display: block;
}

.timelapse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.timelapse-title {
    font-size: 13px;
    font-weight: 600;
    color: #00e676;
}

.timelapse-date {
    font-size: 13px;
    color: #fff;
    font-weight: 500;
}

.timelapse-slider {
    width: 100%;
    margin: 4px 0;
    accent-color: #00e676;
}

.timelapse-buttons {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.timelapse-btn {
    flex: 1;
    padding: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.timelapse-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.timelapse-btn.active {
    background: #00e676;
    color: #000;
    border-color: #00e676;
}

/* Light theme overrides */
body.light-theme {
    background: #f5f5f5;
    color: #000000;
}

body.light-theme .info-panel {
    background: rgba(255, 255, 255, 0.95);
    color: #000000;
}

body.light-theme .info-panel h2 {
    color: #00c853;
}

body.light-theme .stat-label {
    color: #666;
}

body.light-theme .stat-value {
    color: #000;
}

body.light-theme .layer-toggles {
    border-top-color: #ddd;
}

body.light-theme .theme-toggle {
    background: rgba(255, 255, 255, 0.95);
    color: #000;
}

body.light-theme .theme-toggle:hover {
    background: rgba(240, 240, 240, 0.95);
}

body.light-theme .leaflet-popup-content-wrapper {
    background: #ffffff;
    color: #000;
}

body.light-theme .leaflet-popup-tip {
    background: #ffffff;
}

body.light-theme .popup-label {
    color: #666;
}

body.light-theme .repeater-link {
    color: #00c853;
}

body.light-theme .repeater-link:hover {
    color: #00a03e;
}

body.light-theme .modal-content {
    background: #ffffff;
    color: #000;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}

body.light-theme .modal-header {
    border-bottom-color: #ddd;
}

body.light-theme .modal-title {
    color: #00c853;
}

body.light-theme .modal-close:hover {
    color: #000;
}

body.light-theme .signal-entry {
    background: rgba(0, 200, 83, 0.1);
    border-left-color: #00c853;
}

body.light-theme .signal-label {
    color: #666;
}

body.light-theme .resolution-select {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .resolution-select option {
    background: #ffffff;
    color: #000;
}

body.light-theme .measure-control {
    background: rgba(255, 255, 255, 0.95);
}

body.light-theme .unit-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .unit-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

body.light-theme .measure-distance {
    color: #00c853;
}

body.light-theme .menu-button {
    background: rgba(255, 255, 255, 0.95);
}

body.light-theme .menu-button:hover {
    background: rgba(240, 240, 240, 0.95);
}

body.light-theme .tools-button {
    background: rgba(255, 255, 255, 0.95);
}

body.light-theme .tools-button:hover {
    background: rgba(240, 240, 240, 0.95);
}

body.light-theme .legend {
    border-top-color: #ddd;
}

body.light-theme .legend-title {
    color: #666;
}

body.light-theme .legend-color {
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .timelapse-control {
    background: rgba(255, 255, 255, 0.95);
}

body.light-theme .timelapse-title {
    color: #00c853;
}

body.light-theme .timelapse-date {
    color: #000;
}

body.light-theme .timelapse-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .timelapse-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Repeater markers */
.repeater-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .info-panel {
        min-width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
    }

    .measure-control {
        min-width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
    }

    .theme-toggle {
        display: block;
        top: 60px;
        right: 10px;
        z-index: 1002;
    }

    .timelapse-control {
        min-width: calc(100vw - 40px);
    }
}
