/* WhatsApp-style chat UI.
   Bubble colours, tails and header layout adapted from aladinyo/WhatsappyApp (MIT,
   © 2021 Alaa Eddine Boubekeur — see CREDITS.md). The wallpaper is our own CSS
   pattern; no WhatsApp image assets are used. */

.wa-stage { display: grid; grid-template-columns: 392px minmax(0, 1fr); gap: 28px; align-items: start; }

/* phone frame */
.phone { width: 392px; height: 800px; max-height: calc(100vh - 120px); min-height: 600px; border-radius: 46px; background: #111; padding: 12px; box-shadow: 0 0 0 2px #2a2a2a, 0 30px 60px rgba(35, 28, 23, .28); position: sticky; top: 86px; }
.phone-screen { width: 100%; height: 100%; border-radius: 36px; overflow: hidden; display: flex; flex-direction: column; background: #efeae2; position: relative; }
.phone-status { height: 34px; flex: none; background: #075e54; color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 26px 0 30px; font-size: 13px; font-weight: 600; }
.phone-status .notch { width: 96px; height: 24px; background: #111; border-radius: 0 0 14px 14px; position: absolute; left: 50%; top: 0; transform: translateX(-50%); }

.wa-header { flex: none; background: #075e54; color: #fff; display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px 6px; }
.wa-header .back { font-size: 22px; padding: 0 4px; opacity: .9; }
.wa-avatar { width: 38px; height: 38px; border-radius: 50%; background: #231c17; color: #d9b38c; display: grid; place-items: center; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 16px; font-weight: 600; flex: none; border: 1.5px solid rgba(255, 255, 255, .25); }
.wa-title { flex: 1; min-width: 0; }
.wa-title .n { font-weight: 600; font-size: 15.5px; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-title .s { font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verified { width: 15px; height: 15px; border-radius: 50%; background: #25d366; display: inline-grid; place-items: center; font-size: 10px; color: #fff; flex: none; }
.wa-header .acts { display: flex; gap: 16px; font-size: 17px; opacity: .9; padding-right: 6px; }

/* wallpaper: subtle repeating doodle dots, our own */
.wa-body { flex: 1; overflow-y: auto; padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 3px;
  background-color: #efeae2;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(120, 100, 80, .07) 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 65%, rgba(120, 100, 80, .06) 0 3px, transparent 3.5px),
    radial-gradient(circle at 45% 85%, rgba(120, 100, 80, .05) 0 1.5px, transparent 2px);
  background-size: 46px 46px, 62px 62px, 38px 38px;
  scrollbar-width: none; }
.wa-body::-webkit-scrollbar { display: none; }
.wa-day { align-self: center; background: #e1f2fb; color: #54656f; font-size: 11.5px; padding: 4px 10px; border-radius: 8px; margin: 6px 0; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
.wa-encrypt { align-self: center; text-align: center; background: #fdf4c5; color: #54656f; font-size: 11.5px; padding: 6px 10px; border-radius: 8px; margin: 4px 14px 8px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); max-width: 300px; }

.msg { max-width: 82%; padding: 6px 8px 8px 9px; border-radius: 8px; font-size: 14.2px; line-height: 1.38; position: relative; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); word-wrap: break-word; white-space: pre-wrap; color: #111b21; animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
.msg .meta { float: right; margin: 6px 0 -4px 10px; font-size: 11px; color: #667781; display: inline-flex; gap: 3px; align-items: center; white-space: nowrap; }
.msg .ticks { color: #53bdeb; font-size: 12px; letter-spacing: -3px; padding-right: 3px; }
.msg.in { align-self: flex-start; background: #fff; }
.msg.out { align-self: flex-end; background: #d9fdd3; }
.msg.first.in { border-top-left-radius: 0; margin-top: 6px; }
.msg.first.out { border-top-right-radius: 0; margin-top: 6px; }
.msg.first.in::before, .msg.first.out::before { content: ''; position: absolute; top: 0; width: 8px; height: 13px; }
.msg.first.in::before { left: -8px; clip-path: polygon(0 0, 100% 0, 100% 100%); background: #fff; }
.msg.first.out::before { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); background: #d9fdd3; }
.msg.staff { background: #fff4e5; }
.msg.first.staff::before { background: #fff4e5; }
.msg .who { font-size: 12px; font-weight: 600; color: #a8744f; margin-bottom: 2px; }
.msg.system { align-self: center; background: #fbe5e3; color: #8a1c15; font-size: 12.5px; max-width: 92%; }
.msg b { font-weight: 600; }
.msg a { color: #027eb5; }
.msg[dir=rtl] .meta { float: left; margin: 6px 10px -4px 0; }

.typing { align-self: flex-start; background: #fff; border-radius: 8px; border-top-left-radius: 0; padding: 10px 14px; display: flex; gap: 4px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); margin-top: 6px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa5ab; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.wa-footer { flex: none; display: flex; align-items: flex-end; gap: 6px; padding: 6px 8px 14px; background: transparent; }
.wa-input { flex: 1; display: flex; align-items: flex-end; gap: 8px; background: #fff; border-radius: 22px; padding: 8px 12px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); min-height: 44px; }
.wa-input .em { color: #8696a0; font-size: 19px; line-height: 26px; }
.wa-input textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; font-size: 15px; line-height: 1.35; max-height: 110px; min-height: 22px; padding: 2px 0; box-shadow: none !important; }
.wa-send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #00a884; color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; font-size: 18px; }
.wa-send:disabled { background: #7fcfbd; cursor: default; }
.wa-send svg { width: 20px; height: 20px; }

/* insight panel next to the phone */
.insight-panel { display: flex; flex-direction: column; gap: 16px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: 13px; text-align: left; }
.quick button:hover { border-color: var(--wa); color: var(--wa); }
.quick button[dir=rtl] { font-family: inherit; }
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; font-weight: 500; }
.score { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.score > div { height: 100%; background: var(--good); border-radius: 99px; transition: width .4s; }
.analysis-log { font-size: 12.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.analysis-log div { padding: 6px 8px; background: var(--surface-2); border-radius: 8px; }

/* clinic inbox (WhatsApp-Web-like) */
.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 300px; height: calc(100vh - 130px); min-height: 560px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--line); overflow-y: auto; }
.inbox-list .search { padding: 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.chat-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item .av { width: 44px; height: 44px; border-radius: 50%; background: #dfe5e7; display: grid; place-items: center; font-weight: 600; color: #54656f; }
.chat-item .nm { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .last { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .tm { font-size: 11px; color: var(--ink-3); text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.inbox-chat { display: flex; flex-direction: column; min-width: 0; background: #efeae2; }
.inbox-chat .wa-header { background: #f0f2f5; color: #111b21; border-bottom: 1px solid var(--line); padding: 10px 14px; }
.inbox-chat .wa-header .s { color: #667781; }
.inbox-chat .wa-body { padding: 14px 7%; }
.inbox-side { border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.takeover { background: #fff4e5; border-bottom: 1px solid #f0dcae; padding: 8px 14px; font-size: 12.5px; color: #6b4600; display: flex; gap: 10px; align-items: center; }

@media (max-width: 1180px) {
  .inbox { grid-template-columns: 290px minmax(0, 1fr); }
  .inbox-side { display: none; }
}
@media (max-width: 980px) {
  .wa-stage { grid-template-columns: 1fr; justify-items: center; }
  .insight-panel { width: 100%; }
  .phone { position: relative; top: 0; }
}
@media (max-width: 760px) {
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox-list { max-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); }
  .inbox-chat { height: 560px; }
}
@media (max-width: 440px) {
  .phone { width: 100%; height: 640px; padding: 8px; border-radius: 34px; }
  .phone-screen { border-radius: 28px; }
}

/* video: WhatsApp full screen, like the patient's own phone */
body.wa-full .lead-text, body.wa-full .insight-panel, body.wa-full .wa-encrypt, body.wa-full .phone-status .notch { display: none !important; }
body.wa-full .view { padding: 0 !important; }
body.wa-full .wa-stage { display: block; }
body.wa-full .phone { position: fixed; inset: 0; top: 0; width: 100vw; height: 100vh; max-height: none; min-height: 0; border-radius: 0; padding: 0; box-shadow: none; background: #075e54; }
body.wa-full .phone-screen { border-radius: 0; }
body.wa-full .phone-status { padding: 0 18px; }
