/* ================================================================
   THEME — edit these to match your portfolio's visual identity
   ================================================================ */
:root {
  --bg:              #0a0a0a;
  --surface:         #111111;
  --surface-hover:   #3a3a3a;
  --border:          #3f3f3f;
  --primary:         #d693a3;
  --text:            #ececec;
  --text-muted:      #8e8ea0;
  --user-bubble-bg:  #111111;
  --bot-bubble-bg:   #141414;
  --input-bg:        #111111;
  --send-bg:         #ffffff;
  --send-icon:       #212121;
  --send-disabled:   #4a4a4a;
  --topbar-bg:       #111111;
  --topbar-border:   #3f3f3f;
  --radius-bubble:   18px;
  --radius-input:    16px;
  --font:            "IBM Plex Mono", monospace;
  --max-width:       760px;
}

/* ================================================================
   RESET
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ================================================================
   APP SHELL
   ================================================================ */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ================================================================
   TOPBAR
   ================================================================ */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  flex-shrink: 0;
}

#topbar-name {
  font-weight: 600;
  font-size: 16px;
  color: #d693a3;
}

#new-chat-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#new-chat-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ================================================================
   MESSAGES
   ================================================================ */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9999px; }

/* Empty state */
#empty-state {
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  user-select: none;
}

#empty-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

#empty-subtitle {
  font-size: 16px;
  color: var(--text-muted);
}

/* Message rows */
.message-row {
  display: flex;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

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

.message-row.bot {
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
}

/* Bubbles */
.bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-bubble);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.6;
}

.message-row.user .bubble {
  background: var(--user-bubble-bg);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.message-row.bot .bubble {
  background: var(--bot-bubble-bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
  max-width: 100%;
}

.message-row.error .bubble {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-radius: var(--radius-bubble);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 0;
}

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

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ================================================================
   INPUT BAR
   ================================================================ */
#input-bar {
  padding: 16px 20px 24px;
  flex-shrink: 0;
}

#input-wrap {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  display: flex;
  align-items: flex-end;
  padding: 12px 52px 12px 16px;
  transition: border-color 0.15s;
}

#input-wrap:focus-within {
  border-color: #6b6b6b;
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
}

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

#send-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: var(--send-bg);
  color: var(--send-icon);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.1s;
}

#send-btn:disabled {
  background: var(--send-disabled);
  cursor: default;
}

#send-btn:not(:disabled):hover  { opacity: 0.85; }
#send-btn:not(:disabled):active { transform: scale(0.93); }

#send-btn svg {
  width: 17px;
  height: 17px;
}

/* ================================================================
   CONTEXT PANEL
   ================================================================ */
.context-panel {
  max-width: 100%;
  margin-top: 8px;
}

.context-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}

.context-toggle::before {
  content: '▶';
  font-size: 9px;
  transition: transform 0.2s;
}

.context-toggle.open::before {
  transform: rotate(90deg);
}

.context-toggle:hover {
  color: var(--text);
}

.context-body {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.context-body.collapsed {
  display: none;
}

.context-section {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  overflow: hidden;
}

.context-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.context-section-text {
  font-family: var(--font);
  font-size: 13px;
  color: #a0a0a0;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.context-section-text::-webkit-scrollbar { width: 4px; }
.context-section-text::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9999px; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 600px) {
  #messages { padding: 20px 12px; }
  #input-bar { padding: 12px 12px 20px; }
  .bubble { max-width: 88%; }
}
