/* ==========================================================================
   NTU AI ASSISTANT - MONOCHROME CHAT WORKSPACE (chat.css)
   Clean, Minimalist & High-Contrast Chat Layout
   ========================================================================== */

.chat-app-container {
  display: flex;
  height: calc(100vh - var(--header-height));
  margin-top: var(--header-height);
  position: relative;
  overflow: hidden;
  background-color: var(--bg-main);
}

/* ==========================================================================
   CHAT SIDEBAR
   ========================================================================== */
.chat-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  position: relative;
}

.chat-sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.new-chat-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.new-chat-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.sidebar-search {
  position: relative;
}
.sidebar-search input {
  width: 100%;
  padding: 0.55rem 0.8rem 0.55rem 2.2rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.84rem;
  transition: all 0.2s ease;
}
.sidebar-search input:focus {
  outline: none;
  border-color: var(--text-main);
}
.sidebar-search i {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.82rem;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  border: 1px solid transparent;
  font-size: 0.88rem;
}

.conversation-item:hover {
  background: var(--bg-glass);
  color: var(--text-main);
  border-color: var(--border-color);
}

.conversation-item.active {
  background: var(--bg-card);
  border-color: var(--border-hover);
  color: var(--text-main);
  font-weight: 600;
}

.conv-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-actions {
  display: none;
  align-items: center;
  gap: 0.35rem;
}

.conversation-item:hover .conv-actions,
.conversation-item.active .conv-actions {
  display: flex;
}

.conv-action-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  transition: all 0.2s ease;
}
.conv-action-btn:hover {
  color: var(--text-main);
}
.conv-action-btn.btn-delete:hover {
  color: var(--danger);
}

/* ==========================================================================
   MAIN CHAT WORKSPACE
   ========================================================================== */
.chat-main {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-main);
}

.chat-header {
  height: 60px;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  z-index: 10;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.active-conv-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  max-width: 400px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toggle-sidebar-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
}

/* ==========================================================================
   CHAT MESSAGES AREA
   ========================================================================== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

.message-row {
  display: flex;
  gap: 1rem;
  width: 100%;
  animation: messageFadeIn 0.25s ease;
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.message-row.user .message-avatar {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

.message-content-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.message-row.user .message-content-wrap {
  align-items: flex-end;
}

.message-bubble {
  padding: 1.1rem 1.35rem;
  border-radius: var(--radius-lg);
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--text-main);
  position: relative;
  word-break: break-word;
}

.message-row.assistant .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top-left-radius: var(--radius-sm);
}

.message-row.user .message-bubble {
  background: var(--primary);
  color: var(--primary-text);
  border-top-right-radius: var(--radius-sm);
  font-weight: 500;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.message-actions-inline {
  display: flex;
  gap: 0.35rem;
}

.msg-btn-mini {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  transition: color 0.15s ease;
}
.msg-btn-mini:hover {
  color: var(--text-main);
}

/* ==========================================================================
   CODE BLOCKS & MARKDOWN IN CHAT
   ========================================================================== */
.code-block-wrapper {
  margin: 1rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #000000;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.copy-code-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 0.72rem;
  cursor: pointer;
}
.copy-code-btn:hover {
  color: #ffffff;
  border-color: #ffffff;
}

.code-block-wrapper pre {
  padding: 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
  color: #e4e4e7;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
}

/* ==========================================================================
   TYPING INDICATOR
   ========================================================================== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
}

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

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

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

/* ==========================================================================
   QUICK PROMPTS BAR (CAPSULES)
   ========================================================================== */
.quick-prompts-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.6rem 1.5rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

.prompt-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.prompt-chip:hover {
  background: var(--bg-surface);
  border-color: var(--border-hover);
  color: var(--text-main);
  transform: translateY(-1px);
}

/* ==========================================================================
   CHAT INPUT AREA
   ========================================================================== */
.chat-input-area {
  padding: 0.85rem 1.5rem 1.25rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

.attachment-preview-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.attachment-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  color: var(--text-main);
}

.remove-attach {
  cursor: pointer;
  color: var(--text-dim);
}
.remove-attach:hover {
  color: var(--danger);
}

.chat-input-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}

.chat-input-box:focus-within {
  border-color: var(--text-main);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.chat-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-main);
  font-size: 0.94rem;
  color: var(--text-main);
  resize: none;
  max-height: 150px;
  line-height: 1.5;
}

.chat-input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tool-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.tool-btn:hover {
  color: var(--text-main);
  background: var(--bg-glass);
}
.tool-btn.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}
.send-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: scale(1.05);
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .chat-app-container {
    height: calc(100vh - var(--header-height) - 58px);
  }
  .chat-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    box-shadow: 8px 0 25px rgba(0, 0, 0, 0.4);
    z-index: 1000;
  }
  .chat-sidebar.open {
    transform: translateX(0);
  }
  .chat-messages {
    padding: 1rem 0.85rem;
  }
  .message-content-wrap {
    max-width: 90%;
  }
  .message-bubble {
    padding: 0.85rem 1.1rem;
    font-size: 0.9rem;
  }
  .chat-input-area {
    padding: 0.4rem 0.65rem 0.65rem;
  }
  .d-none-sm {
    display: none !important;
  }
}
