/* =========================
   基本設定
========================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Noto Sans TC",
        "Microsoft JhengHei",
        sans-serif;

    background: #f5f7fa;
    color: #333;
    overflow: hidden;
}


/* =========================
   標題
========================= */

h1.title {
    height: 70px;
    margin: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;

    font-size: 22px;
    font-weight: 700;

    background: #ffffff;
    color: #333;

    position: relative;
    z-index: 1000;

    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
}

h1.title img {
    width: 30px;
    height: 30px;

    margin-right: 8px;

    object-fit: contain;
}


/* =========================
   地圖
========================= */

#map {
    width: 100%;
    height: calc(100vh - 70px);
}


/* =========================
   定位按鈕
========================= */

#locate-btn {
    position: fixed;

    right: 20px;
    bottom: 40px;

    width: 50px;
    height: 50px;

    border: none;
    border-radius: 50%;

    background: #ffffff;
    color: #1976d2;

    font-size: 22px;

    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);

    cursor: pointer;

    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: center;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

#locate-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
}

#locate-btn:active {
    transform: scale(0.95);
}


/* =========================
   目前位置 Marker
========================= */

.location-marker {
    background: transparent;
    border: none;
}

.location-marker img {
    width: 52px;
    height: 52px;

    object-fit: contain;

    display: block;
}


/* =========================
   附近吸菸區 Bottom Sheet
========================= */

#nearest-panel {
    position: fixed;

    left: 0;
    right: 0;
    bottom: 0;

    height: 36vh;
    min-height: 180px;
    max-height: 420px;

    background: #ffffff;

    border-radius: 18px 18px 0 0;

    box-shadow: 0 -3px 18px rgba(0, 0, 0, 0.18);

    z-index: 1100;

    overflow: hidden;

    transform: translateY(100%);

    transition: transform 0.25s ease;
}

#nearest-panel.show {
    transform: translateY(0);
}


/* Header */

.nearest-header {
    height: 52px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 18px;

    border-bottom: 1px solid #eeeeee;

    background: #ffffff;
}

.nearest-header strong {
    font-size: 17px;
    font-weight: 700;
}

#close-nearest {
    width: 36px;
    height: 36px;

    border: none;
    border-radius: 50%;

    background: transparent;

    font-size: 26px;
    line-height: 1;

    color: #666;

    cursor: pointer;
}

#close-nearest:hover {
    background: #f2f2f2;
}


/* 附近清單 */

#nearest-list {
    height: calc(100% - 52px);

    overflow-y: auto;

    padding: 8px 12px 20px;
}

.nearest-item {
    display: grid;

    grid-template-columns: 36px 1fr auto;

    align-items: center;

    gap: 10px;

    padding: 12px 8px;

    border-bottom: 1px solid #eeeeee;

    cursor: pointer;

    transition: background 0.15s ease;
}

.nearest-item:hover {
    background: #f7f9fb;
}

.nearest-item.first {
    background: #f5f9ff;
}

.nearest-rank {
    width: 30px;
    height: 30px;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #1976d2;
    color: #ffffff;

    font-size: 14px;
    font-weight: 700;
}

.nearest-info {
    min-width: 0;
}
.nearest-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nearest-address {
    font-size: 15px;
    font-weight: 600;

    color: #333;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nearest-status {
    flex-shrink: 0;

    padding: 2px 7px;

    border-radius: 999px;

    font-size: 14px;
    font-weight: 600;

    line-height: 1.3;
    white-space: nowrap;
}

.nearest-status.open {
    color: #198754;
    background: #e8f5ee;
}

.nearest-status.closed {
    color: #dc3545;
    background: #fbe9eb;
}

.nearest-status.unknown {
    color: #6c757d;
    background: #f1f3f5;
}
.nearest-distance {
    margin-top: 4px;

    font-size: 13px;
    color: #777;
}

.nearest-walking-time {
    margin-top: 3px;

    font-size: 12px;
    color: #888;
}

.nearest-item .nearest-distance {
    white-space: nowrap;
}


/* 沒有附近資料 */

.nearest-empty {
    padding: 30px 20px;

    text-align: center;

    color: #777;
    font-size: 14px;
}


/* =========================
   開啟附近吸菸區
========================= */

#open-nearest {
    position: fixed;

    left: 50%;
    bottom: 24px;

    transform: translateX(-50%);

    padding: 10px 18px;

    border: none;
    border-radius: 24px;

    background: #1976d2;
    color: #ffffff;

    font-size: 14px;
    font-weight: 600;

    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);

    cursor: pointer;

    z-index: 1050;

    display: none;
}

#open-nearest.show {
    display: block;
}


