.admin-chat-panel {
  --admin-chat-shell-bg: rgba(18,22,28,0.98);
  --admin-chat-shell-border: var(--line);
  --admin-chat-shell-shadow: 0 22px 50px rgba(0,0,0,0.34);
  --admin-chat-head-bg: linear-gradient(180deg, rgba(85,215,193,0.14), rgba(85,215,193,0.04));
  --admin-chat-head-border: var(--line);
  --admin-chat-customer-border: var(--line);
  --admin-chat-customer-bg: rgba(255,255,255,0.03);
  --admin-chat-customer-active-bg: rgba(85,215,193,0.08);
  --admin-chat-customer-active-border: rgba(85,215,193,0.28);
  --admin-chat-conversation-bg: #151a1f;
  --admin-chat-conversation-border: var(--line);
  --admin-chat-conversation-head-bg: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
  --admin-chat-conversation-head-border: var(--line);
  --admin-chat-title-color: var(--ink);
  --admin-chat-meta-color: var(--muted);
  --admin-chat-thread-bg: rgba(255,255,255,0.03);
  --admin-chat-thread-border: var(--line);
  --admin-chat-thread-active-bg: rgba(85,215,193,0.08);
  --admin-chat-thread-active-border: rgba(85,215,193,0.28);
  --admin-chat-bubble-bg: rgba(85,215,193,0.16);
  --admin-chat-bubble-text: var(--ink);
  --admin-chat-bubble-reply-bg: #1d242b;
  --admin-chat-bubble-reply-text: var(--text);
  --admin-chat-compose-bg: rgba(255,255,255,0.02);
  --admin-chat-compose-border: var(--line);
  --admin-chat-input-bg: #1b2128;
  --admin-chat-input-border: rgba(134,150,160,0.28);
  --admin-chat-input-text: var(--text);
  --admin-chat-input-placeholder: #8696a0;
  --admin-chat-input-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
  --admin-chat-input-focus-border: rgba(85,215,193,0.38);
  --admin-chat-input-focus-ring: 0 0 0 3px rgba(85,215,193,0.12);
  position: fixed;
  right: 22px;
  bottom: 94px;
  width: min(560px, calc(100vw - 28px));
  max-height: min(82vh, 760px);
  border-radius: 20px;
  border: 1px solid var(--admin-chat-shell-border);
  background: var(--admin-chat-shell-bg);
  box-shadow: var(--admin-chat-shell-shadow);
  display: none !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  z-index: 46;
}
.admin-chat-panel.show {
  display: grid !important;
}
.admin-chat-panel.inline {
  position: static;
  right: auto;
  bottom: auto;
  width: 100%;
  height: 100%;
  grid-template-columns: minmax(0, 1fr);
  max-height: none;
  min-height: 100%;
  margin-top: 0;
  box-shadow: none;
  z-index: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.admin-chat-panel.inline .admin-chat-panel-body {
  display: block;
  width: 100%;
}
.admin-chat-panel.inline .admin-chat-inbox {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  width: 100%;
  align-items: stretch;
}
.admin-chat-panel.inline .admin-chat-customer-list {
  border-right: 1px solid var(--admin-chat-customer-border);
  border-bottom: 0;
  padding-right: 10px;
  padding-bottom: 0;
  max-height: none;
  min-height: 0;
}
.admin-chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--admin-chat-head-border);
  background: var(--admin-chat-head-bg);
}
.admin-chat-panel-head h4 {
  margin: 0;
  font-size: 21px;
}
.admin-chat-panel-body {
  padding: 0;
  overflow: hidden;
  display: grid;
  gap: 10px;
  align-content: stretch;
  justify-items: stretch;
  min-height: 0;
  height: 100%;
  width: 100%;
}
.admin-chat-inbox {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  height: 100%;
  width: 100%;
  justify-self: stretch;
  align-self: stretch;
}
.admin-chat-customer-list {
  border-right: 1px solid var(--admin-chat-customer-border);
  padding: 14px 14px 14px 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: 100%;
}
.admin-chat-search-stack {
  display: grid;
  gap: 8px;
}
.admin-chat-search-dropdown {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--admin-chat-thread-border);
  background: var(--admin-chat-thread-bg);
}
.admin-chat-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 4px 0;
}
.admin-chat-customer {
  width: 100%;
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--admin-chat-customer-border);
  background: var(--admin-chat-customer-bg);
  color: var(--text);
  padding: 12px;
  display: grid;
  gap: 4px;
}
.admin-chat-customer.active {
  border-color: var(--admin-chat-customer-active-border);
  background: var(--admin-chat-customer-active-bg);
}
.admin-chat-customer-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}
.admin-chat-customer-status-row,
.admin-chat-conversation-status-row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}
.admin-chat-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.admin-chat-status-badge.pending {
  background: #fff4dc;
  border-color: #f0cc7d;
  color: #8a5a00;
}
.admin-chat-status-badge.closed {
  background: #fbecec;
  border-color: #e7b1b0;
  color: #8a2f2a;
}
.admin-chat-status-badge.conversation {
  min-height: 24px;
  padding: 0 12px;
}
.admin-chat-customer.unread {
  border-color: rgba(209, 106, 104, 0.32);
  box-shadow: inset 0 0 0 1px rgba(209, 106, 104, 0.12);
}
.admin-chat-conversation {
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
  border: 1px solid var(--admin-chat-conversation-border);
  border-radius: 18px;
  background: var(--admin-chat-conversation-bg);
  padding: 14px;
}
.admin-chat-conversation-head {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--admin-chat-conversation-head-border);
  background: var(--admin-chat-conversation-head-bg);
}
.admin-chat-conversation-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--admin-chat-title-color);
}
.admin-chat-conversation-body {
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  gap: 2px;
  align-content: start;
  max-height: none;
  min-height: 0;
  padding-right: 0;
}
.admin-chat-thread {
  border-radius: 16px;
  border: 1px solid var(--admin-chat-thread-border);
  background: var(--admin-chat-thread-bg);
  padding: 14px;
  display: grid;
  gap: 8px;
}
.admin-chat-thread.active {
  border-color: var(--admin-chat-thread-active-border);
  background: var(--admin-chat-thread-active-bg);
}
.admin-chat-bubble {
  border-radius: 8px;
  border: 0;
  background: rgba(255,255,255,0.04);
  padding: 5px 7px 3px;
  font-size: 15.5px;
  line-height: 1.24;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: grid;
  gap: 0;
  box-shadow: 0 1px 0 rgba(15,23,32,0.04);
}
.admin-chat-bubble.reply {
  background: var(--admin-chat-bubble-reply-bg);
  color: var(--admin-chat-bubble-reply-text);
}
.admin-chat-conversation .admin-chat-meta {
  color: var(--admin-chat-meta-color);
}
.admin-chat-conversation .admin-chat-bubble {
  width: fit-content;
  max-width: min(58%, 460px);
  justify-self: end;
  background: var(--admin-chat-bubble-bg);
  color: var(--admin-chat-bubble-text);
  border-radius: 8px 8px 2px 8px;
}
.admin-chat-conversation .admin-chat-bubble.reply {
  justify-self: start;
  background: var(--admin-chat-bubble-reply-bg);
  color: var(--admin-chat-bubble-reply-text);
  border-radius: 8px 8px 8px 2px;
}
.admin-chat-meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 1px;
  line-height: 1.15;
}
.admin-chat-bubble-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.admin-chat-bubble-time {
  justify-self: end;
  font-size: 10px;
  line-height: 1;
  color: #8696a0;
  margin-top: 0;
}
.admin-chat-panel-compose {
  border-top: 1px solid var(--admin-chat-compose-border);
  padding: 12px 0 0;
  display: grid;
  gap: 10px;
  background: var(--admin-chat-compose-bg);
}
.admin-chat-panel-compose.hidden {
  display: none;
}
.admin-chat-panel-compose textarea {
  font-size: 15px;
  line-height: 1.55;
  min-height: 92px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--admin-chat-input-bg);
  color: var(--admin-chat-input-text);
  border: 1px solid var(--admin-chat-input-border);
  resize: vertical;
  outline: none;
  box-shadow: var(--admin-chat-input-shadow);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.admin-chat-panel-compose textarea::placeholder,
