/* Messages as a chat (dashboard/chatApp.js, 6 Nov).
   WhatsApp's shape in DelPod's colours: teal and black, never WhatsApp
   green. A list of chats, and a conversation with bubbles, ticks and day
   chips. Below 600 px each is full screen; wider, side by side. */
.chat-envelope { width: 44px; height: 44px; }
.chat-envelope svg { width: 20px; height: 20px; }

.chat-app {
  --chat-own: #d9f2f0;            /* light teal: the office's own bubbles */
  --chat-other: #ffffff;
  --chat-ink: #0f172a;
  --chat-muted: #64748b;
  --chat-tick-seen: #0e9a94;
  --chat-bg: #eef3f2;
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.45);
}
.chat-app[hidden] { display: none; }
.chat-shell {
  display: flex;
  width: min(1100px, calc(100vw - 48px));
  height: min(820px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.04);
}
.chat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 22px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.chat-icon-btn:hover { background: rgba(15, 23, 42, 0.06); }
.chat-icon-btn svg { width: 22px; height: 22px; }

.chat-avatar.has-logo { background: #fff; }
.chat-avatar-logo { width: 100%; height: 100%; object-fit: contain; }

/* ---- the list ---- */
.chat-list-pane {
  display: flex;
  flex-direction: column;
  flex: none;
  width: 340px;
  min-width: 0;
  border-right: 1px solid #e2e8f0;
}
.chat-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 8px 8px 8px 16px;
  background: #0b0b0b;
  color: #fff;
}
.chat-list-head .chat-icon-btn:hover, .chat-head .chat-icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.chat-list-title { margin: 0; font-size: 18px; font-weight: 700; }
.chat-rows { flex: 1; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  color: var(--chat-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.chat-row:hover { background: #f8fafc; }
.chat-row.is-open { background: #e9f7f6; }
.chat-row.is-pinned { border-bottom-color: #e2e8f0; }
.chat-row-mid { flex: 1; min-width: 0; }
.chat-row-top, .chat-row-bottom { display: flex; align-items: center; gap: 8px; }
.chat-row-title { flex: 1; min-width: 0; overflow: hidden; font-size: 15px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.chat-row-time { flex: none; font-size: 12px; color: var(--chat-muted); }
.chat-row-preview { flex: 1; min-width: 0; overflow: hidden; margin-top: 2px; font-size: 13px; color: var(--chat-muted); white-space: nowrap; text-overflow: ellipsis; }
.chat-row-unread {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #5ed6d1;
  color: #000;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.chat-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 22px;
  background: #0b0b0b;
  color: #5ed6d1;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.02em;
}
.chat-head .chat-avatar { background: #1f2937; }
.chat-avatar.is-group { background: #5ed6d1; color: #000; }
.chat-avatar svg { width: 24px; height: 24px; }

/* ---- the conversation ---- */
.chat-pane { position: relative; display: flex; flex-direction: column; flex: 1; min-width: 0; background: var(--chat-bg); }
.chat-pane.is-empty > :not(.chat-placeholder) { display: none; }
.chat-pane:not(.is-empty) > .chat-placeholder { display: none; }
.chat-placeholder { margin: auto; color: var(--chat-muted); font-size: 15px; }
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 8px;
  background: #0b0b0b;
  color: #fff;
}
.chat-head .chat-back { display: none; }
.chat-head-text { flex: 1; min-width: 0; }
.chat-title { margin: 0; overflow: hidden; font-size: 16px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.chat-subtitle { margin: 1px 0 0; overflow: hidden; font-size: 12px; color: #9fb3b1; white-space: nowrap; text-overflow: ellipsis; }

/* A faint pattern, like WhatsApp's: parcels, pins and a van-box outline in
   teal, low enough that a bubble always reads first. */
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 4% 16px;
  background-color: var(--chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%230e9a94' stroke-opacity='0.11' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='12' y='14' width='22' height='18' rx='2'/%3E%3Cpath d='M12 20h22M23 14v18'/%3E%3Cpath d='M82 18c0 8-8 14-8 14s-8-6-8-14a8 8 0 0 1 16 0z'/%3E%3Ccircle cx='74' cy='18' r='2.5'/%3E%3Cpath d='M30 78l10-6 10 6v12l-10 6-10-6z'/%3E%3Cpath d='M86 74h16v14H86zM90 74v-4h8v4'/%3E%3Ccircle cx='58' cy='52' r='2'/%3E%3Ccircle cx='104' cy='108' r='2'/%3E%3Ccircle cx='14' cy='104' r='2'/%3E%3C/g%3E%3C/svg%3E");
}
.chat-feed { display: flex; flex-direction: column; gap: 3px; }
/* An empty chat: the pattern, and one chip that says so. */
.chat-day.chat-none { margin-top: 24px; font-size: 14px; font-weight: 500; }
.chat-day {
  align-self: center;
  margin: 10px 0 6px;
  padding: 4px 12px;
  border-radius: 8px;
  background: #fff;
  color: var(--chat-muted);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
}
.chat-unread-divider {
  align-self: stretch;
  margin: 8px 0;
  padding: 4px;
  background: rgba(94, 214, 209, 0.25);
  color: #04342c;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.bubble-row { position: relative; display: flex; flex-direction: column; max-width: 100%; margin-top: 4px; }
.bubble-row.own { align-items: flex-end; }
.bubble-row.other { align-items: flex-start; }
.bubble-row.has-pill { margin-bottom: 18px; }
.bubble {
  position: relative;
  max-width: min(78%, 520px);
  min-width: 84px;
  padding: 6px 9px 6px 10px;
  border-radius: 10px;
  color: var(--chat-ink);
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.10);
  overflow-wrap: anywhere;
}
.bubble.own { background: var(--chat-own); border-top-right-radius: 0; }
.bubble.other { background: var(--chat-other); border-top-left-radius: 0; }
/* The tails. */
.bubble.own::after, .bubble.other::after { content: ''; position: absolute; top: 0; width: 10px; height: 12px; }
.bubble.own::after { right: -8px; background: var(--chat-own); clip-path: polygon(0 0, 100% 0, 0 100%); }
.bubble.other::after { left: -8px; background: var(--chat-other); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.bubble.failed { outline: 1px solid #dc2626; }
.bubble-sender { margin: 0 0 2px; font-size: 13px; font-weight: 700; color: #0e7f7a; }
.bubble-stop {
  display: inline-block;
  margin: 0 0 4px;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(4, 52, 44, 0.08);
  color: #04342c;
  font-size: 12px;
  font-weight: 650;
}
.bubble-text { margin: 0; font-size: 14.5px; line-height: 1.4; white-space: pre-wrap; }
.bubble-tag { margin: 3px 0 0; font-size: 11px; font-weight: 700; color: #7c4a10; }
/* Time and ticks: small and grey, bottom right, inside the bubble. */
.bubble-meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -2px 10px; font-size: 11px; color: var(--chat-muted); white-space: nowrap; }
.bubble-tick { font-size: 12px; letter-spacing: -2px; }
.bubble-tick.tick-seen { color: var(--chat-tick-seen); font-weight: 700; }
.bubble-tick.tick-pending { letter-spacing: 0; }
.bubble-tick.tick-failed { color: #dc2626; font-weight: 800; letter-spacing: 0; }
.bubble-failed { margin: 2px 2px 0; font-size: 12px; color: #b91c1c; }
.bubble-photos { display: grid; gap: 3px; margin: 0 -5px 5px; }
.bubble-photos.n2, .bubble-photos.n3, .bubble-photos.n4 { grid-template-columns: 1fr 1fr; }
.bubble-photo { display: block; width: 100%; min-height: 44px; padding: 0; border: none; border-radius: 8px; overflow: hidden; background: #cfe3e1; cursor: zoom-in; }
.bubble-photo img { display: block; width: 100%; max-height: 260px; object-fit: cover; transition: filter 0.25s ease; }
.bubble-photos.n1 .bubble-photo img { min-height: 120px; }
.bubble-photos:not(.n1) .bubble-photo img { aspect-ratio: 1; }
/* Blurred until it has arrived. */
.bubble-photo img.is-loading, .chat-viewer-img.is-loading { filter: blur(14px); }
/* The reaction pill, overlapping the bottom of the bubble. */
.bubble-pill {
  position: absolute;
  bottom: -18px;
  left: 10px;
  min-height: 32px;
  padding: 3px 11px;
  border: 2px solid var(--chat-bg);
  border-radius: 16px;
  background: #fff;
  color: var(--chat-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
  cursor: pointer;
}
/* On the bubble's left edge: its right holds the time and ticks. The pill is
   the visible part of a 44 px target. */
.bubble-pill::before { content: ''; position: absolute; inset: -8px -4px; }

.chat-jump {
  position: absolute;
  right: 18px;
  bottom: 86px;
  z-index: 2;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 22px;
  background: #0b0b0b;
  color: #5ed6d1;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.3);
  cursor: pointer;
}
.chat-jump[hidden] { display: none; }

/* ---- the compose bar, fixed at the bottom ---- */
.chat-compose { flex: none; padding: 6px 10px 10px; background: var(--chat-bg); }
.chat-name-row[hidden], .chat-context[hidden], .chat-photo-strip[hidden], .chat-error[hidden] { display: none; }
.chat-name { box-sizing: border-box; width: 100%; min-height: 44px; margin-bottom: 6px; padding: 0 14px; border: 1px solid #e2e8f0; border-radius: 22px; font: inherit; font-size: 14px; }
.chat-context { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; padding-left: 12px; border-left: 3px solid #5ed6d1; border-radius: 6px; background: rgba(255, 255, 255, 0.9); }
.chat-context-text { flex: 1; min-width: 0; overflow: hidden; font-size: 13px; font-weight: 650; color: #04342c; white-space: nowrap; text-overflow: ellipsis; }
.chat-context-x { width: 44px; height: 44px; border: none; background: transparent; color: var(--chat-muted); font-size: 20px; cursor: pointer; }
.chat-photo-strip { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 6px; padding: 0; list-style: none; }
.chat-photo-thumb { position: relative; width: 64px; height: 64px; }
.chat-photo-thumb img { width: 100%; height: 100%; border-radius: 8px; object-fit: cover; }
.chat-photo-x { position: absolute; top: -10px; right: -10px; width: 30px; height: 30px; padding: 0; border: 2px solid #fff; border-radius: 15px; background: #0b0b0b; color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.chat-photo-x::before { content: ''; position: absolute; inset: -7px; }
.chat-error { margin: 0 4px 6px; font-size: 13px; color: #b91c1c; }
.chat-bar { display: flex; align-items: flex-end; gap: 8px; }
.chat-box {
  display: flex;
  align-items: flex-end;
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding-left: 16px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.10);
}
.chat-text {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 13px 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
}
.chat-clip { margin: 2px; color: var(--chat-muted); }
.chat-clip:disabled { opacity: 0.35; cursor: default; }
.chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 24px;
  background: #5ed6d1;
  color: #000;
  cursor: pointer;
}
.chat-send:hover { filter: brightness(0.95); }
.chat-send svg { width: 22px; height: 22px; margin-left: 2px; }

/* ---- the 👍 sheet, rising from the bottom ---- */
.chat-sheet { position: absolute; inset: 0; z-index: 3; display: flex; align-items: flex-end; background: rgba(2, 6, 23, 0.35); }
.chat-sheet[hidden] { display: none; }
.chat-sheet-card { box-sizing: border-box; width: 100%; max-height: 75%; overflow-y: auto; padding: 8px 16px 18px; border-radius: 14px 14px 0 0; background: #fff; }
.chat-sheet-head { display: flex; align-items: center; justify-content: space-between; }
.chat-sheet-title { margin: 0; font-size: 17px; }
.chat-sheet-section { margin: 12px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--chat-muted); }
.chat-sheet-list { margin: 0; padding: 0; list-style: none; }
.chat-sheet-list li { display: flex; align-items: center; justify-content: space-between; min-height: 44px; border-bottom: 1px solid #f1f5f9; font-size: 15px; }
.chat-sheet-time, .chat-sheet-seen { color: var(--chat-muted); font-size: 13px; }

/* ---- full screen photo ---- */
.chat-viewer { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.92); }
.chat-viewer[hidden] { display: none; }
.chat-viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; transition: filter 0.25s ease; }
.chat-viewer-x { position: absolute; top: 10px; right: 10px; color: #fff; }
.chat-viewer-count { position: absolute; bottom: 16px; left: 0; right: 0; margin: 0; color: #fff; text-align: center; font-size: 14px; }

/* Phone width: one pane at a time, full screen, with the back arrow. */
@media (max-width: 599px) {
  .chat-app { align-items: stretch; background: #fff; }
  .chat-shell { width: 100vw; height: 100%; border-radius: 0; box-shadow: none; }
  .chat-list-pane { width: 100%; border-right: none; }
  .chat-pane { display: none; }
  .chat-app.show-chat .chat-list-pane { display: none; }
  .chat-app.show-chat .chat-pane { display: flex; }
  .chat-head .chat-back { display: inline-flex; }
  .chat-head .chat-close-wide { display: none; }
  .bubble { max-width: 86%; }
  .chat-scroll { padding: 10px 12px 14px; }
}
