/* chatbot.css - Smooth single-motion shrink with mic button support */

:root {
  --bg: #0f172a;
  --panel: #0f172a;
  --border: #1e293b;
  --bubble: #1e293b;
  --user-bubble: #334155;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --text: #e2e8f0;
}

* { box-sizing: border-box; }

html, body, #root {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.container {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---------------- LEFT PANEL ---------------- */

.left {
  flex: 1 1 0%;
  min-width: 300px;
  background-color: var(--panel);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  transition:
    flex-basis 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.left.hidden {
  flex-basis: 27%;
  min-width: 210px;
  padding: 22px;
}

.left h1,
.left p {
  transform-origin: left center;
  transition:
    transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.4s ease;
}

.left.hidden h1 { transform: scale(0.72); opacity: 0.95; }
.left.hidden p  { transform: scale(0.85); opacity: 0.85; }

.left h1 {
  font-size: 2.2rem;
  margin: 0 0 6px;
  color: #ffffff;
  line-height: 1.05;
}

.left p {
  font-size: 1.05rem;
  line-height: 1.55;
  color: #cbd5e1;
  max-width: 680px;
  margin-top: 0;
}

/* ---------------- RIGHT PANEL ---------------- */

.right {
  flex: 1 1 0%;
  min-width: 350px;
  background-color: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 12px;
  min-height: 0;
  transition: flex-basis 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.right.expanded { flex-basis: 73%; }

/* ---------------- CHAT ---------------- */

#chatbox {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: 18px;
  background-color: #071028;
  border-radius: 10px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* MESSAGE ROW — full width, flex row */
.message {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  margin-bottom: 12px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bot: avatar left, bubble pushes right */
.message.bot  { justify-content: flex-start; }

/* User: bubble left of avatar, both pushed to right */
.message.user { justify-content: flex-end; }

/* AVATAR */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

/* BUBBLE WRAPPER: stacks text + timestamp vertically */
.bubble-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 68%;
}

.message.bot  .bubble-wrapper { align-items: flex-start; }
.message.user .bubble-wrapper { align-items: flex-end; }

/* TEXT BUBBLE */
.message .text {
  padding: 14px 16px;
  line-height: 1.5;
  border: 1px solid rgba(59, 130, 246, 0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  word-break: break-word;
  white-space: normal;
  background-color: var(--bubble);
}

.message.bot  .text { border-radius: 12px 12px 12px 4px; }
.message.user .text { border-radius: 12px 12px 4px 12px; background-color: var(--user-bubble); }

/* Markdown */
.message .text strong, .message .text b { color: #60a5fa; font-weight: 700; }
.message .text em, .message .text i     { color: #fbbf24; font-style: italic; }
.message .text code { background-color: rgba(0,0,0,0.3); color: #a5f3fc; padding: 3px 8px; border-radius: 4px; font-family: monospace; font-size: 0.95em; }
.message .text pre  { background-color: rgba(0,0,0,0.4); padding: 12px; border-radius: 6px; overflow-x: auto; margin: 10px 0; border-left: 4px solid #3b82f6; }
.message .text blockquote { border-left: 4px solid #3b82f6; padding-left: 16px; margin: 10px 0; color: #cbd5e1; font-style: italic; background-color: rgba(59,130,246,0.05); border-radius: 4px; }

/* ---------------- ATTACHMENTS (VISUAL RAG) ---------------- */

.attachments-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
  width: 100%;
}

.attachment-container {
  display: flex;
  flex-direction: column;
  background-color: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  max-width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.attachment-image {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  cursor: zoom-in;
  transition: transform 0.2s ease, filter 0.2s ease;
  object-fit: contain;
}

.attachment-image:hover {
  filter: brightness(1.05);
}

.attachment-meta {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attachment-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #f8fafc;
}

.attachment-source {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---------------- LIGHTBOX PREVIEW MODAL ---------------- */

.lightbox-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease-out;
}

.lightbox-content {
  max-width: 90%;
  max-height: 85%;
  border-radius: 8px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5);
  cursor: default;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 25px;
  color: #94a3b8;
  font-size: 2.5rem;
  font-weight: 300;
  cursor: pointer;
  transition: color 0.15s ease;
}

.lightbox-close:hover {
  color: #f8fafc;
}

.lightbox-caption {
  position: absolute;
  bottom: 30px;
  color: #cbd5e1;
  font-size: 0.95rem;
  text-align: center;
  width: 100%;
  padding: 0 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* TIMESTAMP */
.timestamp {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 4px;
  padding: 0 2px;
}

.message.bot  .timestamp { text-align: left; }
.message.user .timestamp { text-align: right; }

/* TYPING */
.message.typing .text { font-style: italic; opacity: 0.9; }
.typing-text::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 10px 0 0 var(--muted), 20px 0 0 var(--muted);
  animation: typing-dots 1s linear infinite;
}
@keyframes typing-dots {
  0%   { opacity: 0.2; }
  30%  { opacity: 1;   }
  60%  { opacity: 0.6; }
  100% { opacity: 0.2; }
}

/* ---------------- INPUT ---------------- */

.chat-input { display: flex; gap: 12px; align-items: center; }

#userInput {
  flex: 1;
  padding: 14px;
  font-size: 1rem;
  border: 1px solid #334155;
  border-radius: 8px;
  background-color: #061226;
  color: var(--text);
  outline: none;
  height: 45px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#userInput:focus { border-color: var(--accent); }

#sendBtn {
  padding: 12px 18px;
  font-size: 1rem;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
#sendBtn:hover  { background-color: #2563eb; }
#sendBtn:active { transform: scale(0.98); }

#logoutBtn {
  align-self: flex-end;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: #ef4444;
  color: white;
  cursor: pointer;
}

@media (max-width: 768px) {
  .container { flex-direction: column; }
  .left, .right { flex-basis: auto !important; min-width: 100%; border-left: none; border-top: 1px solid var(--border); }
}