.admin-chat-page-compose textarea::placeholder {
  color: var(--admin-chat-input-placeholder);
}
.admin-chat-panel-compose textarea:focus,
.admin-chat-page-compose textarea:focus {
  border-color: var(--admin-chat-input-focus-border);
  box-shadow: var(--admin-chat-input-shadow), var(--admin-chat-input-focus-ring);
}
.admin-message-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.admin-message-status-btn {
  min-width: 96px;
}
.admin-message-status-btn.active {
  background: #0d3b66;
  color: #fff;
  border-color: #0d3b66;
}
.admin-chat-status-banner {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.45;
  border: 1px solid #dbe4ee;
}
.admin-chat-status-banner.pending {
  background: #fff8ea;
  border-color: #f3d49a;
  color: #8a5a00;
}
.admin-chat-status-banner.closed {
  background: #fbecec;
  border-color: #e8b7b6;
  color: #8a2f2a;
}
.messages-view-grid {
  height: 100%;
}
.messages-view-card {
  height: min(calc(100dvh - 138px), 820px);
  min-height: 520px;
  padding: 0 18px 18px;
  overflow: hidden;
  display: grid;
}
.admin-messages-host {
  min-height: 0;
  height: 100%;
  display: grid;
}
.admin-chat-panel.message-page {
  background: var(--admin-chat-shell-bg);
  height: min(calc(100dvh - 170px), 640px);
  min-height: 360px;
  overflow: hidden;
}
.admin-chat-panel-body-focus {
  padding: 0;
  overflow: hidden;
  min-height: 0;
}
.admin-chat-page {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: 0 0 20px 20px;
  background: var(--admin-chat-conversation-bg);
  color: var(--admin-chat-input-text);
}
.admin-chat-page-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--admin-chat-conversation-head-border);
  background: var(--admin-chat-conversation-head-bg);
  display: grid;
  gap: 6px;
}
.admin-chat-page-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-chat-page-back {
  width: auto;
  min-width: 0;
  padding: 8px 12px;
}
.admin-chat-page-state {
  font-size: 12px;
  color: var(--admin-chat-meta-color);
  line-height: 1.4;
}
.admin-chat-page-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--admin-chat-title-color);
}
.admin-chat-page-meta {
  font-size: 12px;
  color: var(--admin-chat-meta-color);
  line-height: 1.4;
}
.admin-chat-page-body {
  overflow-y: auto;
  min-height: 0;
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px 16px;
  background: var(--admin-chat-conversation-bg);
}
.admin-chat-page .admin-chat-meta {
  color: var(--admin-chat-meta-color);
}
.admin-chat-page .admin-chat-bubble {
  background: var(--admin-chat-bubble-reply-bg);
  border-color: var(--admin-chat-thread-border);
  color: var(--admin-chat-bubble-reply-text);
  padding: 10px 11px;
  font-size: 14px;
  line-height: 1.45;
}
.admin-chat-page .admin-chat-bubble.reply {
  background: var(--admin-chat-bubble-bg);
  border-color: var(--admin-chat-customer-active-border);
  color: var(--admin-chat-bubble-text);
}
.admin-chat-page-compose {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--admin-chat-compose-border);
  background: var(--admin-chat-compose-bg);
  display: grid;
  gap: 8px;
}
.admin-chat-page-compose label {
  margin-top: 0;
}
.admin-chat-page-compose textarea {
  min-height: 86px;
  max-height: 120px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--admin-chat-input-bg);
  color: var(--admin-chat-input-text);
  border: 1px solid var(--admin-chat-input-border);
  resize: vertical;
  outline: none;
  box-shadow: var(--admin-chat-input-shadow);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

