:root {
  --wa-teal: #008069;
  --wa-teal-deep: #005c4b;
  --wa-panel: #ffffff;
  --wa-bg: #f0f2f5;
  --wa-chat-bg: #efeae2;
  --wa-in: #ffffff;
  --wa-out: #d9fdd3;
  --wa-text: #111b21;
  --wa-muted: #667781;
  --wa-line: #e9edef;
  --wa-hover: #f5f6f6;
  --wa-active: #f0f2f5;
  --wa-tick: #53bdeb;
  --wa-tick-gray: #8696a0;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  color: var(--wa-text);
  background: #0b141a;
}

.wa-app {
  display: grid;
  grid-template-columns: 220px minmax(280px, 360px) 1fr;
  height: 100vh;
  max-width: 1680px;
  margin: 0 auto;
  background: var(--wa-bg);
  overflow: hidden;
}

/* ── Channels rail ─────────────────────────── */
.wa-channels {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #fff;
  border-right: 1px solid var(--wa-line);
}
.wa-channels-head {
  padding: 14px 14px 8px;
  border-bottom: 1px solid var(--wa-line);
}
.wa-channels-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--wa-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.wa-channel-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0;
}
.wa-channel,
.wa-channel-all {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--wa-text);
}
.wa-channel:hover,
.wa-channel-all:hover { background: var(--wa-hover); }
.wa-channel.active,
.wa-channel-all.active { background: var(--wa-active); }
.wa-channel-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #25d366;
  color: #fff;
}
.wa-channel-icon.ig { background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af); }
.wa-channel-icon.wapi { background: #128c7e; }
.wa-channel-icon.blocked { opacity: 0.45; }
.wa-channel-icon.all { background: #54656f; }
.wa-channel-body { min-width: 0; flex: 1; }
.wa-channel-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
}
.wa-channel-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-channel-time {
  font-size: 11px;
  color: var(--wa-muted);
  flex-shrink: 0;
}
.wa-channel-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--wa-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-channel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ea4335;
  flex-shrink: 0;
}
.wa-channel-all {
  border-top: 1px solid var(--wa-line);
  margin-top: auto;
}

/* ── Sidebar ───────────────────────────────── */
.wa-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--wa-panel);
  border-right: 1px solid var(--wa-line);
}

.wa-side-head {
  background: var(--wa-bg);
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--wa-line);
}
.wa-side-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.wa-side-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.wa-side-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.wa-live {
  font-size: 10px;
  color: #8696a0;
  line-height: 1;
}
.wa-live.on { color: #25d366; }

.wa-icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--wa-muted);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wa-icon-btn:hover { background: rgba(0,0,0,.06); color: var(--wa-text); }

