:root {
  --mm-sidebar-bg: #1e325c;
  --mm-sidebar-dark: #152442;
  --mm-sidebar-hover: rgba(255, 255, 255, 0.08);
  --mm-sidebar-active: #2b4478;
  --mm-sidebar-text: #e2e8f0;
  --mm-sidebar-muted: #8fa5c4;
  --mm-sidebar-border: #283e6b;
  --mm-accent-blue: #3888ff;

  --app-bg: #f4f6fa;
  --header-bg: #ffffff;
  --border-light: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --msg-me-bg: #eef4ff;
  --msg-me-border: #bfdbfe;
  --msg-other-bg: #ffffff;
  --msg-other-border: #e2e8f0;

  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --danger-color: #ef4444;
  --success-color: #10b981;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-card: 0 4px 14px -2px rgba(15, 23, 42, 0.08);
  --shadow-popup: 0 24px 50px -12px rgba(15, 23, 42, 0.22);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body.mattermost-theme {
  font-family: var(--font-family);
  background-color: var(--app-bg);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: fixed;
}

/* ================= 1. DEDICATED FULL-SCREEN LOGIN ================= */
.login-full-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(135deg, #152442 0%, #1e325c 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.login-box-card {
  width: 410px;
  max-width: 95vw;
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.4);
  padding: 36px 32px 30px;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.25s ease;
}
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.login-card-header {
  text-align: center;
  margin-bottom: 20px;
}
.login-logo-badge {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.login-app-title {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.5px;
}
.login-app-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-default-hint {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 20px;
  line-height: 1.45;
}
.login-default-hint i { font-size: 17px; flex-shrink: 0; margin-top: 1px; }

.login-form-body {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.input-icon-wrap i {
  position: absolute;
  left: 14px;
  font-size: 19px;
  color: #94a3b8;
  pointer-events: none;
}
.input-icon-wrap input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}
.input-icon-wrap input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-error-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 12.5px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
}

.login-submit-btn {
  background: var(--primary-color);
  color: #ffffff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  margin-top: 4px;
}
.login-submit-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

/* ================= 2. APP LAYOUT ================= */
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(2px);
  z-index: 150;
  display: block;
  animation: fadeIn 0.2s ease;
}

/* SIDEBAR */
.mm-sidebar {
  width: 254px;
  min-width: 254px;
  background-color: var(--mm-sidebar-bg);
  color: var(--mm-sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--mm-sidebar-border);
  user-select: none;
  z-index: 20;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.mm-team-header {
  height: 54px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--mm-sidebar-border);
  background-color: var(--mm-sidebar-dark);
}

.team-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  overflow: hidden;
}

.team-badge {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3888ff, #6366f1);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}

.team-info { display: flex; flex-direction: column; overflow: hidden; }
.team-title { font-size: 14.5px; font-weight: 700; color: #ffffff; letter-spacing: -0.3px; }
.team-status { font-size: 11px; color: var(--mm-sidebar-muted); display: flex; align-items: center; gap: 4px; }
.status-indicator.online { width: 6px; height: 6px; background-color: var(--success-color); border-radius: 50%; }

.mobile-sidebar-close {
  display: none;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.mm-channels-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  -webkit-overflow-scrolling: touch;
}

.channel-category { margin-bottom: 16px; }
.category-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--mm-sidebar-muted);
  margin-bottom: 5px;
}

.add-channel-icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--mm-sidebar-muted);
  font-size: 14px;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.add-channel-icon-btn:hover {
  background: var(--mm-accent-blue);
  color: #ffffff;
  transform: scale(1.05);
}

.channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--mm-sidebar-text);
  font-size: 13.5px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.15s ease;
  position: relative;
}
.channel-item:hover { background-color: var(--mm-sidebar-hover); color: #ffffff; }
.channel-item.active {
  background-color: var(--mm-sidebar-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.channel-item.active::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 22%;
  height: 56%;
  width: 3.5px;
  background-color: var(--mm-accent-blue);
  border-radius: 4px;
}

.channel-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  max-width: 72%;
}
.channel-icon { font-size: 15px; color: var(--mm-sidebar-muted); flex-shrink: 0; }
.channel-item.active .channel-icon { color: #ffffff; }
.channel-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.channel-pair-pill {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  flex-shrink: 0;
}

.empty-channels-hint {
  padding: 16px 8px;
  font-size: 12px;
  color: var(--mm-sidebar-muted);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.mm-user-footer {
  height: 60px;
  padding: 0 10px 0 12px;
  background-color: var(--mm-sidebar-dark);
  border-top: 1px solid var(--mm-sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.user-profile-summary { display: flex; align-items: center; gap: 9px; overflow: hidden; }
.avatar-wrap { position: relative; width: 34px; height: 34px; flex-shrink: 0; }
.avatar-wrap img { width: 100%; height: 100%; border-radius: 10px; background: #334155; }
.user-dot.online { position: absolute; bottom: -1px; right: -1px; width: 8px; height: 8px; border-radius: 50%; background-color: var(--success-color); border: 1.5px solid var(--mm-sidebar-dark); }
.user-meta { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 12px; font-weight: 600; color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 95px; }
.user-desc { display: flex; align-items: center; gap: 4px; }
.role-badge { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: var(--radius-xs); text-transform: uppercase; }
.role-badge.admin { background: #3888ff; color: #fff; }
.role-badge.user { background: #64748b; color: #fff; }

.footer-actions { display: flex; align-items: center; gap: 4px; }
.footer-btn { background: transparent; border: none; color: var(--mm-sidebar-muted); font-size: 18px; padding: 7px; border-radius: var(--radius-xs); cursor: pointer; transition: all 0.15s; }
.footer-btn:hover { background: var(--mm-sidebar-hover); color: #ffffff; }

/* MAIN CHAT AREA */
.mm-main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  background-color: var(--app-bg);
  overflow: hidden;
}

/* Header */
.channel-header {
  height: 54px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 9px; overflow: hidden; }
.mobile-toggle-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.channel-meta-wrap { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.channel-hash-icon { font-size: 16px; font-weight: 700; color: var(--primary-color); }
.channel-title { font-size: 15px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-pair-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2.5px 8px;
  border-radius: var(--radius-full);
  background: #eff6ff;
  color: var(--primary-color);
  border: 1px solid #bfdbfe;
  flex-shrink: 0;
}
.room-members-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: #f1f5f9;
  border: 1px solid var(--border-light);
  padding: 2.5px 9px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.room-members-pill:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}
.channel-desc-row { font-size: 11.5px; color: var(--text-muted); margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-right { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.header-tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background-color: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.header-tool-btn:hover { background-color: #f8fafc; color: var(--primary-color); border-color: #bfdbfe; }
.header-tool-btn.danger { color: var(--danger-color); }
.header-tool-btn.danger:hover { background-color: #fef2f2; border-color: #fca5a5; }

/* Message Feed */
.message-feed-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

/* Empty State Card */
.no-room-empty-card {
  margin: auto;
  text-align: center;
  max-width: 440px;
  padding: 36px 24px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-icon-wrap {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #eff6ff;
  color: var(--primary-color);
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.no-room-title { font-size: 17.5px; font-weight: 700; color: var(--text-primary); }
.no-room-desc { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; }

.msg-item {
  display: flex;
  gap: 9px;
  max-width: 74%;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

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

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 100%;
}
.msg-item.me .msg-content-wrapper { align-items: flex-end; }

.msg-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px;
}

/* ================= BEAUTIFULLY ROUNDED MESSAGE BUBBLES ================= */
.msg-bubble {
  width: fit-content;
  max-width: min(100%, 600px);
  background-color: var(--msg-other-bg);
  border: 1px solid var(--msg-other-border);
  border-radius: 18px 18px 18px 4px; /* Directional soft rounded chat bubble */
  padding: 8px 13px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow 0.15s;
}
.msg-item.me .msg-bubble {
  background-color: var(--msg-me-bg);
  border-color: var(--msg-me-border);
  border-radius: 18px 18px 4px 18px; /* Directional bubble for me */
}

.msg-orig {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-primary);
  word-break: break-word;
}

.msg-trans-row {
  margin-top: 3px;
  padding-top: 5px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 13.5px;
}
.msg-item.me .msg-trans-row {
  border-top-color: rgba(37, 99, 235, 0.15);
}

.trans-body {
  color: #1d4ed8;
  font-weight: 500;
  line-height: 1.45;
  word-break: break-word;
}
.msg-item:not(.me) .trans-body {
  color: #0369a1;
}

/* Loading spinner for translation */
.trans-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #3b82f6;
  font-weight: 500;
  user-select: none;
}
.spin-icon {
  font-size: 14px;
  animation: spinLoading 1s infinite linear;
}
@keyframes spinLoading {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.msg-time-bottom {
  font-size: 10px;
  color: var(--text-muted);
  align-self: flex-end;
  margin-top: 1px;
}

/* Recording Banner */
.recording-banner {
  background: #1e293b;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 2px solid var(--danger-color);
  animation: slideUp 0.15s ease;
  flex-shrink: 0;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.rec-status-indicator { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.rec-status-indicator i { font-size: 18px; color: var(--danger-color); }
.pulse-red-ring { width: 8px; height: 8px; background-color: var(--danger-color); border-radius: 50%; animation: pulseAnim 1.2s infinite; }
@keyframes pulseAnim { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }

.rec-actions { display: flex; gap: 8px; }
.rec-cancel-btn { background: transparent; border: 1px solid #475569; color: #cbd5e1; border-radius: var(--radius-xs); padding: 5px 12px; font-size: 12px; cursor: pointer; }
.rec-done-btn { background: var(--success-color); border: none; color: #ffffff; border-radius: var(--radius-xs); padding: 5px 14px; font-size: 12px; font-weight: 600; cursor: pointer; }

/* ================= MODERN ROUNDED COMPOSER ================= */
.chat-composer-container {
  padding: 10px 18px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background-color: var(--header-bg);
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.composer-box {
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: 26px; /* Modern rounded pill-box */
  padding: 6px 10px 6px 16px;
  display: flex;
  align-items: flex-end;
  gap: 9px;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.05);
  transition: all 0.2s ease;
}
.composer-box:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.composer-box textarea {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: none;
  max-height: 90px;
  padding: 6px 2px;
  color: var(--text-primary);
  background: transparent;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.mic-btn {
  background: #f1f5f9;
  color: var(--text-secondary);
  padding: 7px 13px;
  height: 36px;
  border-radius: var(--radius-full);
}
.mic-btn:hover { background: #e2e8f0; color: var(--primary-color); }

.send-btn {
  background: var(--primary-color);
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 50%; /* Circle send button */
  font-size: 16px;
  padding: 0;
}
.send-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

/* ================= 3. ROUNDED MODALS & FORMS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
  padding: 14px;
}

.modal-box {
  width: 490px;
  max-width: 96vw;
  max-height: 90vh;
  max-height: 90dvh;
  background: #ffffff;
  border-radius: var(--radius-xl); /* 28px soft modal */
  box-shadow: var(--shadow-popup);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleIn 0.2s ease;
}
.modal-box.modal-large { width: 720px; }
.modal-box.modal-admin-hub { width: 840px; height: 600px; max-height: 92vh; }

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-light);
  background: #f8fafc;
  flex-shrink: 0;
}
.modal-title-wrap { display: flex; align-items: center; gap: 9px; font-size: 15.5px; font-weight: 700; color: var(--text-primary); }
.modal-title-wrap i { font-size: 20px; color: var(--primary-color); }
.modal-x-btn { background: transparent; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; border-radius: var(--radius-xs); padding: 4px; transition: all 0.15s; }
.modal-x-btn:hover { color: var(--text-primary); background: #e2e8f0; }

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.modal-bottom {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 22px;
  border-top: 1px solid var(--border-light);
  background: #f8fafc;
  flex-shrink: 0;
}

.btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary-color); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25); }
.btn-secondary { background: #ffffff; border-color: var(--border-light); color: var(--text-secondary); }
.btn-secondary:hover { background: #f8fafc; color: var(--text-primary); border-color: #cbd5e1; }
.btn-link { background: none; border: none; color: var(--primary-color); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.form-group label .req { color: var(--danger-color); }

.form-input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08); }
.form-help { font-size: 11.5px; color: var(--text-muted); }

/* FIX FOR PASSWORD & EYE BUTTON (PERFECT INLINE TOGGLE) */
.input-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.input-password-wrap input {
  width: 100%;
  padding-right: 42px;
}
.input-password-wrap .toggle-eye-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.input-password-wrap .toggle-eye-btn:hover {
  color: var(--text-primary);
}

.settings-hint {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.test-conn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.test-result-text { font-size: 12.5px; font-weight: 600; }
.test-result-text.success { color: var(--success-color); }
.test-result-text.error { color: var(--danger-color); }

/* Member selector box */
.member-header-row { display: flex; align-items: center; justify-content: space-between; }
.members-selector-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  -webkit-overflow-scrolling: touch;
}
.member-select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.member-select-item:hover { background: #f1f5f9; }
.member-select-item input[type="checkbox"] { cursor: pointer; width: 17px; height: 17px; }
.member-item-info { display: flex; align-items: center; gap: 8px; flex: 1; overflow: hidden; }
.member-mini-avatar { width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; }
.member-item-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-item-uname { font-size: 11.5px; color: var(--text-muted); flex-shrink: 0; }

/* Room members modal list */
.room-members-list-box {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.room-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

/* User CRUD box */
.admin-create-user-box {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.create-user-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.users-table-scroll { max-height: 240px; overflow-y: auto; border: 1px solid var(--border-light); border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
.users-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.users-table th { background: #f8fafc; padding: 9px 12px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border-light); }
.users-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-light); }
.user-action-btn { background: transparent; border: none; cursor: pointer; padding: 5px 8px; border-radius: var(--radius-xs); transition: all 0.15s; }
.user-action-btn.del { color: var(--danger-color); }
.user-action-btn.del:hover { background: #fef2f2; }

/* ================= 4. DEDICATED ADMIN CENTER HUB ================= */
.admin-hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 0;
  background: #ffffff;
}
.admin-tab-nav {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
}
.admin-tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.admin-tab-btn i { font-size: 16px; }
.admin-tab-btn:hover { background: #f8fafc; color: var(--primary-color); border-color: #bfdbfe; }
.admin-tab-btn.active {
  background: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.admin-tab-content { display: none; }
.admin-tab-content.active { display: flex; flex-direction: column; gap: 16px; }

/* STATS CARDS */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.stat-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon-wrap.blue { background: #eff6ff; color: #2563eb; }
.stat-icon-wrap.green { background: #ecfdf5; color: #10b981; }
.stat-icon-wrap.purple { background: #f5f3ff; color: #8b5cf6; }
.stat-icon-wrap.amber { background: #fffbeb; color: #f59e0b; }
.stat-content { display: flex; flex-direction: column; }
.stat-val { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.admin-info-banner {
  background: linear-gradient(135deg, #1e325c 0%, #152442 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.admin-info-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.admin-info-desc { font-size: 12.5px; color: #cbd5e1; line-height: 1.45; }

/* ================= 5. RESPONSIVE MEDIA QUERIES ================= */
@media (max-width: 768px) {
  .mm-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    width: 270px;
    max-width: 82vw;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }
  .mm-sidebar.open { transform: translateX(0); }
  .mobile-toggle-btn { display: flex; }
  .mobile-sidebar-close { display: flex; }

  .channel-header { padding: 0 10px; height: 50px; }
  .channel-title { max-width: 140px; font-size: 14px; }
  .channel-desc-row { display: none; }
  .header-tool-btn span { display: none; }
  .header-tool-btn { padding: 6px 9px; font-size: 15px; }

  .msg-item { max-width: 88%; }
  .message-feed-scroll { padding: 10px 10px; gap: 9px; }
  .msg-bubble { padding: 8px 12px; border-radius: 16px 16px 16px 4px; }
  .msg-item.me .msg-bubble { border-radius: 16px 16px 4px 16px; }

  .chat-composer-container { padding: 6px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .composer-box { border-radius: 22px; padding: 5px 8px 5px 12px; }
  .composer-box textarea { font-size: 15px; }

  .create-user-grid { grid-template-columns: 1fr; }
  .stat-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-tab-nav { overflow-x: auto; padding: 10px 14px; }
  .modal-box.modal-admin-hub { width: 96vw; height: 92vh; border-radius: var(--radius-lg); }
}

@media (max-width: 480px) {
  .login-box-card { padding: 24px 18px 20px; border-radius: var(--radius-lg); }
  .login-app-title { font-size: 20px; }
  .login-default-hint { font-size: 11.5px; padding: 8px 10px; }

  .channel-title { max-width: 110px; font-size: 13.5px; }
  .lang-pair-badge { font-size: 9.5px; padding: 2px 5px; }
  .room-members-pill { padding: 2px 6px; font-size: 10px; }

  .msg-item { max-width: 92%; }
  .mic-label { display: none; }
  .mic-btn { padding: 7px 10px; width: 36px; border-radius: 50%; }

  .stat-cards-grid { grid-template-columns: 1fr; }
  .modal-box { max-height: 92vh; max-height: 92dvh; border-radius: var(--radius-lg); }
  .modal-top { padding: 12px 16px; }
  .modal-body { padding: 14px 16px; gap: 11px; }
  .modal-bottom { padding: 10px 16px; }
}

.hidden { display: none !important; }

/* ================= READABILITY: CHỮ TRONG ROOM TO HƠN ================= */
/* Đặt cuối file (stylesheet load sau cùng) để ghi đè các rule trùng lặp phía trước */

/* Desktop / Web */
.msg-orig { font-size: 15.5px; line-height: 1.5; }
.msg-trans-row { font-size: 15px; }
.trans-body { line-height: 1.5; }
.trans-loading { font-size: 13px; }
.msg-meta-row { font-size: 12.5px; }
.msg-time-bottom { font-size: 11.5px; }
.typing-indicator-bar { font-size: 13px; }
.composer-box textarea { font-size: 15.5px; line-height: 1.5; max-height: 120px; }
.msg-bubble { padding: 9px 14px; }

/* Tablet & Smartphone */
@media (max-width: 768px) {
  .msg-orig { font-size: 16.5px; line-height: 1.5; }
  .msg-trans-row { font-size: 16px; }
  .msg-meta-row { font-size: 12.5px; }
  .msg-time-bottom { font-size: 11.5px; }
  .typing-indicator-bar { font-size: 13px; }
  /* >= 16px: tránh iOS Safari tự zoom khi focus ô nhập */
  .composer-box textarea { font-size: 16.5px; }
  .msg-bubble { padding: 9px 13px; }
}

/* Smartphone nhỏ */
@media (max-width: 480px) {
  .msg-orig { font-size: 16px; }
  .msg-trans-row { font-size: 15.5px; }
  .composer-box textarea { font-size: 16px; }
}

/* ================= ROOM TITLE DROPDOWN (giống Mattermost) ================= */
.room-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  padding: 5px 8px 5px 5px;
  margin-left: -5px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-primary);
  transition: background-color 0.15s ease;
}
.room-title-btn:hover,
.room-title-btn.active { background-color: rgba(15, 23, 42, 0.06); }
.room-title-btn .channel-title { min-width: 0; }
.room-title-caret {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.room-title-btn.active .room-title-caret { transform: rotate(180deg); }

.room-menu-dropdown {
  position: fixed;
  z-index: 1500;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 12px 32px -6px rgba(15, 23, 42, 0.22), 0 2px 6px rgba(15, 23, 42, 0.06);
  padding: 6px 0;
  animation: roomMenuIn 0.12s ease-out;
}
@keyframes roomMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.room-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}
.room-menu-item i { font-size: 19px; color: var(--text-secondary); flex-shrink: 0; }
.room-menu-item:hover { background-color: rgba(37, 99, 235, 0.08); }
.room-menu-item.danger,
.room-menu-item.danger i { color: #d24b4e; }
.room-menu-item.danger:hover { background-color: rgba(210, 75, 78, 0.08); }
.room-menu-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}
.room-menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 0;
}

/* Room info modal */
.room-info-hero { display: flex; align-items: center; gap: 14px; }
.room-info-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #eef4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.room-info-name { font-size: 17px; font-weight: 700; color: var(--text-primary); word-break: break-word; }
.room-info-slug { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.room-info-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  font-size: 14px;
  margin-top: 6px;
}
.room-info-label { color: var(--text-secondary); }
.room-info-value { color: var(--text-primary); font-weight: 500; }

.room-info-hero-text { flex: 1; min-width: 0; }
.room-info-name-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.room-info-name-edit { display: flex; gap: 8px; align-items: center; }
.room-info-name-edit .form-input { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.room-info-name-edit .btn { flex-shrink: 0; white-space: nowrap; }
.room-info-name-edit .btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Room members modal */
.room-members-list { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
#roomMembersModal .add-member-control-row { gap: 8px; }
#roomMembersModal .add-member-control-row .btn { flex-shrink: 0; white-space: nowrap; }

@media (max-width: 768px) {
  .room-menu-item { padding: 12px 18px; font-size: 15.5px; }
  .room-title-btn .channel-title { max-width: 150px; }
}

/* ================= SMARTPHONE: KHU NHẬP TIN NHẮN KIỂU APP ================= */
@media (max-width: 768px) {
  /* Bàn phím ĐÓNG: app luôn vừa đúng vùng nhìn thấy (fixed + inset 0)
     Bàn phím MỞ: chiều cao = phần màn hình phía trên bàn phím (JS cập nhật --app-height) */
  body.mattermost-theme {
    top: 0; right: 0; bottom: 0; left: 0;
    width: auto;
    height: auto;
    overscroll-behavior: none;
  }
  .app-layout,
  .mm-main-content { height: 100%; }
  body.mattermost-theme.keyboard-open {
    top: var(--app-top, 0px);
    bottom: auto;
    height: var(--app-height, 100%);
  }
  .message-feed-scroll { min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .chat-composer-container { flex-shrink: 0; }
  .composer-box textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Sidebar đóng thì không để lộ bóng đổ ở mép trái */
  .mm-sidebar { box-shadow: none; }
  .mm-sidebar.open { box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35); }

  .chat-composer-container {
    padding: 6px 8px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    background: #ffffff;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
  }
  /* Bàn phím đang mở: bỏ phần đệm "home indicator" để ô nhập dính sát bàn phím */
  body.keyboard-open .chat-composer-container { padding-bottom: 6px; }

  .composer-box {
    background: #f0f2f5;
    border: none;
    border-radius: 24px;
    padding: 2px 2px 2px 16px;
    min-height: 48px;
    gap: 4px;
    box-shadow: none;
    align-items: flex-end;
  }
  .composer-box:focus-within { border: none; box-shadow: none; background: #eceff3; }

  .composer-box textarea {
    font-size: 16px;          /* >= 16px để iOS không tự zoom khi focus */
    line-height: 22px;
    padding: 11px 0;          /* 22 + 22 = 44px, bằng chiều cao nút gửi */
    max-height: 120px;        /* tối đa ~5 dòng rồi cuộn */
    overflow-y: auto;
  }

  .composer-actions { gap: 2px; margin-bottom: 1px; }

  .mic-btn,
  .send-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
  }
  .mic-btn { background: transparent; color: #64748b; font-size: 24px; }
  .mic-btn:hover, .mic-btn:active { background: rgba(15, 23, 42, 0.06); }
  .mic-label { display: none; }
  .send-btn { font-size: 21px; animation: sendPop 0.15s ease; }
  .send-btn:hover { transform: none; }
  .send-btn:active { transform: scale(0.92); }

  /* Giống Messenger/WhatsApp: chưa gõ -> hiện mic, đã gõ -> hiện nút gửi */
  .composer-box:not(.has-text) .send-btn { display: none; }
  .composer-box.has-text .mic-btn { display: none; }
}

@keyframes sendPop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ================= SMARTPHONE: BÀN PHÍM KHÔNG CHE Ô NHẬP (login, đổi mật khẩu, modal) ================= */
@media (max-width: 768px) {
  /* iOS tự zoom khi focus ô nhập < 16px -> giữ tối thiểu 16px cho mọi ô nhập */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea,
  .form-input { font-size: 16px !important; }

  /* Màn hình đăng nhập / đổi mật khẩu: cuộn được, card căn giữa nhưng không bị cắt khi màn hình thấp */
  .login-full-screen {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .login-full-screen .login-box-card { margin: auto; }

  .modal-backdrop { overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* Bàn phím MỞ: overlay chỉ chiếm phần màn hình phía trên bàn phím */
  body.keyboard-open .login-full-screen,
  body.keyboard-open .modal-backdrop {
    top: var(--app-top, 0px);
    bottom: auto;
    height: var(--app-height, 100%);
  }
  body.keyboard-open .login-full-screen { padding-top: 12px; padding-bottom: 12px; }
  body.keyboard-open .modal-backdrop { align-items: flex-start; padding: 8px; }
  body.keyboard-open .modal-box {
    max-height: calc(var(--app-height, 100dvh) - 16px);
    margin: 0 auto;
  }

  /* Thanh ghi âm trên điện thoại */
  .recording-banner { border-radius: 0; padding: 10px 14px; }
  .rec-cancel-btn, .rec-done-btn { padding: 8px 14px; font-size: 14px; }
}

/* Nút mic đang ghi âm */
.mic-btn.recording {
  background: var(--danger-color, #ef4444) !important;
  color: #ffffff !important;
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
.mic-btn:disabled { cursor: wait; }
