/* =========================================================
   monitor.css — แผนที่ / ภาพรวม realtime + วางหมุดใน popup มิเตอร์ + แถบสำเร็จ (step34)
   ชื่อ class ใหม่ขึ้นต้น mn- (CSS ทุกหน้าโหลดรวมกัน)
   ========================================================= */

/* ---------- สีสถานะ 4 แบบ (ผู้ใช้ยืนยัน 13 ต.ค. 2026) ---------- */
.dot-warning  { background: var(--c-warn); }
.dot-error    { background: var(--c-err); }
.dot-disabled { background: #9aa39c; }

.st-warning    { background: var(--c-warn-bg); color: var(--c-warn-fg); }
.st-warning i  { background: var(--c-warn); }
.st-error      { background: var(--c-err-bg); color: var(--c-err-fg); }
.st-error i    { background: var(--c-err); }
.st-disabled   { background: #eeece6; color: #6b665d; }
.st-disabled i { background: #9aa39c; }

/* ---------- ป้าย realtime บนแผนที่ (มุมขวาบน) ---------- */
.mn-live {
    position: absolute;
    right: 19px;
    top: 19px;
    display: flex;
    align-items: center;
    gap: 6.5px;
    padding: calc(6.5px * var(--k)) calc(11px * var(--k));
    border-radius: 16px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: calc(11px * var(--k));
    font-variant-numeric: tabular-nums;
}

.mn-live i,
.mn-live-dot {
    display: inline-block;
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c-ok);
    animation: mnPulse 1.6s ease-in-out infinite;
}

.mn-live.off i,
.mn-live-dot.off {
    background: var(--c-warn);
    animation: none;
}

@keyframes mnPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .mn-live i, .mn-live-dot { animation: none; } }

.mn-empty-map {
    position: absolute;
    left: 50%;
    bottom: 56px;
    transform: translateX(-50%);
    max-width: calc(100% - 40px);
    padding: 7px 12px;
    border-radius: 6px;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: calc(11.5px * var(--k));
    text-align: center;
}

.mn-note {
    margin-top: 4px;
    font-size: calc(11.5px * var(--k));
    color: var(--c-ink-soft);
}

/* ---------- หัวรองหน้าภาพรวม ---------- */
.mn-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.mn-live-text { color: var(--c-ok-fg); }
.mn-live-text.off { color: var(--c-warn-fg); }

/* ---------- แถบสำเร็จ (OkBar) ---------- */
.mn-okbar {
    animation: mnFadeIn .2s ease-out;
}

@keyframes mnFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- popup มิเตอร์: ฟอร์มซ้าย + วางหมุดขวา ---------- */
.modal.mn-mt-modal {
    width: calc(960px * var(--k));
}

.mn-mt-body {
    flex-direction: row;
    align-items: flex-start;
    gap: calc(22px * var(--k));
}

.mn-mt-form {
    flex: 1;
    min-width: 0;
}

.mn-pick {
    flex: none;
    width: calc(372px + 22px * var(--k));   /* รูป 372 px + ระยะห่างซ้าย (box-sizing: border-box) */
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding-left: calc(22px * var(--k));
    border-left: 1px solid var(--c-line);
    font-size: calc(11.5px * var(--k));
    color: var(--c-ink-soft);
}

.mn-pick-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mn-link-danger {
    border: 0;
    background: none;
    padding: 0;
    color: var(--c-err-fg);
    font: inherit;
    cursor: pointer;
}

.mn-link-danger:disabled { opacity: .4; cursor: default; }

/* ขนาดคงที่ 372 × 282.65 px (สัดส่วนรูป 1116 : 848) โค้ดคำนวณ % จากขนาดนี้ */
.mn-pick-map {
    position: relative;
    flex: none;
    width: 372px;
    height: 282.65px;
    overflow: hidden;
    border-radius: 6.5px;
    background: var(--c-brand-dark) url("../images/maps/oasys-site.png") 0 0 / 100% 100% no-repeat;
    cursor: crosshair;
}

.mn-pick-map .mn-pin {
    pointer-events: none;     /* ให้คลิกตกที่รูป (OffsetX/Y เทียบกับรูป) */
    font-size: 10px;
    box-shadow: 0 0 0 1.5px #fff, 0 1px 3px rgba(0, 0, 0, .3);
}

.mn-pick-empty {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 5px 8px;
    border-radius: 5px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 10.5px;
    text-align: center;
    pointer-events: none;
}

.mn-pick-info {
    display: flex;
    justify-content: space-between;
    color: #8a938c;
}

.mn-pick-lbl {
    display: flex;
    align-items: center;
    gap: 9px;
}

@media (max-width: 900px) {
    .mn-mt-body { flex-direction: column; }
    .mn-pick { padding-left: 0; border-left: 0; }
}

/* ---------- หน้าแผนที่: รูปเต็มกรอบ ไม่เห็นขอบเขียว (13 ต.ค. 2026) ----------
   เดิม map.css ให้รูปพอดีกรอบ (min) จอที่สัดส่วนไม่ตรงจะเหลือแถบเขียวบน-ล่าง/ซ้าย-ขวา
   ใช้ max แทน: รูปขยายจนเต็มกรอบเสมอ ส่วนที่เกินถูกตัดเท่า ๆ กันรอบด้าน
   หมุดยังตรงตำแหน่ง เพราะใช้ % ของกล่องรูปเดิม (หมุดที่อยู่ริมรูปมากอาจถูกตัดเมื่อจอแคบ/สูงผิดสัดส่วน) */
.mp-img {
    width: max(100cqw, calc(100cqh * 1116 / 848));
    height: max(100cqh, calc(100cqw * 848 / 1116));
}

/* ---------- แถบบน: ไม่มี Alarm ค้าง Ack → ไอคอนกระดิ่งเล็ก (13 ต.ค. 2026) ---------- */
.tb-pill.mn-bell-idle {
    justify-content: center;
    width: var(--pill-h);
    padding: 0;
    text-decoration: none;
}

.tb-pill.mn-bell-idle:hover { background: var(--c-pill-hover); }
.tb-pill.mn-bell-idle.off { color: #9aa39c; }

/* ---------- แผนที่: เลขมิเตอร์ล่าสุด (METER.TOTAL_VOL) เต็มแถว ---------- */
.mn-stat-wide { grid-column: 1 / -1; }
.mn-total { font-size: calc(19px * var(--k)); font-variant-numeric: tabular-nums; }

/* ---------- แผนที่: มิเตอร์ที่มี Alarm ยังไม่ Ack กระพริบแดง (step38) ---------- */
@keyframes mnPinAlarm {
    0%, 45%  { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .45), 0 0 14px rgba(220, 38, 38, .7); }
    55%, 100% { background: rgba(0, 0, 0, .6); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
}
@keyframes mnDotAlarm { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }

.pin.mn-pin-alarm { z-index: 3; animation: mnPinAlarm 1s steps(1, end) infinite; }
.pin.mn-pin-alarm i { background: #fff; border-color: #dc2626; }
.mn-dot-alarm { animation: mnDotAlarm 1s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
    .pin.mn-pin-alarm { animation: none; background: #dc2626; }
    .mn-dot-alarm { animation: none; }
}
