body {
    margin: 0;
    background-color: #f8f9fa;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


.no-leaflet-error {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    color: #555;
    font-family: sans-serif;
    text-align: center;
}

.refresh-button {
    cursor: pointer;
    margin-top: 20px;
    border: none;
    border-radius: 4px;
    background: #333;
    padding: 10px 20px;
    color: #fff;
}

/* Full Screen Map */
#map {
    z-index: 1;
    width: 100vw;
    height: 100vh;
}

/* Floating Control Card - Material Surface */
.controls-card {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), height 0.3s ease-in;
    box-sizing: content-box;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.2),
        0 4px 5px 0 rgba(0, 0, 0, 0.14),
        0 1px 10px 0 rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: #ffffff;
    padding: 16px 24px;
    width: 240px;
    height: auto;
}

.drag-handle {
    display: none;
    /* Hidden on desktop */
}

.header h1 {
    margin: 0;
    color: #202124;
    font-weight: 500;
    font-size: 20px;
    letter-spacing: 0.15px;
}

.header p {
    margin: 4px 0 20px 0;
    color: #5f6368;
    font-size: 14px;
    letter-spacing: 0.25px;
}

/* Radio Button Styling */
.options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-card {
    position: relative;
    cursor: pointer;
    margin: 0;
}

.radio-card input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 0;
    height: 0;
}

/* The visual part of the radio button */
.card-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    border: 1px solid #dadce0;
    border-radius: 4px;
    background: #ffffff;
    padding: 10px 16px;
}

.service-name {
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    color: #3c4043;
    font-weight: 500;
    font-size: 15px;
    letter-spacing: 0.25px;
    text-transform: capitalize;
}

.radio-card:hover .service-name {
    padding: 0px 10px;
    color: #000000;
}

.radio-card:hover .card-content {
    border-color: #333333db !important;
    background-color: #f5f5f5 !important;
}

/* Active/Checked State - Material Selection Style */
.radio-card input:checked~.card-content {
    border-color: #1a73e8;
    background-color: #e8f0fe;
}

.radio-card input:checked~.card-content .service-name {
    color: #1967d2;
}

/* Legend */
.legend {
    display: flex;
    gap: 24px;
    margin-top: 24px;
    border-top: 1px solid #eeeeee;
    padding-top: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #000000;
    font-weight: 400;
    font-size: 13px;
}

.dot {
    display: inline-block;
    border-radius: 50%;
    width: 10px;
    height: 10px;
}

.dot.green {
    background: #34a853;

}

.dot.empty {
    box-sizing: border-box;
    border: 2px solid #dadce0;
    background: transparent;
}

.footer {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    color: #3f3f3f;
    font-size: 11px;
}

.modal a {
    font-weight: bolder;
}

.footer a, .modal a {
    cursor: pointer;
    color: #252525;
    text-decoration: none;
}

.footer a:hover, .modal a:hover {
    color: #000000;
    text-decoration: underline;
}

/* --- MODAL STYLES --- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* The dark background behind the modal */
.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.3s;
    background-color: rgba(0, 0, 0, 0.5);
    width: 100%;
    height: 100%;
}

/* The Modal Box */
.modal-content {
    position: relative;
    z-index: 2001;
    animation: slideUp 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    background-color: #fff;
    width: 90%;
    max-width: 500px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dadce0;
    padding: 20px 24px;
}

.modal-header h2 {
    margin: 0;
    color: #202124;
    font-size: 18px;
}

.modal-close-btn {
    cursor: pointer;
    color: #5f6368;
    font-weight: bold;
    font-size: 24px;
    line-height: 1;
}

.modal-body {
    padding: 24px;
    color: #3c4043;
    font-size: 14px;
    line-height: 1.5;
}

.modal-body p {
    margin-top: 0;
    margin-bottom: 16px;
}

.modal-body ul {
    padding-left: 25px;
}

.modal-footer {
    padding: 8px 24px 20px;
    text-align: right;
}

.btn-close-modal {
    transition: background 0.2s;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background: #1a73e8;
    padding: 8px 16px;
    color: white;
    font-weight: 500;
    font-size: 14px;
}

.btn-close-modal:hover {
    background: #1557b0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- SEARCH BOX STYLES --- */
.search-container {
    display: flex;
    align-items: center;
    transition: background 0.2s, box-shadow 0.2s;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #f1f3f4;
    padding: 4px 12px;
}

.search-container:focus-within {
    box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
    border-color: #dadce0;
    background: #ffffff;
}

#location-search {
    flex-grow: 1;
    outline: none;
    border: none;
    background: transparent;
    padding: 8px 0;
    color: #3c4043;
    font-size: 14px;
    font-family: inherit;
}

#search-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
    cursor: pointer;
    margin-right: -8px;
    /* Align closer to edge */
    border: none;
    border-radius: 50%;
    background: transparent;
    padding: 8px;
    color: #5f6368;
}

#search-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #202124;
}


