/* style.css */
html, body { 
    height: 100%; 
    width: 100%; 
    margin: 0; 
    padding: 0; 
    font-family: Arial, sans-serif; 
    display: flex; 
    flex-direction: column;
    -webkit-tap-highlight-color: transparent; 
}

#map-container { 
    flex-grow: 1; 
    position: relative; 
}

#map { 
    height: 100%; 
    width: 100%; 
}

.legend, .controls-container, #inline-table-display-area, #toggle-menu-button {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out, left 0.3s ease-in-out; 
}


.legend {
    padding: 6px 10px; 
    font: 11px Arial, Helvetica, sans-serif;
    background: white; 
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 15px rgba(0,0,0,0.2); 
    border-radius: 5px;
    line-height: 16px; 
    color: #333; 
    max-height: 350px; 
    overflow-y: auto; 
    position: absolute;
    bottom: 30px; 
    right: 10px;
    z-index: 1000; 
}
.legend h4 { 
    margin: 0 0 5px; 
    color: #333; 
    text-align: center; 
}
.legend i { 
    width: 16px; 
    height: 16px; 
    float: left; 
    margin-right: 6px; 
    opacity: 0.85; 
    border: 1px solid #999;
}

#loading-indicator {
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7); 
    color: white; 
    padding: 15px 25px;
    border-radius: 6px; 
    z-index: 10001; 
    font-size: 16px; 
    display: none;
}

.controls-container {
    position: absolute;
    top: 10px;
    left: 10px; 
    background: rgba(255, 255, 255, 0.85); 
    padding: 10px;
    border-radius: 5px; 
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    z-index: 1001; 
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 250px; 
    max-width: 90%; 
    box-sizing: border-box;
}
.control-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}
.control-item label { 
    font-size: 13px; 
    white-space: nowrap; 
    cursor: pointer;
}
.control-item input[type="range"] { 
    flex-grow: 1; 
    min-width: 60px; 
    margin-right: 8px;
}
.control-item input[type="number"] { 
    width: 45px; 
    padding: 3px 5px;
    box-sizing: border-box;
    text-align: right;
}
.control-item button { 
    padding: 5px 8px; 
    font-size: 11px; 
    cursor: pointer; 
    flex-shrink: 0; 
}
.control-item input[type="checkbox"] { 
    margin-right: 0px; 
    cursor: pointer;
}

body.dark-theme .legend { 
    background: rgba(50,50,50,0.9); 
    color: #f0f0f0; 
}
body.dark-theme .legend h4 { 
    color: #f0f0f0; 
}
body.dark-theme .legend i { 
    border-color: #666; 
}
body.dark-theme .controls-container { 
    background: rgba(40, 40, 40, 0.9); 
    color: #f0f0f0; 
}
body.dark-theme .control-item label { 
    color: #f0f0f0; 
}

.hexagon-label {
    font-weight: bold;
    color: #000000; 
    background-color: rgba(255, 255, 255, 0.75); 
    padding: 1px 3px; 
    border-radius: 3px; 
    white-space: nowrap; 
    text-align: center; 
    pointer-events: none; 
    box-shadow: 0px 0px 1px rgba(0,0,0,0.5); 
    display: flex; 
    align-items: center; 
    justify-content: center;
}

body.dark-theme .hexagon-label {
    color: #FFFFFF; 
    background-color: rgba(20, 20, 20, 0.75); 
    box-shadow: 0px 0px 1px rgba(255,255,255,0.5);
}

.leaflet-control-scale-line {
    border: 2px solid #777;
    border-top: none;
    color: #333; 
    background-color: rgba(255, 255, 255, 0.7); 
    padding: 2px 5px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4); 
    border-radius: 3px; 
    margin-bottom: 2px; 
}
body.dark-theme .leaflet-control-scale-line {
    border-color: #bbb;
    color: #eee;
    background-color: rgba(40, 40, 40, 0.7);
}

#inline-table-display-area {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.95); 
    border: 1px solid #ccc;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-radius: 0 0 5px 5px; 
    z-index: 1000; 
    display: none; 
    flex-direction: column; 
    box-sizing: border-box;
}

body.dark-theme #inline-table-display-area {
    background-color: rgba(50, 50, 50, 0.95);
    border-color: #555;
    color: #f0f0f0;
}

#inline-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background-color: #f0f0f0;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
    box-sizing: border-box;
}
body.dark-theme #inline-table-header {
    background-color: #444;
    border-bottom-color: #555;
}

#inline-table-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
}

#close-inline-table-button {
    background: none;
    border: none;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}
body.dark-theme #close-inline-table-button {
    color: #f0f0f0;
}


#inline-table-content {
    overflow-y: auto; 
    flex-grow: 1; 
    padding: 0 5px 5px 5px; 
    box-sizing: border-box;
}

#inline-table-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

#inline-table-content th, 
#inline-table-content td {
    border: 1px solid #ddd;
    padding: 4px 6px;
    text-align: left;
    box-sizing: border-box;
}

#inline-table-content th {
    background-color: #e9e9e9;
    font-weight: bold;
    position: sticky; 
    top: 0;           
    z-index: 1;       
}
#inline-table-content th.sortable {
    cursor: pointer;
}
#inline-table-content th.sortable:hover {
    background-color: #dcdcdc;
}
body.dark-theme #inline-table-content th.sortable:hover {
    background-color: #666;
}

.sort-indicator {
    margin-left: 5px;
    font-size: 0.8em; 
}


body.dark-theme #inline-table-content th {
    background-color: #555;
    border-color: #666;
}
body.dark-theme #inline-table-content td {
    border-color: #666;
}