body.light-theme .admin-chat-panel {
  --admin-chat-shell-bg: #f3f6fb;
  --admin-chat-shell-border: #dbe4ee;
  --admin-chat-shell-shadow: 0 20px 42px rgba(31, 60, 92, 0.18);
  --admin-chat-head-bg: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  --admin-chat-head-border: #dde5ee;
  --admin-chat-customer-border: var(--line);
  --admin-chat-customer-bg: rgba(255,255,255,0.85);
  --admin-chat-customer-active-bg: rgba(85,215,193,0.08);
  --admin-chat-customer-active-border: rgba(85,215,193,0.28);
  --admin-chat-conversation-bg: #ffffff;
  --admin-chat-conversation-border: #dbe4ee;
  --admin-chat-conversation-head-bg: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  --admin-chat-conversation-head-border: #dde5ee;
  --admin-chat-title-color: #0f1720;
  --admin-chat-meta-color: #607083;
  --admin-chat-thread-bg: rgba(255,255,255,0.78);
  --admin-chat-thread-border: #dbe4ee;
  --admin-chat-thread-active-bg: rgba(85,215,193,0.08);
  --admin-chat-thread-active-border: rgba(85,215,193,0.28);
  --admin-chat-bubble-bg: #d9fdd3;
  --admin-chat-bubble-text: #14212f;
  --admin-chat-bubble-reply-bg: #f6f8fb;
  --admin-chat-bubble-reply-text: #14212f;
  --admin-chat-compose-bg: #fbfcfe;
  --admin-chat-compose-border: #dde5ee;
  --admin-chat-input-bg: linear-gradient(180deg, #fdfefe 0%, #f4f8fc 100%);
  --admin-chat-input-border: #d6e0ea;
  --admin-chat-input-text: #14212f;
  --admin-chat-input-placeholder: #7b8897;
  --admin-chat-input-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
  --admin-chat-input-focus-border: rgba(13,59,102,0.28);
  --admin-chat-input-focus-ring: 0 0 0 3px rgba(13,59,102,0.08);
}

@media (max-width: 980px) {
  .admin-chat-panel.inline {
    min-height: 0;
    height: auto;
  }
  .admin-chat-panel.inline .admin-chat-inbox {
    grid-template-columns: 1fr;
    height: auto;
  }
  .admin-chat-panel.inline .admin-chat-customer-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 10px;
    max-height: 280px;
  }
  .admin-chat-conversation {
    min-height: 420px;
    padding: 12px;
  }
  .admin-chat-panel-body {
    overflow: auto;
  }
  .admin-chat-panel.message-page {
    height: calc(100dvh - 138px);
    min-height: 300px;
  }
  .admin-chat-page {
    border-radius: 0 0 16px 16px;
  }
  .admin-chat-page-head {
    padding: 12px 12px 10px;
    gap: 5px;
  }
  .admin-chat-page-toolbar {
    gap: 8px;
  }
  .admin-chat-page-title {
    font-size: 16px;
  }
  .admin-chat-page-meta,
  .admin-chat-page-state {
    font-size: 11px;
  }
  .admin-chat-page-body {
    padding: 10px 12px;
    gap: 8px;
  }
  .admin-chat-page .admin-chat-bubble {
    padding: 9px 10px;
    font-size: 13px;
  }
  .admin-chat-page-compose {
    padding: 10px 12px 12px;
  }
  .admin-chat-page-compose textarea {
    min-height: 72px;
    max-height: 92px;
  }
}
