/* Pastword Chat UI — uses landing page design tokens from theme.css */
/* Imported alongside theme.css so all --tokens are available */

:root {
  --chat-sidebar-w: 280px;
  --chat-radius: 1rem;
  --chat-radius-sm: 0.5rem;
}

body.chat-body {
  background: var(--bg-dark);
  color: var(--fg);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.chat-sidebar {
  width: var(--chat-sidebar-w);
  min-width: var(--chat-sidebar-w);
  background: var(--bg-mid);
  border-right: 1px solid #3a3530;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #3a3530;
}
.sidebar-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: #F7F3EE;
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
}
.sidebar-tagline {
  font-size: 0.75rem;
  color: var(--fg-light);
  font-style: italic;
  font-family: var(--font-display);
}

.sidebar-actions {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-bottom: 1px solid #3a3530;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: var(--chat-radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; }

.btn-primary {
  background: var(--accent);
  color: #F7F3EE;
}
.btn-ghost {
  background: transparent;
  color: #A0998F;
  border: 1px solid #3a3530;
}
.btn-ghost:hover { color: #F7F3EE; }

.sidebar-sessions-label {
  padding: 0.75rem 1.25rem 0.5rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-light);
  font-weight: 500;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem;
}

.session-item {
  padding: 0.65rem 0.75rem;
  border-radius: var(--chat-radius-sm);
  cursor: pointer;
  margin-bottom: 0.25rem;
  transition: background 0.15s;
}
.session-item:hover { background: rgba(255,255,255,0.05); }
.session-item.active { background: rgba(163,98,27,0.25); }

.session-title {
  font-size: 0.875rem;
  color: #E8E2D8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}
.session-meta {
  font-size: 0.72rem;
  color: var(--fg-light);
}
.session-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--fg-light);
  font-size: 0.85rem;
  font-style: italic;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #3a3530;
}

/* ===== MAIN CHAT ===== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.chat-topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #2A2520;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}
.chat-topbar-title {
  font-family: var(--font-display);
  font-size: 1rem;
  color: #F7F3EE;
}
.context-badge {
  font-size: 0.72rem;
  color: var(--accent-warm);
  background: rgba(200,148,74,0.1);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(200,148,74,0.2);
}

/* Messages area */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.msg-welcome {
  text-align: center;
  padding: 3rem 2rem;
  color: #8B8078;
}
.msg-welcome-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
  opacity: 0.6;
}
.msg-welcome h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: #A0998F;
  margin-bottom: 0.75rem;
}
.msg-welcome p {
  font-size: 0.9rem;
  line-height: 1.7;
  max-width: 400px;
  margin: 0 auto 1.5rem;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 680px;
}
.chat-message.user { align-self: flex-end; align-items: flex-end; }
.chat-message.past-self { align-self: flex-start; align-items: flex-start; }

.msg-role-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 0 0.5rem;
}
.chat-message.user .msg-role-label { color: #6B6459; }
.chat-message.past-self .msg-role-label { color: var(--accent-warm); }

.msg-content {
  padding: 0.9rem 1.25rem;
  border-radius: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 85%;
}
.chat-message.user .msg-content {
  background: #3a3530;
  color: #F7F3EE;
  border-bottom-right-radius: 0.25rem;
}
.chat-message.past-self .msg-content {
  background: #2E2925;
  color: #E8E2D8;
  border-bottom-left-radius: 0.25rem;
  border: 1px solid #3a3530;
}

.msg-time {
  font-size: 0.68rem;
  color: var(--fg-light);
  padding: 0 0.5rem;
}

.msg-typing {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.9rem 1.25rem;
  background: #2E2925;
  border-radius: 1rem;
  border-bottom-left-radius: 0.25rem;
  width: fit-content;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-warm);
  border-radius: 50%;
  animation: pulse 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ===== INPUT ===== */
.chat-input-area {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid #2A2520;
  background: var(--bg-dark);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: var(--bg-mid);
  border: 1px solid #3a3530;
  border-radius: var(--chat-radius);
  padding: 0.75rem 1rem;
  transition: border-color 0.2s;
}
.chat-input-wrapper:focus-within {
  border-color: var(--accent-warm);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #F7F3EE;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
}
.chat-textarea::placeholder { color: var(--fg-light); }

.btn-send {
  background: var(--accent);
  color: #F7F3EE;
  border: none;
  border-radius: 0.75rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.btn-send:hover { opacity: 0.85; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== UPLOAD MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }

.upload-modal {
  background: var(--bg-dark);
  border: 1px solid #3a3530;
  border-radius: var(--chat-radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: #F7F3EE;
  margin-bottom: 0.5rem;
}
.modal-desc {
  font-size: 0.875rem;
  color: var(--fg-light);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.drop-zone {
  border: 2px dashed #3a3530;
  border-radius: var(--chat-radius-sm);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 1rem;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent-warm);
  background: rgba(200,148,74,0.05);
}
.drop-zone-icon { margin-bottom: 1rem; opacity: 0.5; }
.drop-zone p { font-size: 0.875rem; color: var(--fg-light); }
.drop-zone strong { color: var(--accent-warm); }
.drop-zone input[type="file"] { display: none; }

.upload-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-mid);
  border-radius: var(--chat-radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.upload-preview-name {
  font-size: 0.875rem;
  color: #E8E2D8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}
.upload-preview-size {
  font-size: 0.75rem;
  color: var(--fg-light);
  margin-left: 0.75rem;
  flex-shrink: 0;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.source-input {
  width: 100%;
  background: var(--bg-mid);
  border: 1px solid #3a3530;
  border-radius: var(--chat-radius-sm);
  padding: 0.65rem 0.85rem;
  color: #F7F3EE;
  font-family: var(--font-body);
  font-size: 0.875rem;
  outline: none;
  margin-bottom: 1rem;
}
.source-input:focus { border-color: var(--accent-warm); }
.source-input::placeholder { color: var(--fg-light); }

.form-label {
  font-size: 0.8rem;
  color: var(--fg-light);
  margin-bottom: 0.4rem;
  display: block;
}

.upload-progress {
  height: 2px;
  background: #3a3530;
  border-radius: 1px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  background: var(--accent-warm);
  width: 0%;
  transition: width 0.3s ease;
}

/* ===== CONTEXT PANEL ===== */
.context-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-mid);
  border-left: 1px solid #3a3530;
  padding: 1.5rem;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 150;
}
.context-panel.open { transform: translateX(0); }
.context-panel-title {
  font-family: var(--font-display);
  font-size: 1rem;
  color: #F7F3EE;
  margin-bottom: 1rem;
}
.context-chunk {
  background: #252220;
  border-radius: var(--chat-radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid #3a3530;
}
.context-chunk-text {
  font-size: 0.82rem;
  color: #A0998F;
  line-height: 1.6;
}
.context-chunk-meta {
  font-size: 0.7rem;
  color: var(--fg-light);
  margin-top: 0.4rem;
}

/* Scrollbar */
.chat-sidebar ::-webkit-scrollbar,
.messages-container ::-webkit-scrollbar { width: 4px; }
.chat-sidebar ::-webkit-scrollbar-thumb,
.messages-container ::-webkit-scrollbar-thumb {
  background: #3a3530;
  border-radius: 2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  body.chat-body { flex-direction: column; }
  .chat-sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid #3a3530;
  }
  .chat-main { height: 60vh; }
}