/* --- General Layout --- */
html, body {
    height: 100%; margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
    touch-action: manipulation;
}

/* Prevent ugly text selection on UI elements */
.leaflet-bar a, .leaflet-control-district-filter, #bottom-nav, .project-list-item, .modal-content, .nav-tab, #district-filter-select, #map-settings-menu a, .legend-item {
    -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Map Container (Leave space for bottom nav) */
#map { height: calc(100% - 60px); width: 100%; } 

.leaflet-control-attribution { display: none; }

/* --- Custom Popup Styles --- */
.custom-popup .leaflet-popup-content-wrapper { background: #ffffff; color: #333; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.custom-popup .leaflet-popup-content { margin: 0; padding: 0; width: 240px !important; font-size: 14px; }

.custom-popup .popup-header { 
    background-color: #A7D9EE; color: #333; 
    padding: 10px 15px; font-size: 16px; font-weight: bold; 
    border-top-left-radius: 8px; border-top-right-radius: 8px; text-align: center; 
}

/* Red header for incomplete projects */
.custom-popup.incomplete .popup-header { 
    background-color: #dc3545; 
    color: #ffffff; 
}

/* Violet header for Commission projects */
.custom-popup.commission .popup-header { 
    background-color: #e2d9f3; 
    color: #6f42c1; 
}

.custom-popup .popup-body { padding: 15px; text-align: left; }
.custom-popup .popup-row { margin-bottom: 10px; }
.custom-popup .popup-link { display: block; margin: 15px; padding: 10px; background-color: #B2D8B2; color: #333 !important; text-decoration: none; border-radius: 5px; text-align: center; font-weight: bold; transition: background-color 0.2s ease; }
.custom-popup .popup-link:hover { background-color: #9ECBAD; }

/* --- Sidebar Styles --- */
#project-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 60px); /* Fill space above tab bar */
    background: #f9f9f9;
    box-shadow: 2px 0 8px rgba(0,0,0,0.2);
    z-index: 2000;
    transition: transform 0.3s ease-in-out;
    transform: translateX(100%); /* Start off-screen */
    display: flex;
    flex-direction: column;
}
#project-sidebar.visible {
    transform: translateX(0); /* Slide into view */
}
#project-sidebar h2 { margin: 0; padding: 18px 15px; background: #007aff; color: white; font-size: 18px; }
#project-sidebar .close-btn { position: absolute; top: 10px; right: 15px; font-size: 28px; color: white; text-decoration: none; line-height: 1; cursor: pointer; }

/* Filter Container */
.filter-container {
    padding: 10px;
    background-color: #f1f1f1;
    border-bottom: 1px solid #ddd;
    display: flex; /* Use flexbox for alignment */
    gap: 10px; /* Add space between items */
}
#filter-input {
    width: 100%;
    flex-grow: 1; /* Allow input to take remaining space */
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}
/* Select dropdown */
#district-filter-select {
    width: 130px; /* Fixed width */
    padding: 8px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    font-weight: 600;
    box-sizing: border-box;
}

#project-list { overflow-y: auto; flex-grow: 1; }
.project-list-item { display: block; padding: 12px 15px; border-bottom: 1px solid #ddd; color: #333; text-decoration: none; transition: background-color 0.2s ease; }
.project-list-item:hover { background-color: #e9e9e9; text-decoration: none; color: #0056b3; cursor: pointer; }

/* List Item Indicators */
.project-list-item.incomplete { 
    border-left: 5px solid #d9534f; 
    background-color: #b14747ff; 
}
/* Ensure child text elements are also white in incomplete items */
.project-list-item.incomplete .customer-name,
.project-list-item.incomplete .qaror-number {
    color: #ffffff !important;
}
.project-list-item.commission { 
    border-left: 5px solid #6f42c1; 
    background-color: #fbf9ff; 
}

.project-list-item .customer-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; display: block; }
.project-list-item .qaror-number { color: #555; font-size: 13px; }

/* --- Map Settings Popup Menu --- */
#map-settings-menu {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1500; /* Below modal, above map */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
    display: none;
}
#map-settings-menu a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}
#map-settings-menu a:not(:last-child) {
    border-bottom: 1px solid rgba(0,0,0,0.1);
}
#map-settings-menu a:active {
    background-color: rgba(0,0,0,0.1);
}
#map-settings-menu a svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    margin-right: 12px;
    opacity: 0.7;
}

