/* contact-admin.html — the owner's reply inbox for contact.html's chat
   (js/contact-admin.js, functions/admin/contact.js). Loads after
   contact-v2.css and reuses its frame: .chat-layout / .chat-panel /
   .chat-bar / .chat-aside / .chat-stats, bubbles and the composer. Here
   the member's message is the grey "them" bubble and the owner's reply
   the white "me" bubble, mirrored from what the member sees. */

/* ---- Toolbar (filter + branch tabs) ------------------------------------ */
.clog-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--h-line);
}
.clog-tab-pending { --tc: var(--h-yellow); }
.clog-tab-done { --tc: var(--h-lime); }

/* ---- List -------------------------------------------------------------- */
.clog-list {
  display: flex; flex-direction: column;
  min-height: 320px;
}
.clog-list > .chat-empty { padding: 60px 20px; }

.clog-card {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--h-line);
  transition: background .25s;
}
.clog-card:last-child { border-bottom: 0; }
.clog-card:hover, .clog-card:focus-within { background: rgba(255, 255, 255, .018); }
/* Status stripe on the left edge: yellow = waiting, lime = answered. */
.clog-card::before {
  content: ""; position: absolute; left: 0; top: 18px; bottom: 16px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--h-yellow);
}
.clog-card.is-answered::before { background: var(--h-lime); opacity: .55; }

.clog-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.clog-who {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 50%;
  background: #1c1c1c; border: 1px solid var(--h-line); color: var(--h-fg);
  font: 800 12px 'Inter', 'Anuphan', sans-serif;
}
.clog-name { font: 700 14.5px 'Anuphan', sans-serif; color: var(--h-fg); }
.clog-id { font: 500 11px 'JetBrains Mono', monospace; color: #6b6b6b; }
.clog-time { margin-left: auto; font: 500 11px 'JetBrains Mono', monospace; color: #737373; }

.clog-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font: 700 11px 'Anuphan', sans-serif; white-space: nowrap;
  color: var(--h-yellow); background: rgba(234, 179, 8, .12);
}
.clog-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: chat-pulse 1.6s ease-in-out infinite; }
.clog-card.is-answered .clog-badge { color: var(--h-lime); background: rgba(190, 242, 100, .1); }
.clog-card.is-answered .clog-badge::before { animation: none; }

/* The member's bubble sits flush left under the name, the reply flush right. */
.clog-card .chat-row { max-width: min(86%, 44rem); }
.clog-card .chat-row.them { margin-left: 40px; }

/* ---- Reply composer (contact-v2.css .chat-composer, a size smaller) ---- */
.clog-card .chat-composer {
  display: flex; align-items: flex-end; gap: 10px;
  margin: 2px 0 0 40px;
  padding: 6px 6px 6px 14px;
  border-radius: 20px;
}
.clog-card .chat-input { flex: 1; min-width: 0; font-size: 14px; max-height: 160px; }
.clog-card .chat-send { width: 36px; height: 36px; flex: 0 0 auto; }
.clog-card .chat-composer.has-text .chat-send:not(:disabled) { box-shadow: 0 0 0 4px rgba(250, 250, 250, .08), 0 0 18px rgba(250, 250, 250, .18); }
/* Answered cards keep the composer folded until you go to edit. */
.clog-card.is-answered .chat-composer:not(:focus-within):not(.has-text) { opacity: .55; }
.clog-card.is-answered .chat-composer { transition: border-color .2s, box-shadow .2s, opacity .2s; }

/* ---- Aside ------------------------------------------------------------- */
.contact-admin-page .chat-stats div + div b { color: var(--h-lime); }
.contact-admin-page .chat-stats .clog-stat-pending b { color: var(--h-yellow); }

/* Fresh rows rise in once per load (js/contact-admin.js adds .is-new). */
.clog-card.is-new { transition: opacity .35s ease, translate .45s cubic-bezier(.23, 1, .32, 1), background .25s; }
@starting-style {
  .clog-card.is-new { opacity: 0; translate: 0 10px; }
}

@media (max-width: 680px) {
  .clog-toolbar { padding: 12px; }
  .clog-card { padding: 16px 14px 14px; }
  .clog-card .chat-row.them, .clog-card .chat-composer { margin-left: 0; }
  .clog-card .chat-row { max-width: 94%; }
  .clog-time { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .clog-badge::before { animation: none; }
  .clog-card.is-new, .clog-card { transition: none; }
}

/* "แก้ไข" under a sent reply: copies it back into the composer. */
.clog-edit {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: 600 11px 'Anuphan', sans-serif; color: #d4d4d4;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(250, 250, 250, .3);
  transition: color .2s, text-decoration-color .2s;
}
.clog-edit:hover, .clog-edit:focus-visible { color: var(--h-fg); text-decoration-color: currentColor; }
.clog-edit:focus-visible { outline: 2px solid var(--h-lime); outline-offset: 2px; border-radius: 4px; }

/* "ลบ" in the card head: clears the message from this inbox (two clicks). */
.clog-del {
  padding: 3px 10px; border: 1px solid var(--h-line); border-radius: 999px; background: none; cursor: pointer;
  font: 600 11px 'Anuphan', sans-serif; color: #8a8a8a;
  transition: color .2s, border-color .2s, background .2s;
}
.clog-del:hover, .clog-del:focus-visible, .clog-del.is-armed { color: var(--h-rose); border-color: currentColor; }
.clog-del.is-armed { background: rgba(244, 63, 94, .12); }
.clog-del:focus-visible { outline: 2px solid var(--h-rose); outline-offset: 2px; }
.clog-del:disabled { opacity: .5; cursor: default; }
