/* ========== GLOBAL STYLES ========== */
body { 
    margin: 0; 
    padding: 0; 
    font-family: 'Sarabun', sans-serif; 
    overflow: hidden; 
    background: #f4f6f9; 
}

#map { 
    height: 100vh; 
    width: 100%; 
    z-index: 1; 
}

.leaflet-routing-container { 
    display: none !important; 
}

/* ========== RESPONSIVE ========== */
@media (max-width: 600px) {
    .leaflet-control-zoom { display: none !important; }
    .leaflet-popup-content { width: 300px !important; }
    .popover-panel { width: 200px !important; min-width: auto !important; }
}

/* ========== UI CONTROLS ========== */
.toolbar-container { 
    position: fixed; 
    top: 50%; 
    right: 10px; 
    transform: translateY(-50%); 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    z-index: 9000 !important; 
    pointer-events: auto; 
}

.leaflet-control-container {
    z-index: 11000 !important;
}
.leaflet-top.leaflet-right {
    z-index: 12000 !important;
}
.leaflet-control-layers {
    z-index: 12000 !important;
}


.icon-btn { 
    background: #fff; 
    width: 44px; 
    height: 44px; 
    border-radius: 50%; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    font-size: 18px; 
    color: #555; 
    transition: all 0.2s; 
	z-index: 100;
    position: relative; 
    border: 1px solid #eee; 
}

.icon-btn:active { transform: scale(0.95); }
.icon-btn.active { background: #0d6efd; color: white; border-color: #0d6efd; }
.icon-btn i { pointer-events: none; }

.gps-btn-container { 
    position: absolute; 
    top: 80px; 
    left: 10px; 
    z-index: 1000; 
}

.gps-btn { 
    background: white; 
    width: 34px; 
    height: 34px; 
    border-radius: 4px; 
    border: 2px solid rgba(0,0,0,0.2); 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 18px; 
    color: #333; 
}

.gps-btn:hover { background: #f4f4f4; }

.gps-btn-container:nth-child(3) { top: 120px; }

/* ========== SEARCH ========== */
/* ปรับปรุง UI ช่องค้นหาให้เป็นระเบียบ ไม่ทับซ้อน */
.search-container {
        position: absolute;
        top: 60px;          /* ตำแหน่งจากด้านบน */
        right: 10px;        /* ชิดขวา ตามตำแหน่งเครื่องมืออื่นๆ */
        z-index: 1000;
        
        background: white;
        width: 40px;        /* กว้าง 40px */
        height: 40px;       /* สูง 40px (ต้องเท่ากันถึงจะกลม) */
        border-radius: 50%; /* ทำเป็นวงกลม */
        padding: 0;         /* [สำคัญ] ต้องเป็น 0 เพื่อไม่ให้เบี้ยว */
        
        display: flex;
        align-items: center;
        justify-content: center; /* จัดไอคอนให้อยู่กึ่งกลาง */
        
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        overflow: hidden;
        transition: all 0.4s ease; /* เอฟเฟกต์ยืดหด */
        cursor: pointer;
    }

.search-input {
        border: none;
        outline: none;
        background: transparent;
        font-family: 'Sarabun', sans-serif;
        font-size: 14px;
        color: #333;
        
        width: 0;           /* เริ่มต้นกว้าง 0 */
        opacity: 0;         /* เริ่มต้นมองไม่เห็น */
        padding: 0;
        margin: 0;
        
        /* เอฟเฟกต์ตอนโผล่ออกมา */
        transition: all 0.3s ease; 
        white-space: nowrap; /* ป้องกันข้อความขึ้นบรรทัดใหม่ */
    }

.search-container {
        /* ตำแหน่งบนหน้าจอ */
        position: absolute;
        top: 30px;          /* ปรับระยะห่างจากด้านบนตามต้องการ */
        left: 50px;         /* ชิดซ้าย (หรือเปลี่ยนเป็น right ถ้าอยากให้อยู่ขวา) */
        z-index: 1000;
        
        /* รูปร่างและการจัดวาง */
        background: white;
        height: 45px;       /* ความสูงคงที่ */
        width: 45px;        /* ความกว้างเริ่มต้น (เท่ากับสูง = วงกลม) */
        border-radius: 45px; /* ทำมุมโค้งครึ่งนึงของความสูง เพื่อเป็นวงกลม/แคปซูล */
        
        display: flex;
        align-items: center; /* จัดให้อยู่กึ่งกลางแนวตั้ง */
        
        box-shadow: 0 4px 6px rgba(0,0,0,0.2); /* เงา */
        overflow: hidden;    /* ซ่อนส่วนเกิน */
        transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); /* เอฟเฟกต์ยืดหดนุ่มๆ */
        cursor: pointer;
    }


.search-container.active {
        width: 280px; /* ความกว้างตอนยืดออก */
    }

  .search-container.active .search-input {
        width: 100%;        /* ขยายเต็มพื้นที่ที่เหลือ */
        opacity: 1;         /* แสดงผล */
        padding-right: 15px; /* เว้นระยะขวานิดหน่อย */
    }  

.search-icon {
        /* [สำคัญ] ต้องกำหนด min-width ให้เท่ากับ height ของ container */
        min-width: 45px; 
        height: 45px;
        
        display: flex;
        align-items: center;
        justify-content: center; /* จัดไอคอนไว้ตรงกลางพื้นที่ของมัน */
        
        color: #555;
        font-size: 18px;
        cursor: pointer;
    }


/* ========== LOADERS ========== */
.layer-loader { 
    position: absolute; 
    top: 10px; 
    right: 60px; 
    background: rgba(255, 255, 255, 0.95); 
    padding: 5px 12px; 
    border-radius: 20px; 
    font-size: 12px; 
    color: #555; 
    z-index: 2000; 
    display: none; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.15); 
    align-items: center; 
    gap: 6px; 
    font-weight: 600; 
    border: 1px solid #eee; 
    pointer-events: none; 
}

