/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

header {
    background-color: #0a4975;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.5rem;
    margin-right: 20px;
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.control-button {
    background-color: #0d6efd;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.control-button:hover {
    background-color: #0b5ed7;
}

#dataSourceLabel, #cellCount {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    margin-left: 10px;
}

.main-content {
    display: flex;
    flex: 1;
    position: relative;
}

.map-container {
    flex: 1;
    height: 100%;
}

/* Filter Panel */
.filter-panel {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 320px;
    background: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.filter-panel.hidden {
    transform: translateX(-100%);
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.filter-scrollable {
    height: calc(100% - 60px);
    overflow-y: auto;
    padding: 0 15px 15px;
}

.filter-group {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.filter-group h3 {
    margin: 15px 0 10px;
    font-size: 16px;
    color: #0a4975;
}

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

.toggle-switch input[type="checkbox"] {
    height: 0;
    width: 0;
    visibility: hidden;
    position: absolute;
}

.toggle-switch label {
    cursor: pointer;
    width: 40px;
    height: 20px;
    background: #ccc;
    display: block;
    border-radius: 100px;
    position: relative;
}

.toggle-switch label:after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 90px;
    transition: 0.3s;
}

.toggle-switch input:checked + label {
    background: #0d6efd;
}

.toggle-switch input:checked + label:after {
    left: calc(100% - 2px);
    transform: translateX(-100%);
}

/* Dual Range Slider */
.dual-range {
    position: relative;
    height: 40px;
    margin: 15px 0;
}

.range-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 6px;
    background: #e0e0e0;
    transform: translateY(-50%);
    border-radius: 3px;
}

.range-track-highlight {
    position: absolute;
    top: 50%;
    height: 6px;
    background: #0d6efd;
    transform: translateY(-50%);
    border-radius: 3px;
}

.dual-range input {
    position: absolute;
    width: 100%;
    top: 50%;
    height: 6px;
    margin: 0;
    transform: translateY(-50%);
    -webkit-appearance: none;
    background: transparent;
    pointer-events: none;
}

.dual-range input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0d6efd;
    cursor: pointer;
    pointer-events: auto;
    margin-top: -7px;
}

.dual-range input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0d6efd;
    cursor: pointer;
    pointer-events: auto;
    border: none;
}

.dual-range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: -5px;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    color: white;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid white;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 18px;
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 350px;
    background-color: #333;
    color: white;
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
    z-index: 1500;
    transition: transform 0.3s, opacity 0.3s;
    transform: translateY(100px);
    opacity: 0;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.success {
    background-color: #28a745;
}

.notification.warning {
    background-color: #ffc107;
    color: #333;
}

.notification.error {
    background-color: #dc3545;
}

/* Changes panel */
.changes-panel {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 10px;
    margin-top: 10px;
    border-radius: 4px;
}

.changes-panel h3 {
    font-size: 16px;
    margin-bottom: 5px;
}

/* Marker popup customization */
.leaflet-popup-content {
    max-width: 300px;
    max-height: 400px;
    overflow-y: auto;
}

.cell-popup {
    font-size: 14px;
}

.cell-popup h3 {
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.cell-popup table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.cell-popup table td {
    padding: 4px 0;
}

.cell-popup table td:first-child {
    font-weight: bold;
    width: 40%;
}

.cell-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 5px;
    border-top: 1px solid #eee;
}

.cell-navigation button {
    background-color: #0d6efd;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.cell-navigation button:hover {
    background-color: #0b5ed7;
}

.cell-navigation-text {
    font-size: 12px;
    color: #666;
    align-self: center;
}

/* Modal styles for changes display */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    border-radius: 4px;
    width: 80%;
    max-width: 900px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.modal-body {
    padding: 15px;
    overflow-y: auto;
}

.changes-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    margin: 15px 0;
}

.tab-button {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    opacity: 0.7;
}

.tab-button.active {
    border-bottom: 2px solid #0a4975;
    opacity: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.changes-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.changes-table th, .changes-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.changes-table th {
    background-color: #f8f9fa;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    header h1 {
        margin-bottom: 10px;
    }
    
    .top-controls {
        margin-left: 0;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
    }
    
    .filter-panel {
        width: 100%;
        height: 80%;
        top: auto;
        bottom: 0;
        transform: translateY(100%);
    }
    
    .filter-panel.hidden {
        transform: translateY(100%);
    }
    
    .filter-panel:not(.hidden) {
        transform: translateY(0);
    }
}
