/* chat.css — sleek redesign */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:     #f4f6f9;
  --ink:    #0d1b2a;
  --muted:  #64748b;
  --card:   #ffffff;
  --border: #e2e8f0;
  --shadow: 0 4px 20px rgba(2,6,23,.07);
  --green:  #1a7a42;
  --green-2:#22a355;
  --green-bubble: #e8f5ee;
  --green-bubble-border: #b8dfc9;
  --radius: 20px;
  --header-h: 68px;
  --composer-h: 72px;
}

html[data-theme="dark"] {
  --bg:     #0a0f1a;
  --ink:    #e2e8f0;
  --muted:  #8899aa;
  --card:   #111827;
  --border: #1e2d42;
  --shadow: 0 4px 20px rgba(0,0,0,.35);
  --green-bubble: #0d2318;
  --green-bubble-border: #1a4730;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* ── TOP BAR ─────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
  position: relative;
  z-index: 10;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--green);
  font-weight: 800;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 12px;
  transition: background .12s;
  flex-shrink: 0;
}
.back:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }

.who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  justify-content: center;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.who-meta { min-width: 0; }
.who-name {
  display: block;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.who-role { font-size: 12px; color: var(--muted); margin-top: 1px; }

.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.icon-action {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.icon-action:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.muted { color: var(--muted); }

/* ── CHAT AREA ────────────────────────────────────────────── */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 10px;
  scroll-behavior: smooth;
}

.chat-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Date separator */
.date-sep {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 12px 0 4px;
}

/* Message row */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}
.msg.me   { align-self: flex-end; }
.msg.them { align-self: flex-start; }

.bubble {
  padding: 11px 15px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 14.5px;
  word-wrap: break-word;
}

.msg.them .bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--shadow);
}

.msg.me .bubble {
  background: var(--green);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 14px rgba(26,122,66,.25);
}

.meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  padding: 0 4px;
}
.msg.me .meta { text-align: right; }

/* Typing dots */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── COMPOSER ─────────────────────────────────────────────── */
.composer {
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.composer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.composer input {
  flex: 1;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.composer input:focus {
  border-color: color-mix(in srgb, var(--green) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 12%, transparent);
}

.send {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  background: var(--green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(26,122,66,.3);
  transition: background .12s, transform .1s;
}
.send:hover { background: var(--green-2); }
.send:active { transform: scale(0.95); }

/* ── MOBILE ───────────────────────────────────────────────── */
@media (max-width: 520px) {
  .msg { max-width: 88%; }
  .who-name { max-width: 120px; }
  .back span { display: none; }
}