/* --- General Layout & Body --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    margin: 0;
    display: flex; /* Make body a flex container */
    background-color: var(--light-grey);
}

.layout {
    display: flex;
    height: 100vh;
    width: 100%;
    margin-left: 60px; /* Offset for the nav bar */
}

#map {
    flex-grow: 1;
    height: 100vh;
}

/* --- Sidebar --- */
#sidebar {
    width: 300px;
    background: #f8f9fa; /* Light gray background */
    padding: 20px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    border-left: 1px solid #dee2e6; /* Subtle border */
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box; /* Ensures padding is included in height */
}

.filters-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0; /* Prevents flexbox overflow issues */
}

#sidebar h3 {
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #007bff; /* Accent color */
    padding-bottom: 10px;
    color: #495057;
}

/* --- Address Search Section --- */
.search-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #dee2e6;
}

.search-section label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    color: #495057;
    font-size: 14px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#address-search {
    width: 100%;
    padding: 10px 35px 10px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    color: #495057;
    box-sizing: border-box;
}

#address-search:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: #6c757d;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.clear-search-btn:hover {
    background-color: #e9ecef;
    color: #495057;
}

.search-status {
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
    min-height: 18px;
}

.search-status.active {
    color: #007bff;
    font-weight: 500;
}

.search-status.info {
    color: #17a2b8;
}

/* Job Search Dropdown */
.job-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.job-search-item {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background-color 0.2s;
}

.job-search-item:hover:not(.disabled) {
    background-color: #f8f9fa;
}

.job-search-item.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background-color: #f8f9fa;
}

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

.job-ref {
    font-weight: 700;
    color: #007bff;
    font-size: 14px;
    margin-bottom: 4px;
}

.job-info {
    font-size: 13px;
    color: #495057;
    margin-bottom: 2px;
}

.job-builder {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

.not-plottable {
    display: inline-block;
    background-color: #ffc107;
    color: #000;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-top: 4px;
    font-weight: 600;
}

.search-input-wrapper {
    position: relative;
}

/* Job highlight marker animation */
.job-highlight-marker {
    z-index: 10000 !important;
}

/* Google Places Autocomplete dropdown styling (fallback) */
.pac-container {
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    margin-top: 4px;
    font-family: inherit;
}

#sidebar .filter-group {
    margin-bottom: 20px;
}

#sidebar .filter-group > label { /* Target only the main group label */
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    color: #495057;
}

.page-content {
    padding: 20px;
    width: 100%;
}

.page-content h1 {
    color: var(--primary-color-dark);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.date-filter-input {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: #fff;
    font-family: inherit; /* Use the body's font */
    font-size: 14px;
    color: #495057;
}

.quick-date-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.quick-date-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #007bff;
    background-color: #f8f9fa;
    color: #007bff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.quick-date-btn:hover {
    background-color: #007bff;
    color: white;
}

.quick-date-btn:active {
    transform: translateY(1px);
}

.date-inputs-container {
    display: flex;
    gap: 10px;
}

.date-input-group {
    flex: 1;
}

.date-input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
}

.date-input-group .date-filter-input {
    width: 100%;
}

/* --- Popups --- */
.popup-content {
    max-width: 300px;
    font-size: 14px;
}

.popup-content h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.popup-content p {
    margin: 5px 0;
    color: #666;
}

.scrollable-notes {
    max-height: 120px; /* Adjust as needed */
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: #f8f9fa;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-top: 4px;
}

.popup-content hr {
    margin: 12px 0;
    border: 0;
    border-top: 1px solid #eee;
}

.status-active {
    color: #28a745;
}

.status-pending {
    color: #ffc107;
}

.status-completed {
    color: #6c757d;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

/* Styles for the multi-select dropdown */
.multiselect {
    /* This class is no longer used for dropdowns but kept for structure */
    position: relative;
}

.checkboxes {
    /* Now a static list, not a dropdown */
    display: block;
    background: #fff;
    border: 1px solid #ced4da;
    padding: 10px;
    /* max-height is now controlled by the parent .filters-wrapper */
    overflow-y: auto;
    border-radius: 4px;
}
.checkboxes label {
    display: block;
    margin: 4px 0;
    font-weight: normal;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}
.checkboxes label:hover {
    background-color: #e9ecef;
}
.checkboxes label input {
    margin-right: 8px;
}

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

.filter-header label {
    font-weight: 600;
    color: #495057;
}

.filter-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    color: #6c757d;
}

.control-btn:hover {
    background-color: #e9ecef;
    color: #343a40;
}