.inline-table-pagination {
    padding: 8px 5px;
    text-align: center;
    border-top: 1px solid #ccc;
    background-color: #f9f9f9;
    box-sizing: border-box;
}
body.dark-theme .inline-table-pagination {
    border-top-color: #555;
    background-color: #404040;
}
.inline-table-pagination button {
    margin: 0 5px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}
.inline-table-pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
.inline-table-pagination span {
    font-size: 12px;
    margin: 0 8px;
}


#toggle-menu-button {
    display: none; 
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1002; 
    font-size: 24px;
    padding: 5px 10px;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1; 
    box-sizing: border-box;
}
body.dark-theme #toggle-menu-button {
    background-color: rgba(40, 40, 40, 0.8);
    border-color: #555;
    color: #f0f0f0;
}


@media (max-width: 768px) { 
    
    #toggle-menu-button {
        display: block; 
    }

    .controls-container {
        transform: translateX(-100%); 
        left: 0; 
        height: calc(100vh - 20px); 
        max-height: calc(100vh - 20px);
        overflow-y: auto;
        border-radius: 0 5px 5px 0; 
    }

    .controls-container.open {
        transform: translateX(0); 
    }

    .legend {
        max-height: 150px; 
        font-size: 10px; 
        right: 5px;      
        bottom: 25px;    
        max-width: 120px; 
    }
    .legend i {
        width: 12px;
        height: 12px;
        margin-right: 4px;
    }

    #inline-table-display-area {
        z-index: 1000; 
    }

    .leaflet-control-zoom-in, .leaflet-control-zoom-out {
        font-size: 1.5em !important; 
        width: 34px !important;      
        height: 34px !important;     
        line-height: 34px !important;
    }
    .leaflet-control-scale-line {
        font-size: 10px; 
        margin-left: 50px; 
    }
    .leaflet-control-layers {
        display: none !important;
    }
}

@media (max-width: 480px) { 
    .controls-container {
        gap: 8px; 
        padding: 8px; 
        width: 220px; 
    }
    .control-item label, .control-item small {
        font-size: 11px; 
    }
    .control-item button {
        font-size: 10px;
        padding: 4px 6px;
    }
    .control-item input[type="number"] {
        width: 35px;
    }
    #inline-table-title {
        font-size: 13px;
    }
    .legend {
        max-height: 120px;
        font-size: 9px;
    }
    .leaflet-control-scale-line {
        margin-left: 45px; 
    }
}

.leaflet-popup-content-wrapper {
}
.leaflet-popup-content {
    max-height: 200px; 
    overflow-y: auto;
    margin: 10px !important; 
    font-size: 12px;
    box-sizing: border-box;
}
.leaflet-popup-content pre {
    white-space: pre-wrap;      
    white-space: -moz-pre-wrap; 
    white-space: -pre-wrap;     
    white-space: -o-pre-wrap;   
    word-wrap: break-word;      
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    padding: 5px;
    margin-top: 5px;
    border-radius: 3px;
    font-size: 11px;
    box-sizing: border-box;
}
body.dark-theme .leaflet-popup-content pre {
    background-color: #333;
    border-color: #555;
    color: #f0f0f0;
}

body.dark-theme .leaflet-tooltip {
    background: rgba(45, 45, 45, 0.92); 
    color: #e8e8e8;                  
    border: 1px solid #585858;       
    box-shadow: 0 1px 5px rgba(0,0,0,0.5); 
    font-size: 11px;
    padding: 5px 8px;
}

body.dark-theme .leaflet-tooltip-top:before {
	border-bottom-color: #585858; 
}
body.dark-theme .leaflet-tooltip-bottom:before {
	border-top-color: #585858;
}
body.dark-theme .leaflet-tooltip-left:before {
	border-right-color: #585858;
}
body.dark-theme .leaflet-tooltip-right:before {
	border-left-color: #585858;
}

#layer-controls-panel {
    border-top: 1px solid #ccc;
    margin-top: 10px;
    padding-top: 10px;
    box-sizing: border-box;
}
body.dark-theme #layer-controls-panel {
    border-top-color: #555;
}

#layer-controls-panel h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    text-align: center;
}

.layer-control-item {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}
#layer-controls-panel .layer-control-item:last-of-type {
    border-bottom: none;
    margin-bottom: 15px;
}
body.dark-theme .layer-control-item {
    border-bottom-color: #444;
}

.layer-main-info {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 6px;
}

.layer-main-info input[type="checkbox"] {
    margin-right: 6px;
    flex-shrink: 0;
    cursor: pointer;
}

.layer-main-info label {
    font-size: 12px;
    flex-grow: 1; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
    margin-right: 8px;
    min-width: 0;
}

.point-layer-toggle-item {
    display: flex;
    align-items: center;
    padding-left: 25px;
}

.point-layer-toggle-item input[type="checkbox"] {
    margin-right: 6px;
    flex-shrink: 0;
    cursor: pointer;
}

.point-layer-toggle-item label {
    font-size: 11px;
    white-space: nowrap;
    cursor: pointer;
}

.layer-weight-input {
    width: 50px; 
    padding: 3px 5px;
    text-align: right;
    box-sizing: border-box;
    flex-shrink: 0;
}
.layer-control-item span {
    font-size: 12px;
    margin-left: 2px;
    flex-shrink: 0;
}

.recalculate-container {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #ccc;
    display: flex;
    flex-direction: column; 
    gap: 8px;
}
body.dark-theme .recalculate-container {
    border-top-color: #555;
}

#recalculate-ratings-button {
    width: 100%; 
    padding: 6px 10px;
    font-size: 13px;
    box-sizing: border-box;
    cursor: pointer;
}

.recalculation-status-text {
    font-size: 11px;
    color: #555;
    min-height: 1.5em; 
    text-align: center;
}

body.dark-theme .recalculation-status-text {
    color: #bbb;
}