#loader { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    z-index: 2000; 
    background: rgba(255,255,255,0.95); 
    color: #333; 
    padding: 15px 30px; 
    border-radius: 8px; 
    font-size: 14px; 
    display: none; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.1); 
    border: 1px solid #eee; 
    font-weight: 600; 
}

/* ========== POPUPS & PANELS ========== */
.popover-wrapper { position: relative; }

.popover-panel { 
    display: none; 
    position: absolute; 
    right: 60px; 
    top: 50%; 
    transform: translateY(-50%); 
    background: rgba(255, 255, 255, 0.98); 
    padding: 15px; 
    border-radius: 12px; 
    box-shadow: 0 5px 25px rgba(0,0,0,0.2); 
    font-size: 12px; 
    min-width: 200px; 
    backdrop-filter: blur(10px); 
    z-index: 9500 !important;
    animation: slideLeft 0.2s ease; 
    border: 1px solid #f0f0f0; 
}

.popover-panel.show { display: block; }

@keyframes slideLeft { 
    from { opacity: 0; transform: translateY(-50%) translateX(10px); } 
    to { opacity: 1; transform: translateY(-50%) translateX(0); } 
}

/* ========== STATS & BADGES ========== */
.stats-title { 
    font-weight: 700; 
    border-bottom: 2px solid #f1f1f1; 
    margin-bottom: 10px; 
    padding-bottom: 6px; 
    color: #333; 
    font-size: 13px; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.stats-row { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 8px; 
    color: #555; 
    align-items: center; 
}

.badge { 
    padding: 4px 10px; 
    border-radius: 4px; 
    color: white; 
    font-weight: 600; 
    font-size: 11px; 
    min-width: 30px; 
    text-align: center; 
}

.bg-total { background: #6c757d; } 
.bg-green { background: #28a745; } 
.bg-red { background: #dc3545; }

.legend-bar { 
    height: 10px; 
    width: 100%; 
    border-radius: 5px; 
    margin-bottom: 5px; 
    background: linear-gradient(to right, #87CEEB, #0000FF, #00FF00, #FFFF00, #FF0000, #FF00FF); 
}

.legend-labels { 
    display: flex; 
    justify-content: space-between; 
    font-size: 10px; 
    color: #777; 
}

/* ========== WEATHER CARD ========== */
.leaflet-popup-content-wrapper { 
    border-radius: 8px; 
    padding: 0; 
    overflow: hidden; 
    box-shadow: 0 3px 14px rgba(0,0,0,0.2); 
}

.leaflet-popup-content { 
    margin: 0; 
    width: 290px !important; 
}

.weather-card { 
    background: #fff; 
    position: relative; 
    min-height: 240px; 
}

.card-header { 
    background: #0d6efd; 
    color: white; 
    padding: 10px 15px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid rgba(0,0,0,0.1); 
}

.station-name { 
    font-weight: 700; 
    font-size: 13px; 
    display: block; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    max-width: 220px; 
}

.station-sub { 
    font-size: 11px; 
    opacity: 0.8; 
    display: block; 
}

.btn-fav-header { 
    background: transparent; 
    border: none; 
    color: rgba(255,255,255,0.4); 
    font-size: 16px; 
    cursor: pointer; 
    transition: 0.2s; 
}

.btn-fav-header.active { 
    color: #ffd700; 
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5); 
}

.card-body { 
    background: #f8f9fa; 
    padding: 1px; 
    transition: all 0.3s; 
}

.view-panel { 
    display: none; 
    padding: 10px; 
    background: #fff; 
    height: 230px; 
    overflow-y: auto; 
    position: relative; 
}

.view-panel.active { display: grid; }

.data-item { 
    background: #fff; 
    padding: 8px 10px; 
    display: flex; 
    flex-direction: column; 
    border: 1px solid #f1f1f1; 
}

.data-label { 
    font-size: 10px; 
    color: #6c757d; 
    text-transform: uppercase; 
    display: flex; 
    align-items: center; 
    gap: 5px; 
    margin-bottom: 2px;
}

.data-label i { 
    width: 14px; 
    text-align: center; 
    color: #0d6efd; 
    font-size: 12px; 
}

.data-value { 
    font-size: 14px; 
    font-weight: 600; 
    color: #212529; 
}

.unit { 
    font-size: 10px; 
    font-weight: normal; 
    color: #adb5bd; 
    margin-left: 2px; 
}

.card-footer { 
    padding: 8px 15px; 
    background: #fff; 
    border-top: 1px solid #dee2e6; 
    font-size: 10px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    color: #6c757d; 
}

.footer-left { 
    display: flex; 
    gap: 5px; 
}

.btn-toggle-view { 
    background: #fff; 
    border: 1px solid #dee2e6; 
    color: #555; 
    padding: 4px 10px; 
    border-radius: 4px; 
    cursor: pointer; 
    font-weight: 600; 
    font-size: 11px; 
    transition: 0.2s; 
    display: flex; 
    align-items: center; 
    gap: 5px; 
}

.btn-toggle-view.active { 
    background: #0d6efd; 
    color: white; 
    border-color: #0d6efd; 
}

.btn-share { 
    background: #f8f9fa; 
    border: 1px solid #dee2e6; 
    color: #555; 
    width: 28px; 
    height: 28px; 
    border-radius: 4px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 12px; 
}

/* ========== LISTS & CHARTS ========== */
.chart-loader { 
    position: absolute; 
    top:0; 
    left:0; 
    width:100%; 
    height:100%; 
    background:rgba(255,255,255,0.9); 
    display:flex; 
    align-items:center; 
    justify-content:center; 
    z-index:10; 
    font-size:12px; 
    color:#666; 
}

.forecast-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
}

.forecast-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 8px 5px; 
    border-bottom: 1px solid #f1f1f1; 
    font-size: 12px; 
}

.forecast-date { 
    color: #555; 
    font-weight: 600; 
    width: 60px; 
}

.forecast-icon { 
    font-size: 16px; 
    width: 35px; 
    text-align: center; 
}

.forecast-temp { 
    font-weight: bold; 
    color: #333; 
    text-align: center; 
    flex: 1; 
}

.forecast-rain { 
    color: #0984e3; 
    width: 60px; 
    text-align: right; 
    font-size: 11px; 
    display:flex; 
    align-items:center; 
    justify-content:flex-end; 
    gap:3px;
}

.weather-card.offline-mode { 
    filter: grayscale(100%); 
}

.weather-card.offline-mode .card-header { 
    background: #555; 
}

.weather-card.offline-mode::after { 
    content: "OFFLINE"; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%) rotate(-30deg); 
    font-size: 28px; 
    font-weight: 800; 
    color: rgba(220, 53, 69, 0.3); 
    border: 3px solid rgba(220, 53, 69, 0.3); 
    padding: 5px 15px; 
    border-radius: 8px; 
    pointer-events: none; 
    z-index: 999; 
}

.wind-arrow-icon { 
    text-align: center; 
    line-height: 24px; 
    font-size: 20px; 
    color: #0d6efd; 
    text-shadow: 0 0 2px #fff; 
    display: block; 
}

.rank-list, .fav-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    max-height: 200px; 
    overflow-y: auto; 
}

