body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

/* --- Search Bar --- */
#search-container {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 10;
    width: 320px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#search-input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    outline: none;
    font-size: 14px;
    border-radius: 8px 0 0 8px;
}

#search-button {
    padding: 10px 15px;
    border: none;
    background-color: #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 8px 8px 0;
    transition: background-color 0.2s;
}

#search-button:hover {
    background-color: #e0e0e0;
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 2px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-results.visible {
    display: block;
}

.search-results-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.search-result-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item .title {
    font-weight: 500;
    margin-bottom: 2px;
    color: #333;
}

.search-result-item .subtitle {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-show-more {
    padding: 10px;
    text-align: center;
    border-top: 1px solid #eee;
    background-color: #f9f9f9;
}

#show-more-btn {
    background: none;
    border: none;
    color: #0066cc;
    cursor: pointer;
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 4px;
}

#show-more-btn:hover {
    background-color: #f0f0f0;
    text-decoration: underline;
}

/* --- GPS/Geolocation Control --- */
.maplibregl-ctrl-top-right {
    top: 15px;
    right: 15px;
}
.maplibregl-ctrl-group button {
    width: 32px !important;
    height: 32px !important;
}

/* --- Table Toggle Button --- */
#table-toggle-container {
    position: absolute;
    bottom: 20px;
    left: 15px;
    z-index: 10;
}

#toggle-table-btn {
    width: 40px;
    height: 40px;
    background-color: #fff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toggle-table-btn:hover {
    background-color: #f0f0f0;
}

/* --- NEW & IMPROVED DATA TABLE STYLES --- */
#table-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 40vh;
    min-height: 150px;
    max-height: 90vh;
    background-color: #fff;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 20;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out, height 0.3s ease-in-out, width 0.3s ease-in-out, left 0.3s ease-in-out, top 0.3s ease-in-out;
}

#table-container:not(.hidden) {
    transform: translateY(0);
}

/* Resizer Handles */
.resizer {
    position: absolute;
    background: transparent;
    z-index: 30; /* Higher than other elements */
}

/* --- PAGINATION STYLES --- */
.table-pagination-container {
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #555;
}

.pagination-controls button {
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pagination-controls button:hover:not(:disabled) {
    background-color: #e9e9e9;
}

.pagination-controls button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#resizer-top { top: -5px; left: 0; right: 0; height: 10px; cursor: ns-resize; }
#resizer-bottom { bottom: -5px; left: 0; right: 0; height: 10px; cursor: ns-resize; }
#resizer-left { left: -5px; top: 0; bottom: 0; width: 10px; cursor: ew-resize; }
#resizer-right { right: -5px; top: 0; bottom: 0; width: 10px; cursor: ew-resize; }
#resizer-top-left { top: -5px; left: -5px; width: 10px; height: 10px; cursor: nwse-resize; }
#resizer-top-right { top: -5px; right: -5px; width: 10px; height: 10px; cursor: nesw-resize; }
#resizer-bottom-left { bottom: -5px; left: -5px; width: 10px; height: 10px; cursor: nesw-resize; }
#resizer-bottom-right { bottom: -5px; right: -5px; width: 10px; height: 10px; cursor: nwse-resize; }

/* Header and Controls */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    cursor: grab;
}
.floating .table-header { cursor: grab; }
.floating .table-header:active { cursor: grabbing; }

#table-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.control-buttons { display: flex; gap: 4px; }
.control-btn {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
}
.control-btn:hover { background-color: #e9e9e9; }

/* Table Filter - FIXED */
.table-filter-container {
    padding: 8px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}
#table-filter-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

/* Table Content Wrapper */
#data-table-wrapper {
    flex-grow: 1;
    overflow: auto;
}
#data-table {
    width: 100%;
    border-collapse: collapse;
}
#data-table th, #data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    font-size: 13px;
    white-space: nowrap;
}
#data-table thead {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 1;
}
#data-table tbody tr:hover {
    background-color: #f1f3f5;
    cursor: pointer;
}

/* Table States */
#table-container.minimized {
    height: 48px !important;
    overflow: hidden;
}
#table-container.fullscreen {
    height: 100vh !important;
    top: 0 !important;
    bottom: 0;
    left: 0 !important;
    width: 100% !important;
    max-height: 100vh;
    z-index: 1000;
}
#table-container.floating {
    height: 50vh;
    width: 60vw;
    left: 20vw;
    bottom: 5vh;
    top: auto;
    right: auto;
    border-radius: 8px;
    border: 1px solid #ccc;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    resize: both;
    overflow: hidden;
}
#table-container.floating #resize-handle {
    cursor: nwse-resize; /* Allow resizing from all corners in float mode */
}

/* --- Search Results Dropdown --- */
#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
}

#search-results.show {
    display: block;
}

.search-result-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-item h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #333;
}

.search-result-item p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

#show-more-results {
    display: block;
    width: 100%;
    padding: 8px;
    text-align: center;
    background-color: #f8f9fa;
    border: none;
    border-top: 1px solid #eee;
    color: #007bff;
    cursor: pointer;
    font-size: 13px;
}

#show-more-results:hover {
    background-color: #e9ecef;
}

/* --- CUSTOM MAP CONTROLS --- */

/* Ensure all control groups have a consistent bottom margin for even spacing */
.maplibregl-ctrl-group {
    margin-bottom: 10px !important;
}

/* Remove bottom margin from the very last control in the corner */
.maplibregl-ctrl-top-right > .maplibregl-ctrl:last-child .maplibregl-ctrl-group {
    margin-bottom: 0 !important;
}