/* ==========================================================================
   ADMIN CSKH PORTAL & MAILBOX DASHBOARD STYLES
   VietnamPost Blue & Gold Color Palette
   ========================================================================== */

:root {
  --admin-bg: #f1f5f9;
  --admin-header-bg: #00274d;
  --admin-primary: #003366;
  --admin-accent: #ff9b1f;
  --admin-orange: #ff6600;
  --admin-border: #e2e8f0;
  --admin-text-dark: #1e293b;
  --admin-text-muted: #64748b;
  --admin-white: #ffffff;
  --shadow-card: 0 4px 12px rgba(0, 39, 77, 0.06);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.admin-app-body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--admin-bg);
  color: var(--admin-text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   ADMIN HEADER
   -------------------------------------------------------------------------- */
.admin-header {
  background-color: var(--admin-header-bg);
  color: #ffffff;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-brand-section {
  display: flex;
  align-items: center;
}

.admin-brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  text-decoration: none;
}

.admin-nav-logo {
  height: 40px;
  filter: brightness(0) invert(1);
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-live {
  background-color: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.admin-nav-menu {
  display: flex;
  gap: 8px;
}

.admin-nav-menu .nav-item {
  color: #94a3b8;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.admin-nav-menu .nav-item:hover, .admin-nav-menu .nav-item.active {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
}

.admin-user-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
}

.admin-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: #34d399;
  font-weight: 600;
}

.pulse-green {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.admin-name-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}

.btn-logout {
  color: #f87171;
  font-size: 1.1rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 6px;
  transition: color 0.2s;
}

.btn-logout:hover {
  color: #ef4444;
}

/* --------------------------------------------------------------------------
   DASHBOARD LAYOUT & METRICS
   -------------------------------------------------------------------------- */
.admin-main-container {
  flex: 1;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
}

.dashboard-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.metric-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--admin-border);
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.metric-total .metric-icon { background: #e0f2fe; color: #0284c7; }
.metric-open .metric-icon { background: #fef3c7; color: #d97706; }
.metric-closed .metric-icon { background: #dcfce7; color: #16a34a; }
.metric-unread .metric-icon { background: #fee2e2; color: #dc2626; }

.metric-info {
  display: flex;
  flex-direction: column;
}

.metric-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--admin-text-dark);
  line-height: 1.2;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--admin-text-muted);
}

/* --------------------------------------------------------------------------
   MAILBOX TWO-COLUMN WORKSPACE
   -------------------------------------------------------------------------- */
.mailbox-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  min-height: calc(100vh - 210px);
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--admin-border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* Left Sidebar */
.conversations-sidebar {
  border-right: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
}

.sidebar-search {
  padding: 14px;
  border-bottom: 1px solid var(--admin-border);
}

.search-input-wrap {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 6px 12px;
}

.search-input-wrap i {
  color: #94a3b8;
  margin-right: 8px;
}

.search-input-wrap input {
  border: none;
  background: none;
  outline: none;
  width: 100%;
  font-size: 0.85rem;
}

.clear-search-btn {
  color: #94a3b8;
  text-decoration: none;
}

.status-tabs {
  display: flex;
  padding: 8px 12px;
  gap: 6px;
  background-color: #f8fafc;
  border-bottom: 1px solid var(--admin-border);
}

.tab-btn {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--admin-text-muted);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background-color: #e2e8f0;
  color: var(--admin-text-dark);
}

.tab-btn.active {
  background-color: var(--admin-primary);
  color: #ffffff;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.empty-list-state {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
}

.empty-list-state i {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

/* Conversation list item */
.conv-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.conv-item:hover {
  background-color: #f8fafc;
}

.conv-item.active {
  background-color: #eff6ff;
  border-left: 4px solid var(--admin-primary);
}

.conv-item-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #003366 0%, #004b93 100%);
  color: #ffffff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.conv-status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #ffffff;
}