.rank-item, .fav-item { 
    display: flex; 
    justify-content: space-between; 
    padding: 10px 5px; 
    border-bottom: 1px solid #f1f1f1; 
    font-size: 12px; 
    cursor: pointer; 
    align-items: center; 
}

.rank-item:hover, .fav-item:hover { 
    background-color: #f8f9fa; 
}

.rank-tab { 
    display: flex; 
    border-bottom: 1px solid #ddd; 
    margin-bottom: 10px; 
}

.rank-tab-item { 
    flex: 1; 
    padding: 6px; 
    text-align: center; 
    cursor: pointer; 
    font-size: 12px; 
    color: #666; 
    background: #f8f9fa; 
    border-radius: 4px 4px 0 0; 
    border: 1px solid transparent; 
}

.rank-tab-item.active { 
    background: #fff; 
    font-weight: bold; 
    color: #0d6efd; 
    border: 1px solid #ddd; 
    border-bottom: none; 
}

.rank-val { 
    font-weight: bold; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
}

.rank-rain { color: #0984e3; } 
.rank-heat { color: #d35400; } 
.rank-cold { color: #00cec9; }

.fav-delete { 
    color: #dc3545; 
    margin-left: 10px; 
    padding: 2px 6px; 
    font-size: 10px; 
    border: 1px solid #dc3545; 
    border-radius: 3px; 
}

/* ========== POPUPS ========== */
#admin-popup { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.6); 
    z-index: 9999; 
    align-items: center; 
    justify-content: center; 
}

.popup-box { 
    background: white; 
    width: 90%; 
    max-width: 400px; 
    padding: 25px; 
    border-radius: 8px; 
    text-align: center; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.2); 
    animation: popIn 0.3s ease; 
    position: relative; 
}

@keyframes popIn { 
    from { transform: scale(0.9); opacity: 0; } 
    to { transform: scale(1); opacity: 1; } 
}

.popup-icon { 
    font-size: 40px; 
    margin-bottom: 15px; 
}

.popup-msg { 
    font-size: 1.1rem; 
    margin-bottom: 20px; 
    color: #333; 
    line-height: 1.5; 
    font-weight: 500; 
}

.popup-btn { 
    padding: 10px 30px; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 1rem; 
    font-weight: 600; 
    color: white; 
    background: #0d6efd; 
    transition: 0.2s; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
}

.popup-btn:hover { 
    background: #0b5ed7; 
    transform: translateY(-1px); 
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); 
}

