/* Chat Specific Glassmorphism and Layout Styles */

.chat-container {
  display: flex;
  height: calc(100vh - var(--space-8, 64px));
  max-height: 1000px;
  background: var(--bg-card, rgba(18, 24, 38, 0.6));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-xl, 16px);
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  margin-top: var(--space-3, 12px);
}

/* Chat Session Sidebar */
.chat-sidebar {
  width: 280px;
  min-width: 260px;
  background: rgba(13, 17, 28, 0.7);
  border-right: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
}

.new-chat-btn svg {
  width: 18px;
  height: 18px;
}

.session-list-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #94a3b8);
  margin-top: 8px;
  margin-bottom: 4px;
  padding-left: 8px;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary, #cbd5e1);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.session-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: #ffffff;
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 500;
}

.session-title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-title-text svg {
  width: 15px;
  height: 15px;
  opacity: 0.7;
  flex-shrink: 0;
}

.session-del-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  opacity: 0;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-item:hover .session-del-btn {
  opacity: 1;
}

.session-del-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

/* Chat Main Workspace */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(10, 14, 23, 0.4);
  position: relative;
  min-width: 0;
}

.chat-header {
  height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 24, 38, 0.4);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.local-llm-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #10b981;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.local-llm-badge .pulse-dot {
  width: 6px;
  height: 6px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  color: var(--text-muted, #94a3b8);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Chat Messages Feed */
.messages-feed {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 20px;
  margin: auto;
  max-width: 650px;
}

.welcome-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.welcome-icon-wrap svg {
  width: 34px;
  height: 34px;
  color: #818cf8;
}

.welcome-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
}

.welcome-desc {
  font-size: 0.92rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.6;
  margin-bottom: 28px;
}

.suggestion-chips {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

@media (max-width: 600px) {
  .suggestion-chips {
    grid-template-columns: 1fr;
  }
}

.chip-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary, #cbd5e1);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chip-item:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
  color: #ffffff;
}

.chip-title {
  font-weight: 600;
  color: #818cf8;
}

/* Message Bubble */
.msg-row {
  display: flex;
  gap: 14px;
  max-width: 85%;
  animation: fadeInMsg 0.25s ease-out forwards;
}

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

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

.msg-row.assistant {
  align-self: flex-start;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.85rem;
}

.msg-row.user .avatar {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
}

.msg-row.assistant .avatar {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #ffffff;
}

.msg-content-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.65;
  color: #e2e8f0;
}

.msg-row.user .msg-bubble {
  background: #312e81;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(49, 46, 129, 0.3);
}

.msg-row.assistant .msg-bubble {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Markdown formatting inside bubble */
.msg-bubble p {
  margin: 0 0 8px 0;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble code {
  font-family: var(--font-mono, monospace);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.84rem;
  color: #a5b4fc;
}

.msg-bubble pre {
  margin: 10px 0;
  padding: 14px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow-x: auto;
  position: relative;
}

.msg-bubble pre code {
  background: transparent;
  padding: 0;
  color: #e2e8f0;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #cbd5e1;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.msg-meta {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.msg-row.user .msg-meta {
  justify-content: flex-end;
}

/* Input Area Dock */
.input-dock {
  padding: 16px 24px 20px 24px;
  background: rgba(18, 24, 38, 0.6);
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.input-box-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: rgba(10, 14, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-box-wrap:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.92rem;
  resize: none;
  max-height: 160px;
  min-height: 24px;
  line-height: 1.5;
}

.chat-textarea::placeholder {
  color: var(--text-muted, #64748b);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #6366f1;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #4f46e5;
  transform: scale(1.05);
}

.send-btn:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted, #64748b);
  cursor: not-allowed;
  transform: none;
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

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