/* =============================================================================
   deploychat.css — Full-screen person-to-person deploy chat page styles
   Uses CSS variables defined in styles.css
   ============================================================================= */

/* =============================================================================
   Page Layout
   ============================================================================= */

.deploy-chat-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-light);
}

/* =============================================================================
   Toolbar
   ============================================================================= */

.deploy-chat-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--gray-200);
  z-index: 10;
}

.deploy-chat-toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.deploy-chat-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deploy-chat-toolbar-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--dark);
}

/* =============================================================================
   Body (sidebar + main)
   ============================================================================= */

.deploy-chat-body {
  flex: 1;
  display: flex;
  margin-top: 48px;
  overflow: hidden;
}

/* =============================================================================
   Sidebar — Users
   ============================================================================= */

.deploy-chat-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.deploy-chat-sidebar-header {
  padding: 14px 16px 10px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

.deploy-chat-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.deploy-chat-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
}

.deploy-chat-member:hover {
  background: var(--gray-100);
}

img.deploy-chat-member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

div.deploy-chat-member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-200);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
}

.deploy-chat-member-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.deploy-chat-member-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deploy-chat-member-role {
  font-size: 0.6875rem;
  color: var(--gray-400);
}

.deploy-chat-member-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.deploy-chat-member-status.online {
  background: var(--success);
}

.deploy-chat-member-status.offline {
  background: var(--gray-300);
}

/* =============================================================================
   Main (messages + typing + input)
   ============================================================================= */

.deploy-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* =============================================================================
   Messages Area
   ============================================================================= */

.deploy-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.chat-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  max-width: 75%;
}

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

.chat-msg-other {
  align-self: flex-start;
}

.chat-msg-system {
  align-self: center;
  max-width: 90%;
  text-align: center;
  color: var(--gray-500);
  font-style: italic;
  font-size: 0.8125rem;
  padding: 4px 0;
}

img.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

div.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-200);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  line-height: 1.5;
  font-size: 0.9375rem;
  word-wrap: break-word;
}

.chat-msg-own .chat-msg-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg-other .chat-msg-bubble {
  background: var(--bg-surface);
  color: var(--dark);
  border: 1px solid var(--gray-200);
  border-bottom-left-radius: 4px;
}

.chat-msg-meta {
  font-size: 0.6875rem;
  color: var(--gray-400);
  margin-top: 2px;
}

.chat-msg-own .chat-msg-meta {
  text-align: right;
}

/* =============================================================================
   File Attachments
   ============================================================================= */

.chat-file-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  max-width: 300px;
  text-decoration: none;
  color: inherit;
}

.chat-file-attachment:hover {
  background: var(--gray-100);
}

.chat-msg-own .chat-file-attachment {
  border-color: rgba(255, 255, 255, 0.3);
}

.chat-msg-own .chat-file-attachment:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-file-icon {
  flex-shrink: 0;
  color: var(--gray-500);
}

.chat-msg-own .chat-file-icon {
  color: rgba(255, 255, 255, 0.8);
}

.chat-file-name {
  font-size: 0.8125rem;
  color: var(--primary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-msg-own .chat-file-name {
  color: white;
}

.chat-file-size {
  font-size: 0.6875rem;
  color: var(--gray-400);
}

.chat-msg-own .chat-file-size {
  color: rgba(255, 255, 255, 0.7);
}

/* =============================================================================
   Reply Quote (inline in message)
   ============================================================================= */

.chat-reply-quote {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-left: 3px solid var(--primary);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8125rem;
  line-height: 1.4;
  max-width: 100%;
  overflow: hidden;
}

.chat-reply-quote:hover {
  background: rgba(0, 0, 0, 0.07);
}

.chat-msg-own .chat-reply-quote {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: rgba(255, 255, 255, 0.6);
}

.chat-msg-own .chat-reply-quote:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-reply-quote-name {
  font-weight: 600;
  display: block;
  font-size: 0.75rem;
}

.chat-msg-own .chat-reply-quote-name {
  color: rgba(255, 255, 255, 0.9);
}

.chat-reply-quote-text {
  color: var(--gray-500);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-msg-own .chat-reply-quote-text {
  color: rgba(255, 255, 255, 0.7);
}

/* =============================================================================
   Reply Button (on message hover)
   ============================================================================= */

.chat-reply-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 0.6875rem;
  padding: 0;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.chat-msg:hover .chat-reply-btn {
  opacity: 1;
}

.chat-reply-btn:hover {
  color: var(--primary);
}

/* =============================================================================
   Reply Preview (above input bar)
   ============================================================================= */

.chat-reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--gray-200);
  border-left: 3px solid var(--primary);
}

.chat-reply-preview-body {
  min-width: 0;
  flex: 1;
}

.chat-reply-preview-name {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--primary);
  display: block;
}

.chat-reply-preview-text {
  font-size: 0.8125rem;
  color: var(--gray-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.chat-reply-preview-close {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0 0 12px;
  line-height: 1;
}

.chat-reply-preview-close:hover {
  color: var(--dark);
}

/* =============================================================================
   Message Highlight (when scrolling to replied message)
   ============================================================================= */

.chat-msg-highlight {
  animation: msg-highlight 1.5s ease-out;
}

@keyframes msg-highlight {
  0%, 30% { background: rgba(59, 130, 246, 0.12); }
  100% { background: transparent; }
}

/* =============================================================================
   Message Body (wrapper for reply quote + bubble)
   ============================================================================= */

.chat-msg-body {
  min-width: 0;
  max-width: 100%;
}

/* =============================================================================
   Typing Indicator
   ============================================================================= */

.deploy-chat-typing {
  padding: 4px 24px;
  font-size: 0.8125rem;
  color: var(--gray-400);
  font-style: italic;
  min-height: 24px;
}

/* =============================================================================
   Input Bar
   ============================================================================= */

.deploy-chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--gray-200);
  align-items: flex-end;
}

.deploy-chat-attach-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.deploy-chat-attach-btn:hover {
  color: var(--primary);
  background: var(--gray-100);
}

#deploy-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--bg-light);
  color: var(--dark);
  min-height: 44px;
  max-height: 120px;
}

#deploy-chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

#deploy-chat-send-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
}

#deploy-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =============================================================================
   Load More
   ============================================================================= */

.deploy-chat-load-more {
  text-align: center;
  padding: 12px;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8125rem;
}

.deploy-chat-load-more:hover {
  text-decoration: underline;
}

/* =============================================================================
   Dark Mode Overrides
   Most styles inherit correctly via CSS variables; these need explicit overrides.
   ============================================================================= */

[data-theme="dark"] .chat-msg-other .chat-msg-bubble {
  border-color: var(--gray-300);
}

[data-theme="dark"] .chat-file-attachment {
  border-color: var(--gray-400);
}

[data-theme="dark"] .deploy-chat-attach-btn:hover {
  background: var(--gray-200);
}

[data-theme="dark"] .deploy-chat-member:hover {
  background: var(--gray-200);
}

/* =============================================================================
   Unread Badge (Zoom-style red number)
   ============================================================================= */

.chat-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 6px;
  vertical-align: middle;
}

/* Wizard chat button already has position:relative inline */

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
  .chat-msg {
    max-width: 90%;
  }

  .deploy-chat-sidebar {
    display: none;
  }
}