.theme-info .popup-icon { color: #0d6efd; } 
.theme-info .popup-btn { background: #0d6efd; }

#install-popup { 
    display: none; 
    position: fixed; 
    bottom: 20px; 
    left: 50%; 
    transform: translateX(-50%); 
    width: 90%; 
    max-width: 400px; 
    background: white; 
    border-radius: 12px; 
    box-shadow: 0 5px 25px rgba(0,0,0,0.2); 
    z-index: 10000; 
    padding: 15px; 
    text-align: center; 
    animation: slideUp 0.5s ease; 
    border: 1px solid #eee; 
}

@keyframes slideUp { 
    from { transform: translate(-50%, 100%); opacity: 0; } 
    to { transform: translate(-50%, 0); opacity: 1; } 
}

.install-content { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 15px; 
}

.install-info { 
    text-align: left; 
}

.install-title { 
    font-weight: bold; 
    font-size: 14px; 
    margin-bottom: 3px; 
    color: #0d6efd; 
}

.install-desc { 
    font-size: 12px; 
    color: #666; 
}

.install-actions { 
    display: flex; 
    gap: 10px; 
}

.btn-install { 
    background: #0d6efd; 
    color: white; 
    border: none; 
    padding: 8px 15px; 
    border-radius: 4px; 
    font-weight: bold; 
    cursor: pointer; 
    font-size: 12px; 
}

.btn-close-install { 
    background: #f1f1f1; 
    color: #333; 
    border: none; 
    width: 30px; 
    height: 30px; 
    border-radius: 50%; 
    cursor: pointer; 
    font-size: 16px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

/* ========== RULER ========== */
.ruler-info { 
    position: absolute; 
    bottom: 80px; 
    left: 50%; 
    transform: translateX(-50%); 
    background: rgba(33, 37, 41, 0.9); 
    color: white; 
    padding: 8px 20px; 
    border-radius: 30px; 
    font-size: 13px; 
    z-index: 3000; 
    display: none; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    pointer-events: none; 
    font-weight: 500; 
    text-align: center;
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-popup .leaflet-popup-content { 
    width: auto !important; 
    min-width: auto !important; 
    margin: 5px 12px; 
    text-align: center; 
    font-size: 12px; 
    font-weight: 600; 
    color: #333; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 6px; 
    white-space: nowrap; 
}

.mini-popup .leaflet-popup-content-wrapper { 
    border-radius: 20px; 
    padding: 0; 
}

/* ========== RADAR PLAYER ========== */
.radar-player { 
    position: absolute; 
    bottom: 30px; 
    left: 50%; 
    transform: translateX(-50%); 
    width: 90%; 
    max-width: 600px; 
    background: rgba(255, 255, 255, 0.95); 
    padding: 10px 20px; 
    border-radius: 50px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    z-index: 1000; 
    display: none; 
    align-items: center; 
    gap: 15px; 
    backdrop-filter: blur(5px); 
    border: 1px solid #eee; 
    animation: slideUp 0.3s ease; 
}

.btn-play { 
    background: #0d6efd; 
    color: white; 
    border: none; 
    width: 36px; 
    height: 36px; 
    border-radius: 50%; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 14px; 
    flex-shrink: 0; 
    transition: 0.2s; 
}

.btn-play:hover { 
    background: #0b5ed7; 
    transform: scale(1.1); 
}

.time-slider { 
    flex-grow: 1; 
    cursor: pointer; 
    height: 4px; 
    -webkit-appearance: none; 
    background: #e9ecef; 
    border-radius: 5px; 
}

.time-slider::-webkit-slider-thumb { 
    -webkit-appearance: none; 
    width: 16px; 
    height: 16px; 
    border-radius: 50%; 
    background: #0d6efd; 
    cursor: pointer; 
    box-shadow: 0 0 5px rgba(0,0,0,0.2); 
    margin-top: -6px; 
}

.time-slider::-webkit-slider-runnable-track { 
    height: 4px; 
    background: #ddd; 
    border-radius: 5px; 
}

.time-display { 
    font-size: 14px; 
    font-weight: 700; 
    color: #333; 
    min-width: 50px; 
    text-align: right; 
    font-variant-numeric: tabular-nums; 
}

/* ========== EARTHQUAKE PULSE ========== */
.quake-pulse { 
    animation: pulse-ring 2s infinite; 
    border-radius: 50%;
}

@keyframes pulse-ring { 
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); } 
    70% { box-shadow: 0 0 0 20px rgba(220, 53, 69, 0); } 
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); } 
}