/* =========================
   手動設定目前位置 Popup
========================= */

.set-location-popup {
    text-align: center;

    min-width: 220px;
}

.set-location-popup-title {
    font-size: 15px;
    font-weight: 700;

    margin-bottom: 10px;
}

.set-location-buttons {
    display: flex;

    gap: 8px;

    margin-top: 12px;
}

.set-location-buttons button {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 14px;
}

#cancel-current-location {
    border: 1px solid #ddd;
    background: #dddddd;
    color: #555;
}

#confirm-current-location {
    border: none;
    background: #1976d2;
    color: #ffffff;
}


/* =========================
   資料更新資訊
========================= */
#update-info-panel {
    position: relative;
}

#update-info-button {
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 21px;
    padding: 4px 6px;
    line-height: 1;
    cursor: pointer;
}

#update-info-button:hover {
    color: #198754;
}
#update-info-button i {
    padding-left:4px;
}
/* 資訊內容預設隱藏 */
#update-info-panel .update-info-content {
    display: none;

    position: absolute;
    top: calc(100% + 8px);
    right: 0;

    width: 300px;
    padding: 0;

    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;

    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);

    z-index: 1000;
}

/* 展開 */
#update-info-panel.show .update-info-content {
    display: block;
}

#update-info-panel .info-wrapper {
    padding: 10px 14px 0;
}

#update-info-panel .info-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
}

#update-info-panel .body {
    font-size: 13px;
    line-height: 1.5;
    color: #666;
}

#update-info-panel .update-info-source {
    margin: 10px 14px 14px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #777;
}

#update-info-panel .update-info-source a {
    text-decoration: none;
}

/* 重新開啟資訊 */

#open-update-info {
    position: fixed;

    left: 16px;
    bottom: 20px;

    width: 40px;
    height: 40px;

    border: none;
    border-radius: 50%;

    background: #ffffff;
    color: #1976d2;

    font-size: 20px;

    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);

    cursor: pointer;

    z-index: 1050;

    display: none;
}


/* =========================
   Leaflet Popup
========================= */
.current-location-popup {
    min-width: 180px;
    text-align: center;
}
.leaflet-popup-content-wrapper {
    border-radius: 14px;

    padding: 0;

    box-shadow: 0 3px 18px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 0;
    padding:12px;
    width: auto !important;
}

.leaflet-popup-tip {
    box-shadow: none;
}

.leaflet-popup-close-button {
    z-index: 5;

    font-size: 22px !important;

    color: #777 !important;
    top: 6px !important;
    right: 4px !important;
}


/* =========================
   吸菸區 Popup
========================= */

.smoking-popup {
    width: min(320px, 80vw);
    overflow: hidden;
}

/* =========================
   Header
========================= */

.smoking-popup-header {
    margin-bottom: 10px;
    width: calc(100% - 18px);
}

.smoking-popup-header-info {
    min-width: 0;
    border-bottom: 1px dashed #999;
}

.smoking-popup-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.smoking-popup-title {
    min-width: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.4;
}

.smoking-popup-subtitle {
    margin-top: 0px;
    font-size: 12px;
    color: #6c757d;
    line-height: 1.4;
    padding-bottom: 2px;
}


/* =========================
   開放狀態
========================= */

.smoking-popup-status {
    flex-shrink: 0;

    padding: 2px 7px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;

    white-space: nowrap;
}

.smoking-popup-status.open {
    color: #198754;
    background: #e8f5ee;
}

.smoking-popup-status.closed {
    color: #dc3545;
    background: #fbe9eb;
}

.smoking-popup-status.unknown {
    color: #6c757d;
    background: #f1f3f5;
}


/* =========================
   位置
========================= */

.smoking-popup-location {
    margin-top: 10px;
}

.smoking-popup-location-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    line-height: 1.5;
}

.smoking-popup-location-row i {
    flex-shrink: 0;
    margin-top: 0px;
    color: #198754;
}

.smoking-popup-location-detail {
    margin-left: 20px;
    margin-top: 2px;
    font-size: 12px;
    color: #6c757d;
    line-height: 1.5;
}


/* =========================
   一般資訊
========================= */

.smoking-popup-section {
    margin-top: 12px;
}

.smoking-popup-label {
    margin-bottom: 3px;

    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
}

.smoking-popup-value {
    font-size: 13px;
    line-height: 1.5;
}


/* =========================
   照片
========================= */

.smoking-popup-image {
    margin-top: 12px;
}

.smoking-popup-image img {
    display: block;

    width: 100%;
    max-height: 180px;

    object-fit: cover;

    border-radius: 8px;

    cursor: pointer;
}


