/* Export Modal Styles */
#export-modal.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.25);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
#export-modal.hidden {
    display: none;
}
#export-modal .modal-content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.18);
    padding: 24px 28px;
    min-width: 320px;
    max-width: 90vw;
    position: relative;
}
#export-modal .close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5em;
    cursor: pointer;
    color: #888;
}
#export-modal h2 {
    margin-top: 0;
    font-size: 1.2em;
    margin-bottom: 12px;
}
#export-modal label {
    font-weight: 500;
    margin-right: 8px;
}
#export-modal input[type="checkbox"] {
    margin-right: 4px;
}
#export-modal button {
    background: #2196F3;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 1em;
    cursor: pointer;
    margin-top: 8px;
}
#export-modal button:hover {
    background: #1976D2;
}

/* Merge Attribute Selection Modal Styles */
#merge-attribute-modal .attribute-item {
    transition: background-color 0.2s ease;
}
#merge-attribute-modal .attribute-item:hover {
    background-color: #f8f9fa !important;
}
#merge-attribute-modal .modal-body {
    padding: 20px;
}
#merge-attribute-modal #merge-attributes-list {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    background: #fafafa;
    max-height: 400px;
    overflow-y: auto;
}
#merge-attribute-modal .attribute-item input[type="checkbox"] {
    transform: scale(1.1);
    cursor: pointer;
}
#merge-attribute-modal .attribute-item:last-child {
    margin-bottom: 0;
}
@media (max-width: 600px) {
    #layers-menu {
        min-width: 98vw;
        max-width: 98vw;
        left: 0;
        right: 0;
        margin-top: 0;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    .layers-header {
        padding: 10px 12px;
        font-size: 15px;
        text-align: center;
    }
    #layers-list {
        padding: 6px;
        max-height: 220px;
        overflow-y: auto;
    }
    .layer-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 8px;
        margin-bottom: 6px;
        gap: 6px;
        font-size: 13px;
    }
    .layer-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        width: 100%;
        word-break: break-word;
    }
    .layer-name {
        font-size: 14px;
        font-weight: 500;
        color: #333;
        word-break: break-word;
        max-width: 90vw;
    }
    .layer-controls {
        gap: 10px;
        width: 100%;
        justify-content: flex-start;
    }
    .layer-controls .layer-opacity {
        width: 70px;
    }
    /* Removed conflicting early mobile blocks in favor of a single consolidated block below */
    .layer-toggle {
        width: 56px;
        height: 32px;
        position: relative;
        flex: 0 0 auto;
    }
    .slider {
        height: 32px;
        border-radius: 999px;
        background-color: #cfd8dc;
        box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
        transition: background-color 0.25s ease, box-shadow 0.25s ease;
        touch-action: manipulation;
    }
    .slider:before {
        height: 28px;
        width: 28px;
        left: 2px;
        bottom: 2px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        transition: transform 0.25s ease;
    }
    input:checked + .slider {
        background-color: #34C759; /* iOS green */
    }
    input:checked + .slider:before {
        transform: translateX(24px);
    }
    .layer-toggle input:focus + .slider {
        box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.3);
    }
}
:root {
    --toolbar-height: 56px;
}
/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Toolbar styles */
#toolbar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: var(--toolbar-height);
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1500; /* above map content, below modals (2000) */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Search */
#search-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-input {
    width: 260px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1600;
}

.search-results .result-item {
    padding: 8px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-results .result-item:hover {
    background: #f3f4f6;
}

.toolbar-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.3s;
}

.toolbar-btn:hover {
    background: #45a049;
}

.toolbar-btn:active {
    background: #3d8b40;
}

/* Layers panel */
#layers-panel {
    position: relative;
}

#layers-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    min-width: 250px;
    z-index: 1001;
    margin-top: 5px;
}

.layers-header {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.layers-header h3 {
    font-size: 16px;
    color: #333;
}

#layers-list {
    padding: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 4px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.layer-item:hover {
    background: #e9ecef;
}

.layer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.layer-name {
    font-weight: 500;
    color: #333;
}

.layer-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* removed unused .layer-color */

.layer-controls .layer-opacity {
    width: 90px;
}

.layer-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.layer-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.attribute-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.attribute-btn:hover {
    background: #1976D2;
}

/* Map styles */
#map {
    flex: 1;
    min-height: 300px;
    height: calc(100vh - var(--toolbar-height));
    margin-top: 0;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Modal styles */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 1000px;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.modal-toolbar {
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn:hover {
    background: #5a6268;
}

.btn-primary {
    background: #007bff;
}

.btn-primary:hover {
    background: #0056b3;
}

.table-container {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid #eee;
    background: #fafafa;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.form-field label {
    font-size: 13px;
    color: #555;
}

.form-field input {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 14px;
}

.form-field select {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.form-field textarea {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
}

#attribute-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#attribute-table th,
#attribute-table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

#attribute-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
}

#attribute-table td {
    background: white;
}

#attribute-table td input {
    border: none;
    background: transparent;
    width: 100%;
    padding: 4px;
    font-size: 14px;
}

