/* MatSpell Floating Chat Widget Styles */

.chat-widget-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.4), 0 4px 10px -2px rgba(15, 23, 42, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9990;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s;
}

.chat-widget-launcher:hover {
  transform: translateY(-3px) scale(1.05);
  background: #1e293b;
}

.chat-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.chat-launcher-badge.hidden {
  display: none;
}

/* Elevated Chat Container */
.chat-widget-container {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: clamp(320px, 800px, 90vw);
  height: clamp(400px, 600px, 85vh);
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-widget-container.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.chat-container-header {
  height: 54px;
  background: #0f172a;
  color: #ffffff;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.chat-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.chat-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Body Split Pane */
.chat-container-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left Sidebar (User List) */
.chat-sidebar {
  width: 260px;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.chat-search-box {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.chat-search-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  outline: none;
}

.chat-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.chat-user-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.chat-user-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.chat-user-item:hover {
  background: #f1f5f9;
}

.chat-user-item.active {
  background: #e2e8f0;
  font-weight: 500;
}

.chat-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #3b82f6;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.chat-user-info {
  flex: 1;
  min-width: 0;
}

.chat-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-user-last-msg {
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-thread-unread {
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Right Main Chat Pane */
.chat-main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  min-width: 0;
}

.chat-main-header {
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  flex-shrink: 0;
}

.chat-active-name {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}

.chat-active-status {
  font-size: 12px;
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-message-list {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
}

.chat-empty-state {
  margin: auto;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

.chat-message-row {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.chat-message-row.sent {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message-row.received {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-message-meta {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 3px;
  padding: 0 4px;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-message-row.sent .chat-bubble {
  background: #0f172a;
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.chat-message-row.received .chat-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 2px;
  border: 1px solid #e2e8f0;
}

.chat-entity-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
}

.chat-message-row.sent .chat-entity-tag {
  background: rgba(255, 255, 255, 0.15);
  color: #93c5fd;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.chat-context-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: #1e40af;
}

.chat-context-banner button {
  background: transparent;
  border: none;
  color: #1e40af;
  font-weight: 700;
  cursor: pointer;
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-text-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  overflow-y: auto;
}

.chat-text-input:focus {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.chat-context-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.15s;
}

.chat-context-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.chat-send-btn {
  background: #0f172a;
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-send-btn:hover {
  background: #1e293b;
}

.chat-attachment-item {
  margin-top: 6px;
}

.chat-attachment-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: block;
  object-fit: cover;
  margin-top: 4px;
}

.chat-attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.06);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: inherit;
  text-decoration: underline;
  margin-top: 4px;
}

.chat-message-row.sent .chat-attachment-link {
  background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 640px) {
  .chat-widget-container {
    right: 12px;
    left: 12px;
    bottom: 80px;
    width: auto;
    height: 75vh;
  }
  .chat-sidebar {
    width: 100px;
  }
  .chat-user-name, .chat-user-last-msg {
    display: none;
  }
}
