/* ==========================================================================
   NurseChat — WhatsApp-style chat & call UI
   ========================================================================== */
:root {
  --wa-bg: #0b141a;
  --wa-panel: #111b21;
  --wa-header: #202c33;
  --wa-out: #005c4b;
  --wa-in: #202c33;
  --wa-green: #00a884;
  --wa-text: #e9edef;
  --wa-sub: #8696a0;
}

/* ---------- Chat layer ---------- */
.wa-chat-layer {
  position: fixed; inset: 0; z-index: 5000;
  display: flex; justify-content: center; align-items: stretch;
  background: rgba(0,0,0,.4);
  animation: waFade .2s ease;
}
@keyframes waFade { from { opacity: 0 } to { opacity: 1 } }

.wa-chat {
  width: 100%; max-width: 480px; height: 100%;
  display: flex; flex-direction: column;
  background: var(--wa-bg);
  background-image:
    radial-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    radial-gradient(rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 26px 26px; background-position: 0 0, 13px 13px;
  box-shadow: 0 0 40px rgba(0,0,0,.5);
  animation: waSlide .25s ease;
}
@keyframes waSlide { from { transform: translateY(14px); opacity: .6 } to { transform: none; opacity: 1 } }

.wa-header {
  display: flex; align-items: center; gap: 10px;
  background: var(--wa-header); color: var(--wa-text);
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  flex-shrink: 0;
}
.wa-back { background: none; border: none; color: var(--wa-text); font-size: 19px; cursor: pointer; padding: 4px 6px; }
.wa-avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #2a3942; display: grid; place-items: center; color: #8696a0; font-size: 18px; flex-shrink: 0; }
.wa-avatar img { width: 100%; height: 100%; object-fit: cover; }
.wa-peer { flex: 1; min-width: 0; }
.wa-peer h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--wa-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-status { font-size: 12px; color: var(--wa-sub); }
.wa-head-actions { display: flex; gap: 4px; }
.wa-head-actions button { background: none; border: none; color: var(--wa-text); font-size: 18px; cursor: pointer; padding: 8px; border-radius: 50%; }
.wa-head-actions button:active { background: rgba(255,255,255,.1); }

.wa-messages { flex: 1; overflow-y: auto; padding: 14px 10px 8px; display: flex; flex-direction: column; gap: 3px; }

.wa-msg { display: flex; max-width: 82%; }
.wa-msg.out { align-self: flex-end; justify-content: flex-end; }
.wa-msg.in { align-self: flex-start; }
.wa-bubble {
  position: relative; padding: 6px 9px 6px 9px; border-radius: 8px;
  color: var(--wa-text); font-size: 14.5px; line-height: 1.35; word-break: break-word;
  box-shadow: 0 1px .5px rgba(0,0,0,.2); min-width: 64px;
}
.wa-msg.out .wa-bubble { background: var(--wa-out); border-top-right-radius: 2px; }
.wa-msg.in .wa-bubble { background: var(--wa-in); border-top-left-radius: 2px; }
.wa-text-body { padding-right: 50px; }
.wa-meta { float: right; margin: 4px 0 -2px 8px; font-size: 10.5px; color: rgba(233,237,239,.6); display: inline-flex; align-items: center; gap: 3px; }
.wa-tick i { color: #53bdeb; font-size: 11px; }

.wa-call-log { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding-right: 46px; }
.wa-call-log i { color: var(--wa-green); }
.wa-call-log.missed i { color: #f15c6d; }

/* voice message */
.wa-voice { display: flex; align-items: center; gap: 8px; padding-right: 44px; }
.wa-voice-play { width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255,255,255,.12); color: var(--wa-text); cursor: pointer; flex-shrink: 0; }
.wa-voice-wave { display: flex; align-items: center; gap: 3px; height: 22px; }
.wa-voice-wave span { width: 3px; border-radius: 3px; background: var(--wa-sub); }
.wa-voice-wave span:nth-child(1){height:6px}.wa-voice-wave span:nth-child(2){height:14px}.wa-voice-wave span:nth-child(3){height:20px}.wa-voice-wave span:nth-child(4){height:10px}.wa-voice-wave span:nth-child(5){height:18px}.wa-voice-wave span:nth-child(6){height:8px}.wa-voice-wave span:nth-child(7){height:14px}.wa-voice-wave span:nth-child(8){height:6px}
.wa-voice-dur { font-size: 11px; color: var(--wa-sub); }

/* input bar */
.wa-input-bar { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); background: var(--wa-bg); flex-shrink: 0; }
.wa-input-wrap { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--wa-header); border-radius: 22px; padding: 6px 10px; }
.wa-input-wrap input { flex: 1; background: none; border: none; outline: none; color: var(--wa-text); font-size: 15px; padding: 4px 2px; }
.wa-input-wrap input::placeholder { color: var(--wa-sub); }
.wa-emoji, .wa-attach { background: none; border: none; color: var(--wa-sub); font-size: 18px; cursor: pointer; padding: 2px 4px; }
.wa-send, .wa-mic { width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--wa-green); color: #fff; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.wa-send:active, .wa-mic:active { transform: scale(.94); }

