/* ============================================================
   EQUALA Platform UI - messages.css
   ============================================================ */

/* Override main layout for messages — full height, no scroll */
.messages-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - var(--ticker-h));
  overflow: hidden;
  margin-left: var(--sidebar-w);
}

/* ── CONVERSATIONS PANEL ── */
.conversations-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--dark);
  overflow: hidden;
}

.conv-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.conv-panel-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
}

.new-msg-btn {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.new-msg-btn:hover {
  background: var(--accent2);
  color: var(--black);
}

.conv-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.conv-search {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.conv-search:focus { border-color: rgba(26,108,255,0.4); }
.conv-search::placeholder { color: var(--muted); }

/* Conversation list */
.conv-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
  position: relative;
}

.conv-item:hover { background: rgba(255,255,255,0.04); }

.conv-item.active {
  background: rgba(26,108,255,0.1);
  border-right: 2px solid var(--accent2);
}

.conv-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--black);
  flex-shrink: 0;
}

.conv-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.conv-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.conv-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.conv-time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}

.conv-preview {
  font-size: 11px;
  color: var(--muted2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.conv-unread {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── MESSAGE THREAD ── */
.message-thread {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--black);
}

/* Thread header */
.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--dark);
  flex-shrink: 0;
}

.thread-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.thread-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--black);
}

.thread-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thread-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.thread-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--green);
  letter-spacing: 0.04em;
}

.online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-green 2s ease-in-out infinite;
}

.thread-actions {
  display: flex;
  gap: 8px;
}

.thread-action-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted2);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.03em;
}

.thread-action-btn:hover {
  color: var(--accent2);
  border-color: rgba(26,108,255,0.3);
}

/* Messages */
.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thread-date-divider {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 12px 0 4px;
  position: relative;
}

.thread-date-divider::before,
.thread-date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 60px);
  height: 1px;
  background: var(--border);
}

.thread-date-divider::before { left: 0; }
.thread-date-divider::after  { right: 0; }

/* Message bubbles */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.msg.outgoing { justify-content: flex-end; }
.msg.incoming { justify-content: flex-start; }

.msg-avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--black);
  flex-shrink: 0;
  margin-bottom: 2px;
}

.msg-bubble {
  max-width: 65%;
  background: var(--accent);
  border-radius: 12px 12px 2px 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-bubble p {
  font-size: 13px;
  color: #fff;
  line-height: 1.5;
}

.msg-bubble.incoming-bubble {
  background: var(--card);
  border-radius: 12px 12px 12px 2px;
  border: 1px solid var(--border);
}

.msg-bubble.incoming-bubble p { color: var(--text); }

.msg-time {
  font-family: var(--font-mono);
  font-size: 8px;
  color: rgba(255,255,255,0.5);
  align-self: flex-end;
}

.incoming-bubble .msg-time { color: var(--muted); }

/* Input */
.thread-input-wrap {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.thread-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text);
  outline: none;
  resize: none;
  min-height: 44px;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.thread-input:focus { border-color: rgba(26,108,255,0.4); }
.thread-input::placeholder { color: var(--muted); }

.thread-input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.thread-suggest-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--green);
  background: rgba(0,200,150,0.08);
  border: 1px solid rgba(0,200,150,0.2);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.03em;
}

.thread-suggest-btn:hover {
  background: rgba(0,200,150,0.15);
  border-color: var(--green);
}

/* Empty state */
.messages-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--black);
}

.empty-icon-lg {
  font-size: 36px;
  color: var(--muted);
  opacity: 0.3;
}

.messages-empty p {
  font-size: 14px;
  color: var(--muted2);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,3,5,0.85);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted2);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted2);
}

.form-input {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 14px;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.form-input:focus { border-color: rgba(26,108,255,0.5); }
.form-input::placeholder { color: var(--muted); }
.form-textarea { resize: vertical; min-height: 100px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.hidden { display: none !important; }