/* Chat container */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.chat-header h2 {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pinned messages */
.pinned-bar {
  background: #fef9c3;
  border-bottom: 1px solid #fde68a;
  padding: 8px 20px;
  font-size: 13px;
  color: #92400e;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pinned-bar:hover { background: #fef3c7; }

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

/* Single message */
.chat-msg {
  max-width: 85%;
  padding: 8px 14px;
  border-radius: 12px;
  position: relative;
  animation: msg-in 0.2s ease;
}

.chat-msg.own {
  align-self: flex-end;
  background: var(--bg-msg-own);
  border-bottom-right-radius: 4px;
}

.chat-msg.other {
  align-self: flex-start;
  background: var(--bg-msg-other);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-name);
  margin-bottom: 2px;
}

.msg-text {
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-amount {
  display: inline-block;
  font-weight: 700;
  font-size: 15px;
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 4px;
}
.msg-amount.income { background: rgba(34, 197, 94, 0.15); color: var(--green-light); }
.msg-amount.expense { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* Reply block inside message */
.msg-reply {
  background: var(--bg-msg-reply);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 4px 10px;
  margin-bottom: 6px;
  font-size: 12px;
}
.msg-reply-author { font-weight: 700; color: var(--primary); }
.msg-reply-text {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

/* Message metadata */
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Files in message */
.msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.msg-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-input);
  border-radius: 6px;
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  transition: background 0.1s;
}
.msg-file:hover { background: var(--border); }
.msg-file-img {
  max-width: 240px;
  max-height: 180px;
  border-radius: 8px;
  cursor: pointer;
}

/* Message actions (bottom of message, on hover) */
.msg-actions {
  display: none;
  gap: 2px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.chat-msg:hover .msg-actions { display: flex; }
.msg-action-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; padding: 3px 8px; border-radius: 4px;
  color: var(--text-secondary);
  transition: all 0.1s;
}
.msg-action-btn:hover { background: var(--bg-input); color: var(--primary); }

/* Reply preview bar */
.reply-preview {
  display: flex;
  align-items: center;
  padding: 8px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  gap: 10px;
  font-size: 13px;
}
.reply-preview-content {
  flex: 1;
  border-left: 3px solid var(--primary);
  padding-left: 10px;
}
.reply-preview .reply-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-secondary);
}

/* Chat input area */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

.chat-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-input);
  border-radius: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.chat-input-wrap:focus-within {
  border-color: var(--primary);
}

.chat-input {
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 22px;
  max-height: 120px;
  outline: none;
  line-height: 1.4;
  width: 100%;
}

.chat-file-btn {
  background: none; border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.chat-file-btn svg {
  width: 24px;
  height: 24px;
}
.chat-file-btn:hover { color: var(--primary); }

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.chat-send-btn:hover { transform: scale(1.05); }
.chat-send-btn:disabled { opacity: 0.4; transform: none; }

/* File preview chips */
.file-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.file-chip-remove {
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--red); padding: 0 2px;
}

/* Date separator */
.chat-date-sep {
  text-align: center;
  padding: 12px 0 6px;
}
.chat-date-sep span {
  background: var(--bg-input);
  padding: 4px 14px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