/* --- NEW: Auth Styles --- */
#login-view {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw; /* Ensure it takes full viewport width */
    background-color: #f0f2f5;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000; /* Ensure it covers everything */
}
#login-form {
    padding: 40px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 320px;
    text-align: center;
}
#login-form h2 {
    margin-bottom: 20px;
}
#login-form input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}
#login-form button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 4px;
    background-color: #007bff;
    color: white;
    font-size: 16px;
    cursor: pointer;
}
#login-form button:hover {
    background-color: #0056b3;
}
#auth-error {
    color: red;
    margin-top: 10px;
    height: 20px;
}

/* --- NEW: Navigation Bar --- */
.main-nav {
    width: 60px;
    height: 100vh;
    background-color: #343a40; /* Dark gray */
    padding-top: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    position: fixed; /* Keep it in place */
    left: 0;
    top: 0;
    z-index: 1100; /* Above other elements */
    display: flex;
    flex-direction: column;
}
.main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.main-nav ul li a {
    display: block;
    padding: 15px;
    text-align: center;
    opacity: 0.7;
    transition: opacity 0.2s, background-color 0.2s;
}
.main-nav ul li a:hover {
    opacity: 1;
    background-color: #495057;
}
.main-nav ul li a img {
    width: 24px;
    height: 24px;
}

.nav-bottom {
    margin-top: auto; /* Pushes this to the bottom */
    padding-bottom: 20px;
    display: flex;
    justify-content: center;
}

.nav-bottom a {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    text-align: center;
    opacity: 0.7;
    transition: opacity 0.2s, background-color 0.2s;
}

.nav-bottom a:hover {
    opacity: 1;
    background-color: #495057;
}

.nav-bottom svg {
    stroke: #ffffff;
}

:root {
    --primary-color: #007bff; /* A nice, modern blue */
    --primary-color-dark: #0056b3;
    --security-color: #fd7e14; /* A vibrant orange */
    --accessories-color: #6c757d; /* A neutral grey */
    --text-color: #333;
    --light-grey: #f4f4f9;
    --border-color: #e0e0e0;
    --white: #ffffff;
    --hover-light: #f1f1f1;
}

/* Styling for the new unplotted jobs section */
#unplotted-jobs-container summary {
    cursor: pointer;
    font-weight: 600;
    padding: 8px;
    background-color: #f7f7f7;
    border-radius: 4px;
    outline: none; /* Removes the focus ring on some browsers */
    transition: background-color 0.2s;
}

#unplotted-jobs-container summary:hover {
    background-color: #e9e9e9;
}

#unplotted-jobs-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    margin-left: 8px;
    color: white;
    background-color: #f44336; /* Red */
    font-weight: bold;
    display: none; /* Hidden by default */
}

.scrollable-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 8px;
    padding: 8px;
    background-color: #fff;
}

.unplotted-job-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.unplotted-job-item:last-child {
    border-bottom: none;
}

.unplotted-job-item strong {
    font-size: 0.95em;
}

.unplotted-job-item p {
    font-size: 0.85em;
    color: #666;
    margin: 4px 0;
}

.unplotted-job-item a {
    font-size: 0.85em;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}

.unplotted-job-item a:hover {
    text-decoration: underline;
}

.filters-wrapper label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.filter-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0,0,0,0.2);
}

.checkboxes input[type="checkbox"] {
    margin-right: 5px;
}

#app-view.layout {
    display: flex;
    height: calc(100vh - 50px); /* Adjust for nav bar */
}

/* This targets the container div created by L.DivIcon */
.custom-pin .leaflet-popup-content-wrapper,
.custom-multi-layer-pin .leaflet-popup-content-wrapper {
    border-radius: 5px;
    width: 380px !important; /* Fixed width - about 20% larger than default */
    max-width: 380px !important;
}

/* NEW: Styling for enhanced multi-layer markers */
.custom-multi-layer-pin {
    /* Ensure SVG text renders properly */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* NEW: Styling for collapsible other statuses */
.other-statuses {
    margin-top: 8px;
    border-top: 1px solid #e5e5e5;
    padding-top: 8px;
}

.other-statuses summary {
    cursor: pointer;
    padding: 4px 0;
    font-size: 0.9em;
    color: #666;
    user-select: none;
}

.other-statuses summary:hover {
    color: #333;
}

.other-checkboxes {
    margin-top: 8px;
    margin-left: 12px;
}

.other-checkboxes label {
    font-size: 0.9em;
    color: #666;
}

/* Legend styling improvements */
.filter-color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0,0,0,0.2);
    vertical-align: middle;
}

/* NEW: Custom cluster icon styling */
.custom-cluster-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.custom-cluster-icon:hover {
    transform: scale(1.1);
}

.custom-cluster-icon .cluster-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(2px);
}

.custom-cluster-icon svg {
    /* Ensure proper text rendering in SVG */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    shape-rendering: geometricPrecision;
}

/* Cluster icon size adjustments for different zoom levels */
.leaflet-zoom-anim .custom-cluster-icon {
    transition: transform 0.2s ease;
}