#attribute-table td input:focus {
    outline: 2px solid #007bff;
    background: #f8f9ff;
}

.delete-row-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
}

.delete-row-btn:hover {
    background: #c82333;
}

/* Drawing controls */
.leaflet-draw-toolbar {
    display: none !important;
}

/* Custom drawing button active state */
.toolbar-btn.active {
    background: #ff9800;
}

.toolbar-btn.active:hover {
    background: #f57c00;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    :root {
        --toolbar-height: 56px;
    }
    body {
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
    }
    #app {
        min-height: 100vh;
    }
    #toolbar {
        flex-direction: column;
        align-items: stretch;
        height: auto;
        padding: 6px;
        gap: 6px;
        position: sticky;
        top: 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    }
    .toolbar-btn {
        font-size: 15px;
        padding: 12px 0;
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
    #search-container {
        width: 100%;
        flex-direction: column;
        gap: 4px;
    }
    .search-input {
        width: 100%;
        font-size: 15px;
        padding: 10px 8px;
    }
    #layers-menu {
        min-width: 98vw;
        max-width: 98vw;
        left: 0;
        right: 0;
        margin-top: 0;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    .modal-content {
        width: 98%;
        max-width: 98vw;
        max-height: 90vh;
        padding: 8px;
    }
    .modal-header {
        padding: 12px 12px;
        font-size: 15px;
    }
    .table-container {
        padding: 10px;
    }
    .form-field input {
        font-size: 15px;
        padding: 10px 8px;
    }
    #attribute-table th, #attribute-table td {
        padding: 8px 6px;
        font-size: 14px;
    }
    #map {
        margin-top: 0;
        min-height: 300px;
        height: 60vh;
        width: 100vw;
    }
}

/* File Upload Styles */
.file-input-container {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    background: #fafafa;
}

.upload-progress {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 8px;
    border: 1px solid #e9ecef;
}

.upload-progress .progress-bar {
    background: #007bff;
    height: 4px;
    border-radius: 2px;
    transition: width 0.3s ease;
    margin-bottom: 4px;
}

.upload-progress .progress-text {
    font-size: 12px;
    color: #666;
    text-align: center;
    display: block;
}

.file-input-container .btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s;
}

.file-input-container .btn:hover {
    background: #0056b3;
}

.file-input-container input[type="text"] {
    background-color: #f8f9fa !important;
    color: #495057;
    border: 1px solid #ced4da;
}

/* Mobile file upload adjustments */
@media (max-width: 600px) {
    .file-input-container {
        padding: 8px;
    }
    
    .file-input-container .btn {
        font-size: 14px;
        padding: 10px 12px;
        width: 100%;
        justify-content: center;
    }
    
    .upload-progress {
        padding: 6px;
    }
    
    .upload-progress .progress-text {
        font-size: 13px;
    }
}

/* File Preview Modal Styles */
#file-preview-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#file-preview-modal.hidden {
    display: none !important;
}

#file-preview-modal .modal-content {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: modalFadeIn 0.3s ease;
}

#file-preview-modal .modal-header {
    padding: 20px 20px 10px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#file-preview-modal .modal-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: #333;
}

#file-preview-modal .close {
    font-size: 24px;
    cursor: pointer;
    color: #666;
    background: none;
    border: none;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

#file-preview-modal .close:hover {
    background-color: #f0f0f0;
    color: #333;
}

#file-preview-modal .modal-body {
    padding: 0;
    overflow-y: auto;
    max-height: calc(90vh - 120px);
}

#file-preview-modal img {
    transition: opacity 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile responsiveness for file preview */
@media (max-width: 768px) {
    #file-preview-modal .modal-content {
        max-width: 95vw;
        max-height: 95vh;
        margin: 10px;
    }
    
    #file-preview-modal .modal-header {
        padding: 15px;
    }
    
    #file-preview-modal .modal-header h3 {
        font-size: 1.1em;
    }
    
    #file-preview-modal .modal-body {
        max-height: calc(95vh - 100px);
    }
}
