/* Staff inbox. System fonts only, so the page's strict content-security policy
   doesn't need to allow any outside hosts. */
:root{--brand:#800020;--ink:#27282c;--muted:#6b6c70;--line:#e6e6e6;--bg:#f6f4f4}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;color:var(--ink);background:var(--bg)}
[hidden]{display:none!important}
button{font:inherit;cursor:pointer}
a{color:var(--brand)}
.muted{color:var(--muted)}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
:focus-visible{outline:3px solid var(--brand);outline-offset:2px}

.btn{border:0;border-radius:999px;padding:10px 20px;background:var(--brand);color:#fff;font-weight:600}
.btn:disabled{opacity:.6;cursor:default}
.btn--ghost{padding:7px 16px;background:transparent;color:var(--brand);border:1px solid var(--brand)}
.linkbtn{border:0;background:none;color:inherit;text-decoration:underline;padding:4px 6px;font-size:13px}
.danger{color:#b3261e}
.error{margin:0;color:#b3261e;font-size:14px;font-weight:600}

/* ---------- sign in ---------- */
.login{min-height:100%;display:grid;place-items:center;padding:24px}
.login__card{width:100%;max-width:360px;display:grid;gap:14px;padding:32px;background:#fff;border-radius:16px;box-shadow:0 18px 50px rgba(0,0,0,.1)}
.login__logo{width:56px;height:56px;border-radius:50%;justify-self:center}
.login h1{margin:0;text-align:center;font-size:20px}
label{display:grid;gap:5px;font-size:13px;font-weight:600}
input,textarea{width:100%;font:inherit;color:inherit;padding:10px 12px;border:1px solid #d6d6d6;border-radius:10px;background:#fff}
input:focus,textarea:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px rgba(128,0,32,.14)}

/* ---------- app shell ---------- */
.app{height:100%;display:flex;flex-direction:column}
.bar{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 18px;background:var(--brand);color:#fff}
.bar__brand{display:flex;align-items:center;gap:10px;font-weight:600;min-width:0}
.bar__brand img{width:32px;height:32px;border-radius:50%;background:#fff}
.bar__right{display:flex;align-items:center;gap:14px;flex-wrap:wrap;justify-content:flex-end;font-size:13px}
.switch{display:flex;align-items:center;gap:6px;font-size:13px;cursor:pointer}
.switch input{width:auto;accent-color:#4ade80}

.cols{flex:1;min-height:0;display:grid;grid-template-columns:330px 1fr}

/* ---------- conversation list ---------- */
.list{min-height:0;display:flex;flex-direction:column;background:#fff;border-right:1px solid var(--line)}
.tabs{display:flex;border-bottom:1px solid var(--line)}
.tabs button{flex:1;padding:12px;border:0;border-bottom:2px solid transparent;background:none;color:var(--muted);font-weight:600}
.tabs button[aria-selected="true"]{color:var(--brand);border-bottom-color:var(--brand)}
.count{display:inline-block;min-width:20px;margin-left:4px;padding:0 6px;border-radius:10px;background:var(--brand);color:#fff;font-size:12px}
.count:empty{display:none}
#convList{flex:1;overflow-y:auto;list-style:none;margin:0;padding:0}
/* minmax(0,1fr): without it the grid column grows to fit the one-line preview
   instead of cutting it off with an ellipsis, and the list scrolls sideways. */
.conv{width:100%;display:grid;grid-template-columns:minmax(0,1fr);gap:4px;padding:12px 16px;border:0;border-bottom:1px solid var(--line);background:none;text-align:left}
.conv:hover{background:#faf6f7}
.conv.is-current{background:#f6ecef}
.conv__top,.conv__bottom{display:flex;align-items:center;justify-content:space-between;gap:10px}
.conv__name{min-width:0;display:flex;align-items:center;gap:6px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.conv.is-unread .conv__name{color:var(--brand)}
.conv__time{flex:0 0 auto;font-size:12px;color:var(--muted)}
.conv__snippet{min-width:0;font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pill{flex:0 0 auto;min-width:20px;padding:0 6px;border-radius:10px;background:var(--brand);color:#fff;font-size:12px;font-weight:700;text-align:center}
.tag{justify-self:start;padding:1px 7px;border-radius:6px;background:#fff4d6;color:#7a4f00;font-size:11px;font-weight:600}
.dot{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:#22c55e}
.empty{margin:0;padding:24px 16px;color:var(--muted);font-size:14px}

/* ---------- thread ---------- */
.thread{min-width:0;min-height:0;display:flex;flex-direction:column}
.thread__empty{margin:auto;padding:24px;text-align:center;color:var(--muted)}
.thread__empty p{margin:4px 0}
.thread__view{flex:1;min-height:0;display:flex;flex-direction:column}
.thread__head{display:flex;align-items:flex-start;gap:14px;padding:14px 20px;background:#fff;border-bottom:1px solid var(--line)}
.thread__who{flex:1;min-width:0}
.thread__who h2{margin:0;font-size:18px}
.meta{display:flex;flex-wrap:wrap;gap:2px 14px;margin:4px 0 0;font-size:13px;color:var(--muted)}
.status{margin:4px 0 0;font-size:12px;font-weight:600;color:var(--muted)}
.status.is-here{color:#15803d}
.status.is-here,.status.is-away{display:flex;align-items:center;gap:6px}
.status.is-here::before,.status.is-away::before{content:"";flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:#9ca3af}
.status.is-here::before{background:#22c55e}
.thread__actions{display:flex;align-items:center;gap:8px}
.back{display:none}
.msgs{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:20px}
.msg{max-width:70%;display:grid;gap:2px;padding:10px 14px;border-radius:14px}
.msg__who{font-size:11.5px;font-weight:700;color:var(--muted)}
.msg__body{white-space:pre-wrap;overflow-wrap:anywhere}
.msg__time{font-size:11px;color:var(--muted)}
.msg--visitor{align-self:flex-start;background:#fff;border:1px solid var(--line);border-bottom-left-radius:4px}
.msg--staff{align-self:flex-end;background:var(--brand);color:#fff;border-bottom-right-radius:4px}
.msg--staff .msg__who,.msg--staff .msg__time{color:rgba(255,255,255,.82)}
.msg--bot{align-self:flex-end;background:#f8eef1;border:1px dashed #dbb7c2;border-bottom-right-radius:4px}
.msg--bot .msg__who{color:var(--brand)}
.msg--system{align-self:center;padding:2px;background:none;color:var(--muted);font-size:13px;text-align:center}
.msg--system .msg__time{display:none}
.reply{display:flex;align-items:flex-end;gap:10px;padding:12px 16px;background:#fff;border-top:1px solid var(--line)}
.reply textarea{resize:none;min-height:48px;max-height:160px}
.reply__err{padding:0 16px 10px;background:#fff}

/* ---------- phones: list first, then the chat full-screen ---------- */
@media (max-width:800px){
  .cols{grid-template-columns:1fr}
  .thread{display:none}
  .cols.show-thread .list{display:none}
  .cols.show-thread .thread{display:flex}
  .back{display:inline-block}
  .thread__head{flex-wrap:wrap;gap:6px 14px;padding:10px 16px}
  .thread__who{flex:1 1 100%}               /* visitor details get the full width... */
  .thread__actions{width:100%}              /* ...with the buttons on their own row */
  .msg{max-width:88%}
  .bar{flex-wrap:wrap}
  .me{display:none}
}