/* recording overlay */
.wa-input-bar.recording .wa-input-wrap, .wa-input-bar.recording .wa-mic, .wa-input-bar.recording .wa-send { visibility: hidden; }
.wa-rec-ui { position: absolute; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); height: 50px; background: var(--wa-header); border-radius: 26px; display: flex; align-items: center; gap: 12px; padding: 0 14px; }
.wa-rec-cancel { background: none; border: none; color: #f15c6d; font-size: 18px; cursor: pointer; }
.wa-rec-dot { width: 11px; height: 11px; border-radius: 50%; background: #f15c6d; animation: waPulse 1s infinite; }
@keyframes waPulse { 50% { opacity: .25 } }
.wa-rec-time { color: var(--wa-text); font-variant-numeric: tabular-nums; }
.wa-rec-hint { flex: 1; color: var(--wa-sub); font-size: 13px; }
.wa-rec-send { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--wa-green); color: #fff; font-size: 16px; cursor: pointer; }

/* ---------- Call layer ---------- */
.wa-call-layer { position: fixed; inset: 0; z-index: 6000; }
.wa-call { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, #1f2c34 0%, #0b141a 100%); color: #fff; padding: 0; }

/* voice stage */
.wa-voice-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding-top: 60px; width: 100%; }
.wa-call-avatar { width: 130px; height: 130px; border-radius: 50%; overflow: hidden; background: #2a3942; display: grid; place-items: center; font-size: 52px; color: #8696a0; box-shadow: 0 0 0 6px rgba(255,255,255,.05); animation: waRing 2s infinite; }
.wa-call-avatar.small { width: 84px; height: 84px; font-size: 34px; animation: none; box-shadow: none; }
.wa-call-avatar img { width: 100%; height: 100%; object-fit: cover; }
@keyframes waRing { 0%,100% { box-shadow: 0 0 0 6px rgba(0,168,132,.18) } 50% { box-shadow: 0 0 0 18px rgba(0,168,132,0) } }
.wa-voice-stage h2 { margin: 0; font-size: 26px; font-weight: 600; }
.wa-call-status { color: #c9d3d9; font-size: 15px; margin: 0; }

/* video stage */
.wa-video-stage { position: relative; flex: 1; width: 100%; background: #000; overflow: hidden; }
.wa-remote-video { width: 100%; height: 100%; object-fit: cover; background: #111b21; }
.wa-local-video { position: absolute; top: 18px; right: 14px; width: 104px; height: 150px; object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.25); background: #000; z-index: 3; }
.wa-video-overlay-info { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(11,20,26,.55); z-index: 2; }
.wa-video-overlay-info h2 { margin: 0; font-size: 22px; }
.wa-video-overlay-info p { margin: 0; color: #c9d3d9; }
.wa-call.video .wa-call-actions { position: absolute; bottom: 0; left: 0; right: 0; z-index: 4; background: linear-gradient(0deg, rgba(0,0,0,.6), transparent); }

/* call actions */
.wa-call-actions { display: flex; align-items: center; justify-content: center; gap: 26px; padding: 26px 24px max(34px, env(safe-area-inset-bottom)); width: 100%; }
.wa-call-actions.incoming { justify-content: space-around; }
.wa-call-btn { display: flex; flex-direction: column; align-items: center; gap: 7px; background: none; border: none; color: #fff; cursor: pointer; font-size: 12px; }
.wa-call-btn i { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; }
.wa-call-btn.accept i { background: var(--wa-green); animation: waBob 1.2s infinite; }
.wa-call-btn.decline i, .wa-call-btn.hangup i { background: #f15c6d; }
@keyframes waBob { 50% { transform: translateY(-6px) } }
.wa-call-ctl { width: 54px; height: 54px; border-radius: 50%; border: none; background: rgba(255,255,255,.16); color: #fff; font-size: 20px; cursor: pointer; }
.wa-call-ctl.off { background: #fff; color: #1f2c34; }
.wa-call-btn.hangup { margin-left: 6px; }

/* ---------- Nurse inbox panel ---------- */
.inbox-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #f15c6d; color: #fff; font-size: 12px; font-weight: 700; margin-left: 6px; }
.inbox-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 6px; background: none; border: none; border-bottom: 1px solid rgba(0,0,0,.06); cursor: pointer; text-align: left; }
.inbox-row:active { background: rgba(0,0,0,.04); }
.inbox-ava { width: 42px; height: 42px; border-radius: 50%; background: #e6f4f1; color: var(--wa-green); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.inbox-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.inbox-main b { font-size: 14.5px; color: #14303a; }
.inbox-main small { font-size: 12.5px; color: #6b7c85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-unread { background: var(--wa-green); color: #fff; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; font-size: 12px; font-weight: 700; font-style: normal; }

@media (min-width: 520px) {
  .wa-call { max-width: 480px; margin: 0 auto; border-radius: 16px; height: 100%; }
}
