/* ============================================================
   Emergency SOS — resident button + control-room live panel
   ============================================================ */

/* ---------- Resident floating SOS button ---------- */
.sos-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9000;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: radial-gradient(circle at 30% 30%, #ff5b5b, #d40000);
    color: #fff;
    font-family: inherit;
    font-weight: 800;
    font-size: 15px;
    line-height: 1.1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow: 0 6px 20px rgba(212, 0, 0, .45);
    animation: sos-pulse 2s infinite;
    transition: transform .12s ease;
}

.sos-fab:hover { transform: scale(1.06); }
.sos-fab:active { transform: scale(.94); }
.sos-fab .sos-fab-icon { font-size: 26px; }
.sos-fab[disabled] { opacity: .65; cursor: default; animation: none; }

@keyframes sos-pulse {
    0%   { box-shadow: 0 6px 20px rgba(212,0,0,.45), 0 0 0 0 rgba(212,0,0,.5); }
    70%  { box-shadow: 0 6px 20px rgba(212,0,0,.45), 0 0 0 18px rgba(212,0,0,0); }
    100% { box-shadow: 0 6px 20px rgba(212,0,0,.45), 0 0 0 0 rgba(212,0,0,0); }
}

/* ---------- Shared modal ---------- */
.sos-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
}

.sos-modal {
    background: #fff;
    border-radius: 16px;
    max-width: 420px;
    width: 100%;
    padding: 26px 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    direction: rtl;
}

.sos-modal-emoji { font-size: 48px; line-height: 1; }
.sos-modal h2 { margin: 14px 0 6px; color: #d40000; font-size: 22px; }
.sos-modal p { margin: 0 0 8px; color: #444; font-size: 15px; line-height: 1.6; }

.sos-owner-card {
    background: #fff5f5;
    border: 1px solid #ffd2d2;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 14px 0 6px;
    color: #b00000;
    font-weight: 700;
    font-size: 16px;
}

.sos-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.sos-btn {
    flex: 1;
    padding: 13px 14px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 15px;
    transition: filter .12s ease;
}

.sos-btn:hover { filter: brightness(.95); }
.sos-btn-danger { background: #d40000; color: #fff; }
.sos-btn-cancel { background: #eceff3; color: #333; }
.sos-btn[disabled] { opacity: .6; cursor: default; }

/* ---------- Control-room live panel ---------- */
.sos-cr-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 8800;
    width: 360px;
    max-width: calc(100vw - 40px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    border: 1px solid #ececec;
    overflow: hidden;
    direction: rtl;
    font-family: inherit;
}

.sos-cr-panel.has-active { border-color: #ff4d4d; animation: sos-flash 1.1s infinite; }

@keyframes sos-flash {
    0%, 100% { box-shadow: 0 12px 40px rgba(0,0,0,.25); }
    50%      { box-shadow: 0 12px 40px rgba(255,0,0,.55); }
}

.sos-cr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #b00000, #d40000);
    color: #fff;
    cursor: pointer;
}

.sos-cr-header strong { font-size: 15px; }
.sos-cr-count {
    background: #fff;
    color: #d40000;
    border-radius: 999px;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    font-size: 13px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sos-cr-toggle { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }

.sos-cr-body { max-height: 50vh; overflow-y: auto; }
.sos-cr-panel.collapsed .sos-cr-body { display: none; }

.sos-cr-empty { padding: 22px 14px; text-align: center; color: #888; font-size: 14px; }

.sos-alert-card {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f0f0;
}
.sos-alert-card.is-new { background: #fff5f5; }

.sos-alert-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.sos-alert-unit { font-weight: 800; color: #b00000; font-size: 16px; }
.sos-alert-time { font-size: 12px; color: #999; }
.sos-alert-name { color: #333; font-size: 14px; margin: 3px 0; }
.sos-alert-phone { font-size: 13px; }
.sos-alert-phone a { color: #1565c0; text-decoration: none; font-weight: 700; }

.sos-status-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    margin-top: 6px;
}
.sos-status-new { background: #ffe0e0; color: #c00; }
.sos-status-acknowledged { background: #fff3cd; color: #946200; }
.sos-status-resolved { background: #e3f4e3; color: #2e7d32; }

.sos-alert-actions { display: flex; gap: 8px; margin-top: 10px; }
.sos-mini-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 13px;
}
.sos-mini-ack { background: #ffb300; color: #fff; }
.sos-mini-resolve { background: #2e7d32; color: #fff; }
.sos-mini-btn:hover { filter: brightness(.95); }

/* Dark mode niceties */
body.dark-mode .sos-modal { background: #1f2733; }
body.dark-mode .sos-modal p { color: #cbd5e1; }
body.dark-mode .sos-btn-cancel { background: #33404f; color: #e2e8f0; }
body.dark-mode .sos-cr-panel { background: #1f2733; border-color: #33404f; }
body.dark-mode .sos-alert-card { border-color: #33404f; }
body.dark-mode .sos-alert-name { color: #cbd5e1; }
body.dark-mode .sos-alert-card.is-new { background: #2a1d1d; }

/* ---------- Control-room: select & delete alerts ---------- */
.sos-alert-check-wrap { display: inline-flex; align-items: center; }
.sos-alert-check { width: 18px; height: 18px; cursor: pointer; }

.sos-cr-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #eee;
    background: #fafafa;
}
.sos-cr-selall { font-size: 13px; color: #555; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.sos-cr-selall input { width: 16px; height: 16px; cursor: pointer; }
.sos-cr-delete {
    border: none;
    background: #d40000;
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
}
.sos-cr-delete:hover { background: #b00000; }

body.dark-mode .sos-cr-footer { background: #1a212b; border-color: #33404f; }
body.dark-mode .sos-cr-selall { color: #cbd5e1; }
