/* Chat Page Styles */

/* Override main-content flex direction */
.chat-page .main-content {
  overflow: hidden;
}

.chat-layout {
  display: flex;
  height: calc(100vh - 58px);
  overflow: hidden;
}

@media (min-width: 901px) {
  .chat-layout {
    height: 100vh;
  }
}

/* ── Conversations panel ─────────────── */
.conv-panel {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
}

.conv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.conv-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.btn-new-chat {
  width: 30px; height: 30px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.btn-new-chat:hover { background: var(--accent-dark); transform: scale(1.05); }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conv-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all var(--transition);
  position: relative;
}

.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--accent-glow); }

.conv-item-icon {
  width: 28px; height: 28px;
  background: var(--bg-elevated);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  color: var(--accent);
  flex-shrink: 0;
}

.conv-item-text { flex: 1; overflow: hidden; }
.conv-item-title {
  font-size: 0.83rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.conv-del {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  font-size: 0.8rem;
}

.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--accent); }

.login-gate {
  padding: 20px 16px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.login-gate a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ── Chat main ───────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Welcome ─────────────────────────── */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.welcome-logo { margin-bottom: 20px; }

.chat-welcome h2 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.chat-welcome p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 540px;
  width: 100%;
}

.quick-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-btn:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  color: var(--accent);
}

.quick-btn i { color: var(--accent); font-size: 0.85rem; }

/* ── Messages ────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.message {
  display: flex;
  gap: 12px;
  animation: msgIn 0.25s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 4px;
}

.message.assistant .msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--green-ma));
  color: white;
}

.message.user .msg-avatar {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.msg-content { max-width: 72%; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.91rem;
  line-height: 1.65;
  word-break: break-word;
}

.message.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
}

.message.user .msg-bubble {
  background: var(--accent);
  color: white;
  border-radius: 16px 4px 16px 16px;
}

.msg-bubble pre {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.msg-bubble code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(255,255,255,0.08);
  padding: 2px 5px;
  border-radius: 4px;
}

.msg-bubble pre code { background: none; padding: 0; }

.msg-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

.message.assistant .msg-time { text-align: left; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  width: fit-content;
}

.typing-dot {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ──────────────────────── */
.chat-input-wrap {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  background: var(--bg-surface);
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  align-self: center;
}

.login-prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.83rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.login-prompt i { color: var(--accent); }

.chat-input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 10px 10px 16px;
  transition: border-color var(--transition);
}

.chat-input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#chatInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.92rem;
  resize: none;
  max-height: 160px;
  line-height: 1.5;
  padding: 4px 0;
}

#chatInput::placeholder { color: var(--text-muted); }

.send-btn {
  width: 38px; height: 38px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: all var(--transition);
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .conv-panel { display: none; }
  .chat-messages { padding: 16px 14px; }
  .quick-prompts { grid-template-columns: 1fr; }
  .msg-content { max-width: 85%; }
}

/* ── Chat Rich Cards ─────────────────── */
.chat-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

/* Job cards */
.chat-job-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
}

.chat-job-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateX(3px);
}

.cjc-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--bg-card), var(--bg-hover));
  border: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.cjc-body { flex: 1; min-width: 0; }

.cjc-title {
  font-size: 0.87rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.cjc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.cjc-meta span { display: flex; align-items: center; gap: 3px; }
.cjc-meta i { color: var(--accent); font-size: 0.7rem; }

.cjc-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}

.badge-green { background: rgba(0,168,84,0.15); color: #00a854; }
.badge-blue  { background: rgba(96,165,250,0.15); color: #60a5fa; }
.badge-yellow{ background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-red   { background: rgba(230,57,70,0.15); color: var(--accent); }
.badge-gray  { background: var(--bg-elevated); color: var(--text-secondary); }

/* Marketplace cards */
.chat-market-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition);
}

.chat-market-card:hover {
  border-color: var(--accent);
  transform: translateX(3px);
}

.cmc-img {
  width: 56px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.cmc-img-placeholder {
  width: 56px; height: 44px;
  border-radius: 8px;
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.cmc-body { flex: 1; min-width: 0; }
.cmc-title { font-size: 0.84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmc-price { font-size: 0.88rem; font-weight: 700; color: var(--accent); margin: 2px 0; }
.cmc-loc   { font-size: 0.73rem; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }
.cmc-loc i { font-size: 0.68rem; }

/* "See all" link */
.chat-see-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  background: rgba(230,57,70,0.07);
  border: 1px dashed rgba(230,57,70,0.3);
  border-radius: 10px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition);
}

.chat-see-all:hover {
  background: rgba(230,57,70,0.12);
  border-style: solid;
}
