/* ════════════════════════════════════════════════════════════
   WhatsApp inbox inside the portal (moved from Whatsapp/inbox.html)
   Everything is scoped under #screen-whatsapp / .wa- classes so it
   never clashes with the portal's own styles.
   ════════════════════════════════════════════════════════════ */
#screen-whatsapp { --wa-line:#e3e6ea; --wa-text:#111b21; --wa-muted:#667781; --wa-accent:#00a884; --wa-accent-d:#008069; --wa-out:#d9fdd3; --wa-chat:#efeae2; --wa-blue:#53bdeb; --wa-warn:#fff4ce; --wa-danger:#d93025; }
#screen-whatsapp.active { display: block; }
.wa-app { display: flex; height: calc(100vh - 120px); min-height: 480px; background: var(--card); border: var(--card-border); border-radius: 12px; overflow: hidden; color: var(--wa-text); }
.wa-hide { display: none !important; }
.wa-side { width: 360px; min-width: 280px; border-right: 1px solid var(--wa-line); display: flex; flex-direction: column; background: var(--card); }
.wa-sidehead { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--wa-line); }
.wa-sidehead h2 { margin: 0; font-size: 17px; flex: 1; font-weight: 700; }
.wa-iconbtn { background: none; border: 0; font-size: 17px; color: var(--wa-muted); padding: 4px 8px; border-radius: 6px; }
.wa-iconbtn:hover { background: #f0f2f5; }
.wa-iconbtn:disabled { opacity: .4; cursor: default; }
.wa-search { padding: 8px 12px; border-bottom: 1px solid var(--wa-line); }
.wa-search input { width: 100%; background: #f0f2f5; border: 0; border-radius: 8px; padding: 8px 11px; font-size: 13.5px; outline: none; }
.wa-list { flex: 1; overflow-y: auto; }
.wa-ct { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f2f2f2; cursor: pointer; align-items: center; }
.wa-ct:hover { background: #f5f6f6; }
.wa-ct.active { background: #e9edef; }
.wa-av { width: 42px; height: 42px; border-radius: 50%; background: #dfe5e7; color: #54656f; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: 14px; }
.wa-ctmain { flex: 1; min-width: 0; }
.wa-ctrow { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.wa-ctname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-cttime { font-size: 12px; color: var(--wa-muted); flex-shrink: 0; }
.wa-ctprev { font-size: 13px; color: var(--wa-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.wa-badge { background: var(--wa-accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.wa-cust { font-size: 10.5px; font-weight: 700; color: #1d6fa5; background: #e7f2fa; border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.wa-ct.unread .wa-cttime { color: var(--wa-accent); font-weight: 600; }
.wa-empty { padding: 30px; text-align: center; color: var(--wa-muted); }
.wa-usage { padding: 7px 14px; font-size: 12px; color: var(--wa-muted); border-bottom: 1px solid var(--wa-line); background: #fafbfb; line-height: 1.5; }
.wa-usage b { color: var(--wa-text); }
.wa-usage .bar { height: 4px; background: var(--wa-line); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.wa-usage .bar i { display: block; height: 100%; background: var(--wa-accent); }
.wa-usage.warn { background: var(--wa-warn); } .wa-usage.warn .bar i { background: #e0a800; }
.wa-usage.over { background: #fde7e7; } .wa-usage.over .bar i { background: var(--wa-danger); }

.wa-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--wa-chat); }
.wa-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--wa-muted); text-align: center; padding: 20px; }
.wa-thead { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--card); border-bottom: 1px solid var(--wa-line); flex-wrap: wrap; }
.wa-thead .info { flex: 1; min-width: 140px; }
.wa-thead .nm { font-weight: 700; }
.wa-thead .sub { font-size: 12px; color: var(--wa-muted); }
.wa-back { display: none; }
.wa-btn { background: var(--wa-accent); color: #fff; border: 0; border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 13px; }
.wa-btn:hover { background: var(--wa-accent-d); }
.wa-btn.ghost { background: transparent; color: var(--wa-accent-d); border: 1px solid var(--wa-line); }
.wa-btn:disabled { opacity: .5; cursor: default; }
.wa-window { font-size: 12px; padding: 6px 14px; text-align: center; }
.wa-window.open { background: #e7f8f0; color: #0a6c4f; }
.wa-window.closed { background: var(--wa-warn); color: #6b5300; }
.wa-thread { flex: 1; overflow-y: auto; padding: 14px 6%; display: flex; flex-direction: column; gap: 3px; }
.wa-day { align-self: center; background: var(--card); color: var(--wa-muted); font-size: 12px; padding: 4px 10px; border-radius: 7px; margin: 10px 0; box-shadow: 0 1px 1px #0001; }
.wa-msg { max-width: 65%; padding: 6px 8px 4px; border-radius: 8px; box-shadow: 0 1px 1px #0001; word-wrap: break-word; white-space: pre-wrap; position: relative; font-size: 14px; line-height: 1.4; }
.wa-msg.in { background: var(--card); align-self: flex-start; }
.wa-msg.out { background: var(--wa-out); align-self: flex-end; }
.wa-msg .meta { font-size: 11px; color: var(--wa-muted); text-align: right; margin-top: 2px; white-space: nowrap; }
.wa-msg .tick.read { color: var(--wa-blue); }
.wa-msg .tick.failed { color: var(--wa-danger); }
.wa-msg .errtxt { font-size: 12px; color: var(--wa-danger); margin-top: 3px; }
.wa-msg .tpl { font-size: 11px; color: var(--wa-muted); margin-bottom: 2px; }
.wa-msg .quote { border-left: 3px solid var(--wa-accent); background: #0000000d; padding: 3px 6px; border-radius: 4px; font-size: 12px; color: var(--wa-muted); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-msg img, .wa-msg video { max-width: 280px; max-height: 320px; border-radius: 6px; display: block; cursor: pointer; }
.wa-msg audio { max-width: 260px; }
.wa-msg a { color: #027eb5; }
.wa-doc { display: flex; align-items: center; gap: 8px; background: #0000000a; padding: 8px; border-radius: 6px; text-decoration: none; }
.wa-msg .replybtn { position: absolute; top: 2px; right: -26px; opacity: 0; background: none; border: 0; color: var(--wa-muted); }
.wa-msg.out .replybtn { right: auto; left: -26px; }
.wa-msg:hover .replybtn { opacity: 1; }
.wa-replybar { display: flex; align-items: center; gap: 8px; background: #f0f2f5; padding: 6px 14px; font-size: 13px; color: var(--wa-muted); border-top: 1px solid var(--wa-line); }
.wa-replybar span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border-left: 3px solid var(--wa-accent); padding-left: 8px; }
.wa-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; background: #f0f2f5; }
.wa-composer textarea { flex: 1; resize: none; max-height: 140px; min-height: 40px; border: 0; border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 14px; outline: none; }
.wa-composer textarea:disabled { background: #e9edef; }
.wa-send { border-radius: 50% !important; width: 42px; height: 42px; padding: 0 !important; flex-shrink: 0; font-size: 16px; }
.wa-preview { background: var(--wa-out); border-radius: 8px; padding: 10px; white-space: pre-wrap; font-size: 13px; }
.wa-small { font-size: 12px; color: var(--wa-muted); }
.nav-item .wa-navbadge { margin-left: auto; background: #00a884; color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }

@media (max-width: 760px) {
  .wa-app { height: calc(100vh - 150px); }
  .wa-side { width: 100%; min-width: 0; }
  .wa-app.chatting .wa-side { display: none; }
  .wa-app:not(.chatting) .wa-main { display: none; }
  .wa-back { display: inline-block; }
  .wa-thread { padding: 12px 10px; }
  .wa-msg { max-width: 85%; }
  .wa-msg .replybtn { display: none; }
}