/* High priority indicator animation */
.custom-cluster-icon circle[fill="#dc2626"] {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* NEW: Legend system styling - HIDDEN FOR NOW */
.legend-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 280px;
    max-height: 60vh;
    overflow-y: auto;
    font-family: Arial, sans-serif;
    font-size: 12px;
    display: none; /* Hide legend for now */
}

.legend-panel {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 8px 8px 0 0;
}

.legend-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.legend-toggle {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.2s ease;
}

.legend-toggle:hover {
    background: #f5f5f5;
    border-color: #999;
}

.legend-content {
    padding: 16px;
    max-height: 60vh;
    overflow-y: auto;
}

.legend-section {
    margin-bottom: 20px;
}

.legend-section:last-child {
    margin-bottom: 0;
}

.legend-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.legend-description {
    margin: 0 0 12px 0;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.legend-category {
    margin: 8px 0;
}

.legend-category-title {
    cursor: pointer;
    font-weight: 500;
    color: #555;
    user-select: none;
    padding: 4px 0;
}

.legend-category-title:hover {
    color: #333;
}

.legend-category-items {
    margin-top: 6px;
    margin-left: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 4px 0;
    font-size: 12px;
}

.legend-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.legend-icon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.legend-label {
    color: #333;
    flex-grow: 1;
}

.legend-sublabel {
    color: #666;
    font-size: 11px;
    margin-left: 8px;
}

.legend-initials-example {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    line-height: 20px;
    margin-right: 8px;
    flex-shrink: 0;
}

.legend-cluster-examples {
    margin: 12px 0;
}

.legend-cluster-example {
    margin-right: 12px;
    flex-shrink: 0;
}

.legend-cluster-info {
    font-size: 11px;
    color: #555;
    line-height: 1.3;
}

.legend-priority-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.legend-priority-indicator.high {
    background: #dc2626;
}

.legend-priority-indicator.medium {
    background: #f59e0b;
}

.legend-priority-indicator.low {
    background: #22c55e;
}

.legend-note {
    margin: 8px 0 0 0;
    font-size: 11px;
    color: #666;
    font-style: italic;
}

/* Responsive legend for smaller screens */
@media (max-width: 768px) {
    .legend-container {
        position: fixed;
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
        max-width: none;
        max-height: 40vh;
    }
    
    .legend-content {
        max-height: 30vh;
    }
}

/* NEW STYLES for interactive popup actions */
.popup-actions-container {
    display: flex;
    justify-content: space-around; /* Distribute space between items */
    align-items: flex-end; /* Align items to the bottom */
    gap: 15px; /* Space between the two action blocks */
    margin-top: 10px;
}

.popup-action {
    display: flex;
    flex-direction: column; /* Stack label on top of controls */
}

.popup-action label {
    font-size: 0.9em;
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.popup-action .action-controls {
    display: flex;
    align-items: center;
}

.popup-action select {
    margin-right: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
    padding: 5px;
}

.popup-action button {
    padding: 5px 10px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    border-radius: 4px;
    cursor: pointer;
}

.popup-action button:hover {
    background-color: #e9e9e9;
    border-color: #999;
}

/* NEW STYLES for inline, editable info items */
.inline-info-item {
    display: flex;
    align-items: center; /* Vertically center the label and the controls */
    justify-content: space-between; /* Push label to left and controls to right */
    padding: 4px 0; /* Add a little vertical space */
}

.inline-info-item strong {
    margin-right: 10px; /* Space between label and controls */
}

/* Cache warning styles */
.cache-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    margin-bottom: 15px;
    padding: 10px;
    animation: slideIn 0.3s ease-in-out;
}

.cache-warning-content {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.warning-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.warning-text {
    flex-grow: 1;
    font-size: 14px;
    color: #856404;
}

.warning-text strong {
    color: #533f03;
}

.warning-text small {
    color: #6c757d;
}

.warning-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #856404;
    padding: 0;
    margin-left: 5px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    flex-shrink: 0;
}

.warning-close:hover {
    background-color: #f8d7da;
    color: #721c24;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.inline-info-item > div {
    display: flex;
    align-items: center;
    gap: 5px; /* Use gap for cleaner spacing */
}

.inline-select {
    width: 150px; /* <-- Use fixed width for uniformity */
    border-radius: 4px;
    border: 1px solid #ccc;
    padding: 5px;
    box-sizing: border-box; /* <-- Add for consistent box model */
    height: 32px; /* <-- Add for consistent height */
}

.inline-button {
    padding: 5px 10px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    border-radius: 4px;
    cursor: pointer;
    box-sizing: border-box; /* <-- Add for consistent box model */
    height: 32px; /* <-- Add for consistent height */
}

.inline-button:hover {
    background-color: #e9e9e9;
    border-color: #999;
}












