[hidden] { display: none !important; }

button { font-family: inherit; }

/* Boot & auth */
.boot-screen,
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: radial-gradient(circle at 30% 20%, #10241f 0%, var(--bg-app) 60%);
  z-index: 4000;
  padding: 20px;
}

.boot-logo { font-size: 48px; }
.boot-text { color: var(--text-secondary); font-size: 14px; }

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-logo { font-size: 26px; }
.auth-sub { color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }
.auth-hint { color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.auth-error { color: var(--accent-rose); font-size: 13px; min-height: 18px; }
.auth-card .btn-primary-form { margin-top: 6px; }

.btn-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 6px;
}
.btn-link:hover { color: var(--text-main); }

/* Sidebar additions */
.header-actions { position: relative; }

.popover-menu {
  position: absolute;
  top: 42px;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  z-index: 50;
}

.popover-menu button {
  background: none;
  border: none;
  color: var(--text-main);
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}
.popover-menu button:hover { background: var(--bg-card-hover); }
.popover-menu button.danger { color: var(--accent-rose); }

.status-dot.offline { background: var(--accent-amber); }

.connection-banner {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  font-size: 12px;
  text-align: center;
  padding: 6px;
}

.conv-avatar-wrapper .conv-status-dot { display: none; }
.conv-avatar-wrapper.online .conv-status-dot { display: block; }

.unread-badge {
  background: var(--primary);
  color: #04241a;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.conversation-item.has-unread .conv-preview { color: var(--text-main); font-weight: 600; }
.conversation-item.has-unread .conv-time { color: var(--primary-light); }
.conv-kind-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  background: rgba(6, 182, 212, 0.18);
  color: var(--accent-cyan);
  vertical-align: middle;
}
.conv-kind-tag.support { background: rgba(245, 158, 11, 0.18); color: var(--accent-amber); }
.conv-kind-tag.announcement { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }

/* Main chat */
.chat-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  position: relative;
}

.no-chat-selected {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
}
.no-chat-selected h2 { font-family: var(--font-heading); color: var(--text-main); }

.back-btn { display: none; margin-right: 4px; }
.chat-header { gap: 8px; }
.chat-header-info { min-width: 0; flex: 1; }
.header-text { min-width: 0; }
.header-title, .header-subtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-subtitle.muted { color: var(--text-muted); }

.call-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(16, 185, 129, 0.15);
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  padding: 8px 20px;
  font-size: 13px;
  color: var(--primary-light);
}

.btn-call-join {
  background: var(--primary);
  color: #04241a;
  border: none;
  border-radius: var(--radius-full);
  padding: 5px 16px;
  font-weight: 700;
  cursor: pointer;
}

.load-older {
  align-self: center;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
}

.message-bubble.deleted .message-text { color: var(--text-muted); font-style: italic; }
.message-edited { font-size: 10px; color: var(--text-muted); margin-right: 4px; }