/* --- Bottom Tab Bar --- */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    z-index: 2100; /* Above sidebar */
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.nav-tab {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    color: #555;
    font-size: 11px;
    font-weight: 500;
    transition: color 0.2s ease;
}
.nav-tab.active {
    color: #007aff; /* Match modal icon color */
}
/* Make sure the "About" tab doesn't get an active state */
.nav-tab[data-view="modal"]:active, .nav-tab[data-view="modal"]:focus {
    color: #555; 
}
.nav-tab svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    margin-bottom: 2px;
}

/* --- Legend Control --- */
.info.legend {
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    border: 1px solid rgba(0,0,0,0.1);
}
.info.legend h4 {
    margin: 0 0 5px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}
/* --- Clickable Legend Items CSS --- */
.legend-item {
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}
.legend-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.info.legend i {
    width: 18px;
    height: 18px;
    float: left;
    margin-right: 8px;
    opacity: 0.9;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.2);
}

/* --- About Modal --- */
.info-modal {
     position: fixed; top: 0; left: 0; width: 100%; height: 100%;
     background-color: rgba(0, 0, 0, 0.5); display: flex;
     justify-content: center; align-items: center; z-index: 3000;
     opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0s 0.3s linear;
 }
 .info-modal.visible { opacity: 1; visibility: visible; transition: opacity 0.3s ease; }
 .modal-content {
     background-color: #fff; padding: 25px 30px; border-radius: 10px;
     max-width: 500px; width: 90%; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
     position: relative; line-height: 1.6;
     max-height: 80vh; overflow-y: auto;
 }
.modal-content h2 {
     display: flex; align-items: center; justify-content: center;
     margin-bottom: 20px; margin-top: 0; color: #333; font-size: 1.4em;
 }
.modal-content h2 svg { margin-right: 10px; width: 28px; height: 28px; fill: #007aff; }
 .modal-content .section {
     margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid #eee;
 }
 .modal-content .section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
 .modal-content .section h3 {
     display: flex; align-items: center; font-size: 1.15em;
     color: #333; margin-top: 0; margin-bottom: 10px;
 }
 .modal-content .section h3 svg { margin-right: 8px; width: 20px; height: 20px; fill: #555; }
 .modal-content p { margin-bottom: 15px; color: #555; font-size: 1em; }
 .modal-content strong { color: #111; }
 .modal-content ol, .modal-content ul { padding-left: 25px; margin-top: 10px; }
 .modal-content ol li, .modal-content ul li { margin-bottom: 8px; color: #444; }
 .modal-content ul { list-style-type: disc; } 
 .modal-content .warning-text { color: #dc3545; font-weight: 600; }
 .modal-content .contact-info {
     margin-top: 20px; padding-top: 15px; border-top: 1px solid #eee;
     font-size: 0.95em; color: #666;
 }
 .modal-content .contact-info strong { color: #333; }
 .close-modal-btn {
     position: absolute; top: 10px; right: 15px; font-size: 28px; font-weight: bold;
     color: #aaa; cursor: pointer; line-height: 1;
 }
 .close-modal-btn:hover { color: #333; }
 
/* Leaflet Control Overrides */
.leaflet-bar, .leaflet-control-district-filter {
    background-color: rgba(255, 255, 255, 0) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.leaflet-bar a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 1.3rem;
    color: #333 !important;
    background: transparent !important;
    border: none !important;
    transition: background-color 0.2s ease;
}
.leaflet-bar a:hover { background-color: rgba(0, 0, 0, 0.05) !important; }

/* Map Settings Button Icon Size */
.leaflet-bar a.map-settings-button {
    font-size: 20px;
    line-height: 36px !important;
}