/* ========== WATER LEVEL POPUP ========== */
.water-popup-card { 
    min-width: 250px; 
    font-size: 13px; 
    color: #333; 
    font-family: 'Sarabun', sans-serif;
    text-align: center; 
    padding: 12px 15px;
}

.water-popup-header { 
    margin: 0 0 10px 0; 
    color: #0d6efd; 
    font-size: 15px; 
    font-weight: bold; 
    border-bottom: 2px solid #f0f0f0; 
    padding-bottom: 5px; 
}

.water-level-box { 
    padding: 12px; 
    border-radius: 8px; 
    text-align: center; 
    margin: 10px 0; 
    color: #fff; 
    text-shadow: 0 1px 3px rgba(0,0,0,0.3); 
}

.water-level-box.dark-text { 
    color: #333; 
    text-shadow: none; 
}

.water-val-big { 
    font-size: 2em; 
    font-weight: bold; 
    line-height: 1; 
}

.water-status-text { 
    font-size: 13px; 
    margin-top: 4px; 
    font-weight: 500; 
    opacity: 0.95; 
}

.water-detail-container { 
    text-align: left; 
    background: #fff; 
    border: 1px solid #f0f0f0; 
    border-radius: 6px; 
    overflow: hidden; 
}

.water-detail-row { 
    display: flex; 
    justify-content: space-between; 
    padding: 6px 10px; 
    border-bottom: 1px solid #f5f5f5; 
    font-size: 12px;
}