/* =========================
   備註
========================= */
.smoking-popup-meta {
    margin-top: 4px;
    font-size: 11px;
    color: #6c757d;
}

.smoking-popup-meta-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.5;
}

.smoking-popup-meta-row i {
    flex-shrink: 0;
    margin-top: 0px;
}
.smoking-popup-note {
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #6c757d;
    line-height: 1.5;
}


/* =========================
   吸菸區 Marker
========================= */

.smoking-marker {
    background: transparent;
    border: none;

    opacity: 0;
}

.smoking-marker img {
    width: 40px;
    height: 40px;

    display: block;

    object-fit: contain;

    filter: drop-shadow(
        0 2px 3px rgba(0, 0, 0, 0.25)
    );
}


/* Marker 出現動畫 */

.smoking-marker-fade-in {
    animation: smokingMarkerFadeIn 0.35s ease forwards;
}

.smoking-marker-pop {
    animation: smokingMarkerPop 0.25s ease forwards;
}

@keyframes smokingMarkerFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes smokingMarkerPop {
    0% {
        opacity: 0;
        transform: scale(0.7);
    }

    70% {
        opacity: 1;
        transform: scale(1.08);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}


/* =========================
   行政區資訊圓圈
========================= */

.district-circle {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    border-radius: 50%;

    background: rgba(255, 255, 255, 0.88);

    border: 2px solid rgba(25, 118, 210, 0.65);

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.15);

    pointer-events: none;
}

.district-circle-inner {
    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    border-radius: 50%;
}

.district-name {
    font-size: 13px;
    font-weight: 700;

    color: #333;
}

.district-count {
    margin-top: 2px;

    display: flex;
    align-items: center;
    gap: 3px;

    font-size: 12px;
    color: #666;
}

.district-count i {
    font-size: 11px;
}

.district-count strong {
    font-size: 15px;
    color: #1976d2;
}

.district-circle-fade-in {
    animation: districtCircleFadeIn 0.35s ease forwards;
}

@keyframes districtCircleFadeIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* =========================
   定位提示
========================= */

.location-guide {
    position: fixed;
    right: 90px;
    bottom: 32px;
    width: 300px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
    z-index: 2000;
    opacity: 0;
    transform: translateY(8px);
    transition:
        opacity 180ms ease,
        transform 180ms ease;
}

.location-guide.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.location-guide-icon {
    width: 42px;
    height: 42px;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #eaf3ff;
    color: #1976d2;

    font-size: 20px;
}

.location-guide-content {
    min-width: 0;
}

.location-guide-title {
    font-size: 14px;
    font-weight: 700;

    margin-bottom: 3px;
}

.location-guide-text {
    font-size: 12px;
    line-height: 1.45;

    color: #555;
}

.location-guide-privacy {
    margin-top: 3px;

    font-size: 10px;

    color: #999;
}

.location-guide-close {
    border: none;
    border-radius: 8px;

    padding: 7px 10px;

    background: #1976d2;
    color: #ffffff;

    font-size: 12px;

    cursor: pointer;

    white-space: nowrap;
}


/* =========================
   手機版
========================= */

@media (max-width: 600px) {

    h1.title {
        height: 60px;

        padding: 0 14px;

        font-size: 18px;
    }

    h1.title img {
        width: 26px;
        height: 26px;
    }

    #map {
        height: calc(100vh - 60px);
    }

    #update-info-panel {
        top: 72px;
        left: 10px;

        width: calc(100vw - 20px);
    }

    #locate-btn {
        right: 16px;
        bottom: 24px;

        width: 48px;
        height: 48px;
    }

    #nearest-panel {
        height: 42vh;
    }

    .nearest-item {
        grid-template-columns: 32px 1fr auto;

        padding: 11px 6px;
    }

    .nearest-address {
        font-size: 14px;
    }

    .smoking-popup {
        width: min(300px, 78vw);
    }

    .location-guide {
        bottom: 88px;
    }
}
/**** 吸菸種類 *********/#smoking-legend {
    position: absolute;
    left: 15px;
    bottom: 15px;
    z-index: 1000;

    width: 180px;
    padding: 10px 12px;

    background: rgba(255, 255, 255, 0.95);

    border: 1px solid #ddd;
    border-radius: 10px;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.smoking-legend-title {
    margin-bottom: 8px;

    font-size: 14px;
    font-weight: 600;
}

.smoking-legend-item {
    display: flex;
    align-items: center;

    gap: 7px;
    margin-bottom: 5px;

    font-size: 12px;
}

.smoking-legend-item:last-child {
    margin-bottom: 0;
}

.smoking-legend-item img {
    width: 32px;
    height: 32px;

    object-fit: contain;
    flex-shrink: 0;
}