/* ── ORDER THREAD ──
   The conversation on an order. Shared by the account page and the admin
   panel, so nothing in here assumes which one it's inside.
*/

/* ── Status badges ────────────────────────────────────────── */

.work-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.work-new  { border: 1px solid rgba(77,124,255,0.45); background: rgba(77,124,255,0.1);  color: #9db3ff; }
.work-prog { border: 1px solid rgba(245,181,74,0.45); background: rgba(245,181,74,0.1);  color: var(--warn); }
.work-done { border: 1px solid rgba(47,209,138,0.45); background: rgba(47,209,138,0.1);  color: var(--ok); }

/* ── Thread ───────────────────────────────────────────────── */

.thread {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--edge-hi);
  border-radius: var(--r-lg);
  background: var(--slab);
  overflow: hidden;
}

.thread-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--edge);
}
.thread-title { font-size: 15px; font-weight: 500; }
.thread-sub { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 2px; }
.thread-status { margin-left: auto; }

.thread-controls {
  display: flex;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--edge);
  background: rgba(0,0,0,0.18);
}
.thread-controls .btn { height: 32px; padding: 0 13px; font-size: 12px; }
.thread-controls .btn.on {
  border-color: rgba(255,90,45,0.5);
  background: rgba(255,90,45,0.12);
  color: var(--ember-hi);
}

.thread-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 220px;
  max-height: 460px;
  padding: 20px;
  overflow-y: auto;
}

.thread-loading {
  margin: auto;
  color: var(--dim);
  font-size: 14px;
  text-align: center;
}

/* ── Messages ─────────────────────────────────────────────── */

.msg {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: var(--r);
  font-size: 14px;
}

/* The customer's own messages sit right in their view and left in yours,
   which is why the class is on the sender rather than "mine/theirs" — the
   page that mounts this decides which side it's reading from. */
.msg-user {
  align-self: flex-end;
  border: 1px solid rgba(255,90,45,0.28);
  background: rgba(255,90,45,0.09);
}
.msg-admin {
  align-self: flex-start;
  border: 1px solid var(--edge);
  background: var(--slab-hi);
}

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.msg-time { font-family: var(--mono); font-size: 10px; color: var(--dim); }

.msg-tag {
  padding: 1px 7px;
  border: 1px solid rgba(255,90,45,0.4);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--ember-hi);
}
.msg-body { white-space: pre-wrap; word-break: break-word; }

.msg-system {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  color: var(--dim);
  text-align: center;
}

.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  padding: 10px 12px;
  border: 1px solid var(--edge-hi);
  border-radius: var(--r-sm);
  background: rgba(0,0,0,0.28);
  transition: border-color 0.18s var(--ease);
}
.msg-file:hover { border-color: var(--ember); }
.msg-file-name { flex: 1; font-size: 13px; word-break: break-all; }
.msg-file-size { font-family: var(--mono); font-size: 11px; color: var(--dim); }

/* ── Compose ──────────────────────────────────────────────── */

.thread-compose {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--edge);
  background: rgba(0,0,0,0.18);
}
.thread-compose .input { min-height: 42px; resize: none; }
.thread-actions { display: flex; gap: 8px; flex: none; }

.thread-closed {
  padding: 16px 20px;
  border-top: 1px solid var(--edge);
  background: rgba(0,0,0,0.18);
  font-size: 13px;
  color: var(--dim);
  text-align: center;
}

.thread + .field-error { margin-top: 10px; }

/* ── Unread marker ────────────────────────────────────────── */

.unread-dot {
  display: inline-block;
  width: 7px; height: 7px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember);
  vertical-align: middle;
}

@media (max-width: 620px) {
  .msg { max-width: 92%; }
  .thread-body { padding: 14px; max-height: 60vh; }
  .thread-compose { padding: 12px 14px; flex-wrap: wrap; }
  .thread-actions { width: 100%; justify-content: flex-end; }
}