.water-detail-row:nth-child(even) { background-color: #fafafa; } 
.water-detail-row:last-child { border-bottom: none; }

.water-footer { 
    font-size: 11px; 
    color: #888; 
    text-align: right; 
    margin-top: 12px; 
    padding-top: 8px; 
    border-top: 1px dashed #eee; 
    font-style: italic; 
    line-height: 1.4;
}

/* ========== WATER LEGEND ========== */
.water-legend {
    background: rgba(255, 255, 255, 0.95);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    font-size: 12px;
    line-height: 22px;
    color: #333;
    min-width: 140px;
    border: 1px solid #eee;
    margin-bottom: 20px;
    margin-left: 10px;
}

.water-legend b { 
    display: block; 
    margin-bottom: 5px; 
    color: #0d6efd; 
    font-size: 13px; 
    border-bottom: 1px solid #eee; 
    padding-bottom: 3px;
}

.water-legend i {
    width: 14px; 
    height: 14px;
    float: left; 
    margin-right: 8px; 
    margin-top: 4px;
    opacity: 0.9; 
    border-radius: 50%; 
    border: 1px solid rgba(0,0,0,0.1);
}

/* ========== BASIN POPUP ========== */
.basin-popup-header { 
    background: #0d6efd; 
    color: white; 
    padding: 10px; 
    margin: -10px -10px 10px -10px; 
    font-weight: bold; 
    border-radius: 8px 8px 0 0; 
    text-align: center; 
    font-size: 14px;
}

.basin-area-rai { 
    color: #28a745; 
    font-weight: bold; 
}

.basin-count-badge { 
    background: #6c757d; 
    color: white; 
    padding: 2px 8px; 
    border-radius: 12px; 
    font-size: 11px; 
}

/* ========== PERMANENT WATERMARK ========== */
.watermark-control {
    background: rgba(255, 255, 255, 0.85);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    font-size: 12px;
    color: #333;
    line-height: 1.4;
    border: 1px solid #ccc;
    margin-bottom: 5px !important;
    backdrop-filter: blur(2px);
}

/* Opacity Slider */
#opacity-slider {
    -webkit-appearance: none;
    width: 60px;
    height: 4px;
    background: #e9ecef;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
}

#opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #0d6efd;
    border-radius: 50%;
    cursor: pointer;
}

#opacity-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #0d6efd;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ========== ALERT CARD ========== */
.alert-card { 
    border-radius: 10px; 
    overflow: hidden; 
}

.alert-section { 
    padding: 10px 0; 
    border-bottom: 1px solid #f0f0f0; 
}

.alert-section:last-child { 
    border-bottom: none; 
}

.forecast-badge { 
    background: #eef6ff; 
    border-radius: 8px; 
    padding: 12px; 
    margin-top: 10px; 
    display: flex; 
    align-items: center; 
    gap: 12px;
    border: 1px solid #d0e3ff;
}

.forecast-info { 
    flex: 1; 
}

.forecast-main { 
    color: #0d6efd; 
    font-weight: 700; 
    font-size: 1rem; 
    display: block; 
}

.forecast-sub { 
    color: #666; 
    font-size: 0.8rem; 
}

/* ========== STORM ANIMATIONS ========== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.storm-icon-style {
    animation: spin 3s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 5px rgba(0, 81, 255, 0.8));
    color: #ffffff;
    background: rgba(13, 110, 253, 0.8);
    border-radius: 50%;
    border: 2px solid #fff;
}

.fa-balloon:before { content: "\f8fe"; }

.upper-air-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.3));
}

/* ========== RULER STYLES ========== */
.ruler-marker {
    background: #dc3545;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.ruler-line {
    stroke: #dc3545;
    stroke-width: 3;
    stroke-dasharray: 10, 10;
}

.distance-label {
    background: rgba(33, 37, 41, 0.9);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

/* ปรับแต่ง Popup เฉพาะของคลื่นทะเล */
.custom-wave-popup .leaflet-popup-content-wrapper {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}
.custom-wave-popup .leaflet-popup-content {
    margin: 0 !important;
    width: 240px !important;
}
.custom-wave-popup .leaflet-popup-tip {
    background: white !important;
}
canvas {
    display: block !important;
    max-width: 100%;
}

/* ส่วนปรับปรุง Bottom Sheet ให้เด่นขึ้นเวลาแจ้งเตือน */
#weather-summary {
    margin-top: 10px;
    padding: 15px;
    border-radius: 12px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.weather-alert-active {
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* Tomorrow.io Legend Styling */
.tomorrow-legend {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    font-family: 'Sarabun', sans-serif;
    font-size: 11px;
    line-height: 1.4;
    min-width: 120px;
    display: none; /* ซ่อนไว้เริ่มต้น */
}

.tomorrow-legend b {
    display: block;
    margin-bottom: 5px;
    color: #333;
}

.tomorrow-legend-bar {
    height: 12px;
    width: 100%;
    background: linear-gradient(to right, 
        rgba(0,0,0,0), 
        #00fbff, #0078ff, #00ff00, #ffff00, #ff8c00, #ff0000, #ff00ff);
    border-radius: 2px;
    margin-bottom: 4px;
}

.tomorrow-legend-labels {
    display: flex;
    justify-content: space-between;
    color: #666;
}




/* ปรับปรุง Legend ของ Tomorrow.io ให้ไม่ทับเมนูเลเยอร์ */
#tomorrow-legend-box {
    z-index: 8500 !important;
    pointer-events: none; /* เพื่อให้คลิกทะลุไปที่แผนที่ได้ถ้าจำเป็น */
}