/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    visibility: hidden;
    opacity: 0;
    z-index: 9999;
    transition: opacity 0.3s, bottom 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    background-color: #333;
    padding: 12px 24px;
    min-width: 250px;
    color: #fff;
    font-size: 14px;
    text-align: center;
}

.toast-notification.show {
    bottom: 40px;
    /* Slight slide-up animation */
    visibility: visible;
    opacity: 1;
}

.toast-notification.error {
    background-color: #d32f2f;
    /* Material Red for errors */
}



/* Mobile Responsiveness */
@media (max-width: 600px) {
    .controls-card {
        top: auto;
        bottom: 0;
        left: 0;
        transform: translateY(0);
        transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
        box-sizing: content-box;
        border-radius: 20px 20px 0 0;
        padding: 0px;
        width: 100%;
    }

    .header, .options {
        padding: 0px 30px;
    }

    .header p {
        margin: 4px 0 5px 0;
        font-size: 13px;
    }

    .legend {
        margin-top: 15px;
        padding: 10px 50px;
    }

    .options {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }


    .last-refresh {
        padding-bottom: 10px;
    }

    .header h1 {
        font-size: 16px;
    }

    .search-container {
        margin: 0% 3% 2% 6%;
        width: 80%;
    }

    .modal-body {
        padding: 10px;
        padding-bottom: 0px;
        font-size: 12px;
        line-height: 1.2;
    }

    .modal-body p {
        margin-top: 0;
        margin-bottom: 10px;
    }

    .modal-body ul {
        padding-left: 15px;
    }

    .modal-footer {
        padding: 0px 24px 10px;
    }

    .card-content {
        padding: 7px 16px;
    }

    .toast-notification {
        top: 20px;
        bottom: auto;
        width: 90%;
        min-width: auto;
    }

    .toast-notification.show {
        top: 30px;
        bottom: auto;
    }

    .controls-card.collapsed {
        transform: translateY(calc(100% - 85px));
    }

    /* Style the Drag Handle */
    .drag-handle {
        display: block;
        margin: 8px auto 15px auto;
        border-radius: 10px;
        background-color: #e0e0e0;
        width: 40px;
        height: 5px;
    }

    .drag-handle::before {
        position: absolute;
        top: -30px;
        right: -30px;
        left: -30px;
        z-index: 2;
        /* Make the pseudo-element invisible, but it still registers clicks */
        background-color: transparent;
        padding-bottom: 100px;
        content: '';
    }

    /* Make the header clickable */
    .header, .drag-handle {
        cursor: pointer;
    }

    .leaflet-bottom .leaflet-control {
        margin-bottom: 60px !important;
    }

}

/* Dark mode */
@media (prefers-color-scheme: dark) {

    body {
        background-color: #202124;
    }

    .controls-card {
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
        background: #292a2d;
    }

    .header h1 {
        color: #e8eaed;
    }

    .header p {
        color: #9aa0a6;
    }

    .search-container {
        position: relative;
        z-index: 3;
        background: #3c4043;
    }

    .search-container:focus-within {
        border-color: #5f6368;
        background: #303134;
    }

    #location-search {
        color: #e8eaed;
    }

    #search-btn {
        color: #9aa0a6;
    }

    #search-btn:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: #e8eaed;
    }

    .service-name {
        color: #e8eaed;
    }

    .legend-item, .footer {
        color: #efefef;
    }

    .card-content {
        border-color: #5f6368;
        background: #35363a !important;
    }

    .radio-card:hover .service-name {
        color: #efefef;
    }

    .radio-card:hover .card-content {
        border-color: #5f6368;
        background-color: #3c4043 !important;
    }

    .radio-card input:checked~.card-content {
        border-color: #8ab4f8;
        background-color: rgba(138, 180, 248, 0.1);
    }

    .radio-card input:checked~.card-content .service-name {
        color: #8ab4f8;
    }

    .dot.empty {
        border-color: #aaabac;
    }

    .drag-handle {
        background-color: #5f6368 !important;
    }

    /* Invert the Light Map to Dark Map */
    /* This inverts the colors of the base map tiles (White -> Black) */
    /* We add hue-rotate(180deg) so that Blue Water stays Blue (instead of turning Orange) */
    .leaflet-tile-pane {
        filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
    }

    /* Invert the copyright text so it remains readable */
    .leaflet-control-attribution {
        background: rgba(32, 33, 36, 0.8) !important;
        color: #9aa0a6 !important;
    }

    .leaflet-control-attribution a {
        color: #8ab4f8 !important;
    }

    .modal-content {
        background-color: #292a2d;
        color: #e8eaed;
    }

    .modal-header {
        border-bottom-color: #3c4043;
    }

    .modal-header h2 {
        color: #e8eaed;
    }

    .modal-body {
        color: #9aa0a6;
    }

    .modal-close-btn {
        color: #9aa0a6;
    }

    .footer a, .modal a {
        color: #c6c6c6;
    }

    .footer a:hover, .modal a:hover {
        color: #efefef;
    }

    .footer a:hover {
        color: #efefef;
    }
}