/* ── Messenger Widget ── */

.messenger-widget {
  position: fixed;
  bottom: var(--sp-6, 24px);
  right: var(--sp-6, 24px);
  z-index: 9999;
  font-family: var(--ff-body, 'DM Sans', sans-serif);
}

/* ── FAB button ── */
.messenger-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--c-primary, #0072BC);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.messenger-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.messenger-fab--open {
  background: var(--c-surface-2, #e5e7eb);
  color: var(--c-text, #1f2937);
}

.messenger-fab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

/* ── Chat panel ── */
.messenger-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  height: 500px;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Panel header ── */
.messenger-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--c-border, #e5e7eb);
  background: var(--c-surface, #fff);
  flex-shrink: 0;
}

.messenger-header__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-text, #1f2937);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messenger-header__back {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--c-text-2, #6b7280);
  padding: 4px;
  margin-right: 8px;
  border-radius: 4px;
}

.messenger-header__back:hover {
  background: var(--c-surface-2, #f3f4f6);
}

/* ── Search ── */
.messenger-search {
  padding: 8px 16px;
  border-bottom: 1px solid var(--c-border, #e5e7eb);
  flex-shrink: 0;
}

.messenger-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--c-border, #e5e7eb);
  border-radius: 8px;
  font-size: 0.85rem;
  background: var(--c-surface-2, #f9fafb);
  color: var(--c-text, #1f2937);
  outline: none;
  box-sizing: border-box;
}

.messenger-search input:focus {
  border-color: var(--c-primary, #0072BC);
  box-shadow: 0 0 0 2px rgba(0, 102, 255, 0.1);
}

/* ── Conversation list ── */
.messenger-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}

.messenger-conv-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--c-border-light, #f3f4f6);
  transition: background 0.15s ease;
}

.messenger-conv-item:hover {
  background: var(--c-surface-2, #f9fafb);
}

.messenger-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c-primary-light, #dbeafe);
  color: var(--c-primary, #0072BC);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-right: 12px;
}

.messenger-conv-info {
  flex: 1;
  min-width: 0;
}

.messenger-conv-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text, #1f2937);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messenger-conv-preview {
  font-size: 0.78rem;
  color: var(--c-text-2, #6b7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.messenger-conv-meta {
  flex-shrink: 0;
  text-align: right;
  margin-left: 8px;
}

.messenger-conv-time {
  font-size: 0.7rem;
  color: var(--c-text-3, #9ca3af);
}

.messenger-conv-unread {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--c-primary, #0072BC);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  line-height: 18px;
  padding: 0 4px;
  margin-top: 4px;
}

/* ── Messages ── */
.messenger-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.messenger-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.messenger-bubble--sent {
  align-self: flex-end;
  background: var(--c-primary, #0072BC);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.messenger-bubble--received {
  align-self: flex-start;
  background: var(--c-surface-2, #f3f4f6);
  color: var(--c-text, #1f2937);
  border-bottom-left-radius: 4px;
}

.messenger-bubble__sender {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--c-text-2, #6b7280);
  margin-bottom: 2px;
}

.messenger-bubble--sent .messenger-bubble__sender {
  color: rgba(255, 255, 255, 0.7);
}

.messenger-bubble__time {
  font-size: 0.65rem;
  margin-top: 4px;
  opacity: 0.6;
  text-align: right;
}

.messenger-typing {
  font-size: 0.75rem;
  color: var(--c-text-2, #6b7280);
  font-style: italic;
  padding: 4px 0;
}

/* ── Input area ── */
.messenger-input {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--c-border, #e5e7eb);
  background: var(--c-surface, #fff);
  flex-shrink: 0;
  gap: 8px;
}

.messenger-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--c-border, #e5e7eb);
  border-radius: 20px;
  font-size: 0.85rem;
  background: var(--c-surface-2, #f9fafb);
  color: var(--c-text, #1f2937);
  outline: none;
}

.messenger-input input:focus {
  border-color: var(--c-primary, #0072BC);
}

.messenger-input__send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-primary, #0072BC);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.messenger-input__send:hover {
  opacity: 0.9;
}

.messenger-input__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Empty state ── */
.messenger-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--c-text-2, #6b7280);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px;
}

.messenger-empty i {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ── Loading ── */
.messenger-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--c-text-2, #6b7280);
  font-size: 0.85rem;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
  .messenger-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 120px);
    right: -8px;
    bottom: 64px;
  }

  .messenger-widget {
    bottom: 16px;
    right: 16px;
  }
}

/* ── Widget tabs (Chats / Meets) ── */
.msg-tabs { display:flex; border-bottom:1px solid var(--c-border,#e5e7eb); flex-shrink:0; }
.msg-tab { flex:1; padding:8px; font-size:13px; background:none; border:none; border-top:none; border-left:none; border-right:none; cursor:pointer; color:var(--c-text-muted,#6b7280); border-bottom:2px solid transparent; }
.msg-tab--active { color:var(--c-primary,#0072BC); border-bottom-color:var(--c-primary,#0072BC); font-weight:600; }

/* ── Call buttons in conversation header ── */
.msg-call-btn { width:28px; height:28px; border-radius:50%; border:none; background:var(--c-surface-2,#f3f4f6); cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--c-text,#1f2937); flex-shrink:0; }
.msg-call-btn:hover { background:var(--c-primary,#0072BC); color:white; }

/* ── Meets room / meeting cards ── */
.msg-meets-room { padding:8px; border-radius:6px; border:1px solid #bbf7d0; background:#f0fdf4; margin-bottom:6px; }
.msg-meets-meeting { padding:8px; border-radius:6px; border:1px solid var(--c-border,#e5e7eb); margin-bottom:6px; }
