/* =============================================================================
   HosFind Map Styles
   ============================================================================= */

/* === Nearby Map (Front Page) =============================================== */
.nearby-map-section {
    margin-bottom: 32px;
}

.nearby-map {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 600px;
    overflow: hidden;
}

.nearby-map-status {
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-top: 15px;
}

/* === Legend ================================================================= */
.map-legend-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.map-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 1rem;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 2px 10px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, .08);
    background: transparent;
    transition: all var(--transition);
    user-select: none;
}

.map-legend__item:hover {
    background: var(--color-bg);
    border-color: var(--color-border);
}

.map-legend__item--active {
    background: var(--color-bg);
    border-color: var(--color-text);
    color: var(--color-text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.map-legend__dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.map-legend__toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, .08);
    user-select: none;
    transition: all var(--transition);
}

.map-legend__toggle:hover {
    border-color: var(--color-border);
}

.map-legend__toggle:has(input:checked) {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
    font-weight: 600;
}

.map-legend__toggle input {
    display: none;
}

/* === Markers =============================================================== */
.map-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1;
    padding: 6px;
}

/* === Nearby Hospital List =================================================== */
.nearby-hospital-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.nearby-hospital-list:empty {
    display: none;
}

.nearby-hospital-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-bg);
    text-decoration: none;
    color: var(--color-text);
    transition: background var(--transition);
}

.nearby-hospital-item:hover {
    background: var(--color-bg-light);
}

.nearby-hospital-item__badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 20px;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.nearby-hospital-item__name {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.nearby-hospital-item__dept {
    flex: 1 1 auto;
    font-size: 0.875rem;
    color: var(--color-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.nearby-hospital-item__dist {
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--color-text-light);
}

/* === Archive Map ============================================================ */
.nearby-map-section--archive {
    margin-bottom: 20px;
}

.nearby-map-section--archive .nearby-map {
    height: 350px;
}

/* === Detail Map (Single Hospital) ========================================== */
.hospital-detail__map,
.detail-map {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 280px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background-color: var(--color-bg-light);
    margin-bottom: 24px;
}

/* === Responsive ============================================================ */
@media (max-width: 768px) {
    .nearby-map {
        height: 300px;
    }

    .nearby-map-section--archive .nearby-map {
        height: 250px;
    }

    /* Flex column layout for reordering */
    .nearby-map-section,
    .nearby-map-section--archive {
        display: flex;
        flex-direction: column;
    }

    /* Status contains legend + toggle; split them via inner flex */
    .nearby-map-status {
        display: contents;
        margin: 0;
    }

    /* Legend row: above map, single-line swipe */
    .nearby-map-status .map-legend {
        order: -1;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 10px;
        margin-bottom: 10px;
    }

    .nearby-map-status .map-legend::-webkit-scrollbar {
        display: none;
    }

    .nearby-map-status .map-legend__item {
        flex-shrink: 0;
        font-size: 1rem;
        padding: 6px 4px;
        color: var(--color-text-light);
        background: none;
        border: none;
        border-bottom: 2px solid transparent;
        border-radius: 0;
    }

    .nearby-map-status .map-legend__item:hover {
        color: var(--color-text);
        background: none;
        border-bottom-color: var(--color-border);
    }

    .nearby-map-status .map-legend__item--active {
        color: var(--color-text);
        font-weight: 700;
        background: none;
        border-bottom-color: var(--color-text);
        box-shadow: none;
    }

    .nearby-map-status .map-legend__dot {
        display: none;
    }

    /* Nearby hospital item: two-line layout */
    .nearby-hospital-item {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }

    .nearby-hospital-item__badge {
        order: 1;
    }

    .nearby-hospital-item__name {
        order: 2;
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nearby-hospital-item__dist {
        order: 3;
    }

    .nearby-hospital-item__dept {
        order: 4;
        width: 100%;
    }

    /* Toggle: below map, right-aligned */
    .nearby-map-status .map-legend__toggle {
        order: 1;
        align-self: flex-end;
        margin-top: 8px;
        margin-left: 0;
        flex-shrink: 0;
        font-size: 0.8rem;
    }
}