.wa-search input {
  width: 100%;
  border: 0;
  outline: none;
  background: #fff;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--wa-text);
  box-shadow: inset 0 0 0 1px transparent;
}
.wa-search input::placeholder { color: #8696a0; }
.wa-search input:focus { box-shadow: inset 0 0 0 1px #25d36655; }

.wa-chat-list {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

.wa-chat {
  width: 100%;
  display: grid;
  grid-template-columns: 49px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--wa-line);
  background: #fff;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.wa-chat:hover { background: var(--wa-hover); }
.wa-chat.active { background: var(--wa-active); }

.wa-avatar {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  background: #dfe5e7;
  color: #54656f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}
.wa-avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.wa-avatar.teal { background: #00a884; color: #fff; }

.wa-chat-body { min-width: 0; }
.wa-chat-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.wa-chat-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-chat-time {
  font-size: 12px;
  color: var(--wa-muted);
  flex-shrink: 0;
}
.wa-chat-preview {
  margin-top: 3px;
  font-size: 13px;
  color: var(--wa-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.wa-chat-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}
.wa-chat.has-unread .wa-chat-name { font-weight: 700; }
.wa-chat.has-unread .wa-chat-preview { color: #111b21; font-weight: 600; }
.wa-unread {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wa-chat-readers {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  min-height: 18px;
}
.wa-chat-readers.muted {
  font-size: 11px;
  color: #8696a0;
}
.wa-mini-av {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #00a884;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wa-mini-more {
  font-size: 11px;
  color: #667781;
}
.wa-viewer-chip {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  color: #008069;
  background: #e7f8f0;
  border-radius: 999px;
  padding: 3px 8px;
}
.wa-viewer-chip.warn {
  color: #a16207;
  background: #fef3c7;
}
.wa-thread-readers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.wa-reader-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #54656f;
  background: #e9edef;
  border-radius: 999px;
  padding: 2px 8px;
}
.wa-readers-none {
  font-size: 11px;
  color: #8696a0;
}
.wa-read-by {
  margin-top: 4px;
  font-size: 11px;
  color: #667781;
  line-height: 1.3;
}
.wa-bubble-row.out .wa-read-by { color: #54656f; }

/* ── Main / thread ─────────────────────────── */
.wa-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--wa-chat-bg);
}

.wa-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, #f0f2f5 0%, #e9edef 100%);
  border-bottom: 6px solid #25d366;
}
.wa-empty-card {
  text-align: center;
  max-width: 420px;
  padding: 24px;
}
.wa-empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
.wa-empty h2 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 300;
  color: #41525d;
}
.wa-empty p {
  margin: 0;
  color: #667781;
  font-size: 14px;
  line-height: 1.5;
}

.wa-thread {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.wa-thread.hidden, .hidden { display: none !important; }

.wa-thread-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--wa-bg);
  border-bottom: 1px solid var(--wa-line);
  z-index: 2;
}
.wa-back { display: none; font-size: 28px; line-height: 1; }
.wa-thread-meta { min-width: 0; }
.wa-thread-meta h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-thread-meta p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--wa-muted);
}

.wa-feed {
  flex: 1;
  overflow-y: auto;
  padding: 18px 8% 28px;
  background-color: #efeae2;
  background-image:
    radial-gradient(rgba(0,0,0,.03) 1px, transparent 1px);
  background-size: 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wa-day {
  align-self: center;
  margin: 10px 0 14px;
  padding: 6px 12px;
  border-radius: 8px;
  background: #ffffffd9;
  color: #54656f;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
}

.wa-bubble-row {
  display: flex;
  margin: 1px 0;
}
.wa-bubble-row.in { justify-content: flex-start; }
.wa-bubble-row.out { justify-content: flex-end; }

.wa-bubble {
  max-width: min(65%, 560px);
  padding: 6px 8px 4px 9px;
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
  position: relative;
}
.wa-bubble-row.in .wa-bubble {
  background: var(--wa-in);
  border-top-left-radius: 0;
}
.wa-bubble-row.out .wa-bubble {
  background: var(--wa-out);
  border-top-right-radius: 0;
}

.wa-bubble-author {
  font-size: 12px;
  font-weight: 700;
  color: #02a698;
  margin-bottom: 2px;
}
.wa-bubble-text {
  font-size: 14.2px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--wa-text);
}
.wa-bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  margin-left: 12px;
  float: right;
}
.wa-bubble-time {
  font-size: 11px;
  color: #667781;
}
.wa-ticks {
  font-size: 14px;
  line-height: 1;
  color: var(--wa-tick-gray);
  letter-spacing: -2px;
}
.wa-ticks.read { color: var(--wa-tick); }
.wa-ticks.error { color: #ea4335; }

.wa-quote {
  border-left: 4px solid #06cf9c;
  background: rgba(0,0,0,.04);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--wa-muted);
}
.wa-media {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #027eb5;
  text-decoration: none;
  word-break: break-all;
}
.wa-img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 6px;
  margin: 2px 0 4px;
  object-fit: cover;
}

.wa-feed-empty {
  margin: auto;
  text-align: center;
  color: var(--wa-muted);
  font-size: 14px;
  background: #ffffffd0;
  padding: 10px 16px;
  border-radius: 8px;
}

@media (max-width: 1100px) {
  .wa-app { grid-template-columns: 190px minmax(260px, 320px) 1fr; }
}

@media (max-width: 860px) {
  .wa-app { grid-template-columns: 1fr; }
  .wa-channels.hidden-mobile { display: none; }
  .wa-sidebar.hidden-mobile { display: none; }
  .wa-main.hidden-mobile { display: none; }
  .wa-back { display: inline-flex; }
  .wa-feed { padding: 14px 4% 22px; }
  .wa-bubble { max-width: 88%; }
}