.conv-status-indicator.open { background-color: #10b981; }
.conv-status-indicator.closed { background-color: #94a3b8; }

.conv-item-body {
  flex: 1;
  min-width: 0;
}

.conv-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.conv-customer-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--admin-text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
}

.conv-customer-phone {
  font-size: 0.75rem;
  color: var(--admin-accent);
  font-weight: 600;
  margin-bottom: 4px;
}

.conv-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.conv-preview {
  font-size: 0.78rem;
  color: var(--admin-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.badge-unread {
  background-color: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
}

.badge-status {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-status.open { background: #dcfce7; color: #15803d; }
.badge-status.closed { background: #f1f5f9; color: #64748b; }

/* --------------------------------------------------------------------------
   RIGHT WORKSPACE: CHAT AREA
   -------------------------------------------------------------------------- */
.chat-workspace {
  display: flex;
  flex-direction: column;
  background-color: #f8fafc;
  position: relative;
}

/* Chat Header */
.chat-workspace-header {
  background: #ffffff;
  border-bottom: 1px solid var(--admin-border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.client-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.client-avatar-large {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #003366 0%, #004b93 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.client-name-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.client-name-title h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--admin-text-dark);
}

.conv-id-code {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
}

.client-sub-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--admin-text-muted);
}

.client-sub-meta a {
  color: var(--admin-text-dark);
  font-weight: 600;
}

/* Action Controls */
.chat-header-controls button {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-action-close {
  background: #fee2e2;
  color: #dc2626;
}

.btn-action-close:hover {
  background: #dc2626;
  color: #ffffff;
}

.btn-action-reopen {
  background: #dcfce7;
  color: #16a34a;
}

.btn-action-reopen:hover {
  background: #16a34a;
  color: #ffffff;
}

/* Initial inquiry note */
.initial-inquiry-box {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  padding: 10px 16px;
  margin: 12px 16px 0;
  border-radius: 8px;
  font-size: 0.85rem;
}

.inquiry-label {
  color: #b45309;
  margin-bottom: 2px;
}

.inquiry-content {
  color: #78350f;
}

/* Messages thread */
.chat-thread-stream {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg-row {
  display: flex;
  gap: 10px;
  max-width: 75%;
}

.msg-row.customer {
  align-self: flex-start;
}

.msg-row.admin {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-row.system {
  align-self: center;
  max-width: 90%;
}

.msg-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
}

.msg-sender-name {
  font-size: 0.72rem;
  color: #64748b;
  margin-bottom: 2px;
}

.msg-row.admin .msg-sender-name {
  text-align: right;
}

.msg-bubble {
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
}

.msg-bubble.customer {
  background: #ffffff;
  color: var(--admin-text-dark);
  border: 1px solid var(--admin-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-top-left-radius: 2px;
}

.msg-bubble.admin {
  background: var(--admin-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 51, 102, 0.25);
  border-top-right-radius: 2px;
}

.msg-bubble.system {
  background: #e2e8f0;
  color: #475569;
  font-size: 0.78rem;
  padding: 6px 14px;
  border-radius: 20px;
  text-align: center;
}

.msg-time {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 3px;
}

.msg-row.admin .msg-time {
  text-align: right;
}

/* Typing alert */
.admin-typing-alert {
  padding: 6px 16px;
  font-size: 0.78rem;
  color: #0284c7;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-dots .dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  background-color: #0284c7;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dots .dot:nth-child(2) { animation-delay: -0.16s; }

/* Canned replies bar */
.canned-responses-bar {
  background: #ffffff;
  border-top: 1px solid var(--admin-border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.canned-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--admin-text-muted);
  white-space: nowrap;
}

.canned-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
}

.canned-chip {
  background: #f1f5f9;
  border: 1px solid var(--admin-border);
  color: var(--admin-text-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.canned-chip:hover {
  background: var(--admin-primary);
  color: #ffffff;
}

/* Admin Input Form */
.admin-input-form {
  background: #ffffff;
  border-top: 1px solid var(--admin-border);
  padding: 12px 16px;
}

.input-form-inner {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-form-inner textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  resize: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.input-form-inner textarea:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

.btn-admin-send {
  background: linear-gradient(135deg, #003366 0%, #004b93 100%);
  color: #ffffff;
  border: none;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  height: 44px;
}

.btn-admin-send:hover {
  background: var(--admin-orange);
}

/* Empty workspace state */
.empty-workspace-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  color: #94a3b8;
}

.empty-icon-wrap {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.empty-workspace-state h3 {
  font-size: 1.25rem;
  color: var(--admin-text-dark);
  margin-bottom: 6px;
}

/* --------------------------------------------------------------------------
   LOGIN VIEW STYLES
   -------------------------------------------------------------------------- */
.login-body {
  background: linear-gradient(135deg, #002244 0%, #003366 50%, #004b93 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card-container {
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 36px 30px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  height: 60px;
  margin: 0 auto 14px;
}

.login-brand h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--admin-primary);
  margin-bottom: 4px;
}

.login-brand p {
  font-size: 0.82rem;
  color: var(--admin-text-muted);
}

.alert-box.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-login-form .form-group {
  margin-bottom: 16px;
}

.admin-login-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--admin-text-dark);
  margin-bottom: 6px;
}

.admin-login-form label i {
  color: var(--admin-primary);
  margin-right: 4px;
}

.admin-login-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  background-color: #f8fafc;
  transition: all 0.2s ease;
}

.admin-login-form input:focus {
  border-color: var(--admin-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.12);
}

.btn-login-submit {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #ff9b1f 0%, #ff6600 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
  box-shadow: 0 4px 14px rgba(255, 102, 0, 0.35);
}

.btn-login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255, 102, 0, 0.5);
}

.demo-credentials-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  margin-top: 20px;
  font-size: 0.8rem;
}

.demo-tag {
  display: block;
  font-weight: 700;
  color: var(--admin-primary);
  margin-bottom: 4px;
}

.demo-row {
  display: flex;
  justify-content: space-between;
  color: #475569;
}

.demo-row code {
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  color: #0f172a;
  font-weight: 700;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
}

.login-footer a {
  font-size: 0.82rem;
  color: var(--admin-primary);
  text-decoration: none;
  font-weight: 600;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   HISTORY TABLE VIEW
   -------------------------------------------------------------------------- */
.history-page-container {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--admin-border);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.page-top-bar {
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--admin-primary);
}

.input-search-text {
  padding: 8px 14px;
  border: 1px solid var(--admin-border);
  border-radius: 6px 0 0 6px;
  outline: none;
  font-size: 0.88rem;
  width: 240px;
}

.btn-search-history {
  background: var(--admin-primary);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 0 6px 6px 0;
  font-weight: 600;
  cursor: pointer;
}

.btn-reset-search {
  margin-left: 8px;
  font-size: 0.85rem;
  color: var(--admin-accent);
  text-decoration: none;
  align-self: center;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.history-table th {
  background: #f8fafc;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--admin-text-muted);
  border-bottom: 1px solid var(--admin-border);
}

.history-table td {
  padding: 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.history-table tr:hover td {
  background-color: #f8fafc;
}

.cust-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--admin-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.text-truncate-cell {
  display: inline-block;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--admin-text-muted);
}

.btn-table-action {
  background: #e0f2fe;
  color: #0369a1;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-table-action:hover {
  background: var(--admin-primary);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .mailbox-layout {
    grid-template-columns: 1fr;
  }
}


/* Realtime chat polish: status, readable composer, responsive workspace */
.chat-workspace::before {
  content: 'Kênh CSKH trực tuyến';
  position: absolute;
  top: 0;
  right: 18px;
  z-index: 2;
  color: #64748b;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  pointer-events: none;
}
.chat-thread-stream { scroll-behavior: smooth; background: linear-gradient(180deg,#f8fafc 0%,#eef5fb 100%); }
.msg-bubble { transition: transform .18s ease, box-shadow .18s ease; }
.msg-bubble:hover { transform: translateY(-1px); }
.admin-typing-alert { min-height: 28px; background: rgba(239,246,255,.8); border-top: 1px solid #dbeafe; }
.admin-input-form { padding: 14px 16px 16px; box-shadow: 0 -4px 16px rgba(15,23,42,.04); }
.input-form-inner textarea { min-height: 48px; max-height: 140px; line-height: 1.45; }
.btn-admin-send { min-width: 112px; justify-content: center; }
@media (max-width: 900px) {
  .mailbox-layout { grid-template-columns: 300px 1fr; }
  .client-sub-meta { flex-wrap: wrap; gap: 6px 12px; }
  .chat-header-controls button { padding: 8px 10px; }
  .chat-header-controls button { font-size: 0; }
  .chat-header-controls button i { font-size: .9rem; }
}
@media (max-width: 680px) {
  .admin-main-container { padding: 10px; }
  .metrics-row { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .metric-card { padding: 12px; }
  .metric-label { font-size: .7rem; }
  .mailbox-layout { display: flex; min-height: calc(100vh - 170px); }
  .conversations-sidebar { width: 100%; min-height: 260px; max-height: 34vh; border-right: 0; border-bottom: 1px solid var(--admin-border); }
  .chat-workspace { min-height: 62vh; }
  .chat-workspace-header { padding: 12px; }
  .client-avatar-large { width: 40px; height: 40px; }
  .client-name-title h3 { font-size: .95rem; }
  .conv-id-code { display: none; }
  .msg-row { max-width: 90%; }
  .canned-responses-bar { padding: 8px 10px; }
  .admin-input-form { padding: 10px; }
  .input-form-inner { gap: 6px; }
  .btn-admin-send { min-width: 48px; padding: 10px; }
  .btn-admin-send span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-thread-stream { scroll-behavior: auto; }
  .msg-bubble { transition: none; }
}


/* Mobile viewport fix: keep the conversation composer inside the visible app area. */
@media (max-width: 680px) {
  html, body.admin-app-body { height: 100%; overflow: hidden; }
  .admin-header { flex: 0 0 64px; }
  .admin-main-container { min-height: 0; height: calc(100dvh - 64px); overflow: hidden; }
  .dashboard-page { min-height: 0; overflow: hidden; gap: 10px; }
  .metrics-row { flex: 0 0 auto; }
  .mailbox-layout {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .conversations-sidebar {
    flex: 0 0 252px;
    height: 252px;
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }
  .conversations-list { min-height: 0; overflow-y: auto; }
  .chat-workspace {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow: hidden;
  }
  .chat-thread-stream { min-height: 0; }
  .canned-responses-bar { flex: 0 0 auto; }
  .admin-input-form { flex: 0 0 auto; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}