.message-ticks { color: var(--text-muted); font-weight: bold; }
.message-ticks.read { color: #38bdf8; }

.message-quote {
  border-left: 3px solid var(--accent-cyan);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.message-quote strong { color: var(--accent-cyan); display: block; font-size: 11px; }

.message-bubble-wrapper.highlight .message-bubble { box-shadow: 0 0 0 2px var(--primary); }

.message-text a, .ai-body-text a { color: var(--primary-light); word-break: break-all; }
.message-text pre, .ai-body-text pre {
  background: rgba(0, 0, 0, 0.35);
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
}

.msg-video {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius-sm);
  background: #000;
  display: block;
}

.message-file-card .file-name { max-width: 220px; }
.file-icon-box { width: 36px; text-align: center; }

.call-log-card {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.call-log-card .call-log-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-log-card.missed .call-log-icon { background: rgba(244, 63, 94, 0.2); }
.call-log-card.missed { color: #fda4af; }

.chat-system-message span { white-space: pre-line; text-align: center; max-width: 80%; }
.chat-system-message.erp span {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
  border-radius: var(--radius-md);
  text-align: left;
  padding: 8px 14px;
}

.message-hover-actions button.danger { color: var(--accent-rose); }
.message-bubble.show-actions .message-hover-actions { display: flex; }
@media (hover: none) {
  .message-bubble:hover .message-hover-actions { display: none; }
  .message-bubble.show-actions .message-hover-actions { display: flex; }
}
.message-hover-actions { flex-wrap: wrap; max-width: min(92vw, 360px); }
.call-banner .btn-call-join + .btn-call-join { margin-left: 8px; }

.reaction-chip.mine { border-color: var(--primary); background: rgba(16, 185, 129, 0.15); }

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 8px;
}
.reply-bar-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-bar-name { font-size: 12px; font-weight: 700; color: var(--primary-light); }
.reply-bar-text { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.upload-progress { margin-bottom: 8px; font-size: 12px; color: var(--text-secondary); }
.upload-progress-track { height: 4px; background: var(--bg-card); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.upload-progress-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }

.read-only-note { text-align: center; font-size: 13px; color: var(--text-muted); padding: 8px; }

.input-bar-recording.active { display: flex; }

.voice-note-player audio { display: none; }

/* Drawer */
.drawer-group-title { font-family: var(--font-heading); margin-bottom: 4px; }
.drawer-group-desc { font-size: 13px; color: var(--text-secondary); }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.drawer-actions button {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
.drawer-actions button.danger { color: var(--accent-rose); }
.drawer-member-item { justify-content: space-between; }
.drawer-member-item .member-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.drawer-member-item .member-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}
.drawer-member-item .member-remove:hover { color: var(--accent-rose); }
.drawer-file-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
}
.drawer-file-row a { color: var(--text-main); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-file-row a:hover { color: var(--primary-light); }
.empty-media-text { font-size: 12px; color: var(--text-muted); }

/* Generic modal */
.mx-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mx-dialog {
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.mx-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  font-family: var(--font-heading);
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
}

.mx-dialog-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mx-dialog-body form { display: flex; flex-direction: column; gap: 12px; }

.people-list {
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 8px;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  color: var(--text-main);
  text-align: left;
  width: 100%;
}
.person-row:hover { background: var(--bg-card); }
.person-row .person-text { flex: 1; min-width: 0; }
.person-row .person-name { font-size: 13px; font-weight: 600; }
.person-row .person-sub { font-size: 11px; color: var(--text-muted); }
.person-row input[type='checkbox'] { accent-color: var(--primary); width: 16px; height: 16px; }
.person-online { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding-top: 22px;
}
.checkbox-row input { accent-color: var(--primary); }

/* Admin additions */
.admin-search { margin-bottom: 12px; max-width: 320px; }
.table-scroll { overflow-x: auto; }
.admin-table select {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 12px;
}
.admin-table tr.inactive { opacity: 0.55; }
.admin-subheading { font-family: var(--font-heading); margin: 24px 0 12px; }
.credential-box {
  margin-top: 16px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
}
.credential-box code {
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 14px;
  user-select: all;
}

/* Calls */
.live-dot { color: var(--accent-rose); }
.meeting-top-bar { gap: 12px; }
.meeting-main-grid { align-content: center; }
.meeting-main-grid.speaker { grid-template-columns: 1fr; }
.meeting-main-grid.speaker .meeting-participant-card:not(:first-child) { display: none; }

.meeting-participant-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  position: absolute;
  inset: 0;
}
.meeting-participant-card.screen video { object-fit: contain; }
.meeting-participant-card .participant-avatar { position: relative; z-index: 1; }
.meeting-participant-card.has-video .participant-avatar { display: none; }
.meeting-participant-card .participant-status-badge { z-index: 2; }
.meeting-participant-card .tile-state { font-size: 11px; color: var(--text-muted); }
.meeting-participant-card.speaking { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-glow); }
.mic-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.mic-indicator.muted { background: var(--accent-rose); }

.meeting-waiting {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.meeting-waiting img { width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--primary); animation: callAvatarPulse 1.5s infinite; }

.local-video-wrapper .tile-name {
  position: absolute;
  bottom: 6px;
  left: 8px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.local-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
}
.local-placeholder img { width: 48px; height: 48px; border-radius: 50%; }
.local-video-wrapper.audio-only { height: 90px; width: 160px; }

.btn-call-accept {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--primary);
  color: #04241a;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: callAvatarPulse 1.5s infinite;
}
.btn-call-accept:hover { transform: scale(1.1); }
.call-actions { gap: 40px; }

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5000;
  pointer-events: none;
  width: min(92vw, 420px);
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}
.toast.error { border-left-color: var(--accent-rose); }

/* Responsive */
@media (max-width: 1100px) {
  .details-drawer.open {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 768px) {
  body { height: 100dvh; }
  .app-container { height: 100dvh; }
  .app-sidebar { width: 100%; max-width: none; min-width: 0; }
  .app-main-chat { display: none; }
  .app-container.chat-open .app-sidebar { display: none; }
  .app-container.chat-open .app-main-chat { display: flex; }
  .back-btn { display: flex; }
  .btn-call-action { padding: 7px 10px; }
  .btn-call-action .btn-label { display: none; }
  .message-bubble { max-width: 85%; }
  .conv-preview { max-width: 60vw; }
  .details-drawer.open { width: 100%; }
  .local-video-wrapper { width: 120px; height: 160px; right: 12px; bottom: 96px; }
  .meeting-main-grid { padding: 12px; gap: 10px; grid-template-columns: 1fr; }
  .meeting-participant-card { min-height: 200px; }
  .admin-dialog { width: 100vw; height: 100dvh; max-width: none; border-radius: 0; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .emoji-popover { width: calc(100vw - 40px); }
  .chat-input-area { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
}
