/* ============================================================
   Claudia — Design System
   Baseline: aiscore dark navy (DESIGN-REFERENCE.md)
   ============================================================ */

:root {
  --bg:       #0c1029;
  --bg-card:  #131836;
  --border:   #252d54;
  --text:     #edf2f7;
  --text-dim: #a8b4cc;
  --pink:     #E91E7B;
  --cyan:     #00C8DC;
  --primary:  var(--pink);

  /* Chat-specific */
  --sidebar-w:    280px;
  --topbar-h:     56px;
  --msg-user-bg:  #1a2147;
  --msg-ai-bg:    #131836;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Exo', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Login page
   ============================================================ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-logo {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: .5rem;
}
.logo-text { color: var(--text); }
.logo-dot  { color: var(--pink); }

.login-tagline {
  color: var(--text-dim);
  font-size: .95rem;
  margin: 0 0 2rem;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  background: #fff;
  color: #3c4043;
  border: none;
  border-radius: 8px;
  padding: .75rem 1.5rem;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow .15s;
  width: 100%;
}
.btn-google:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  text-decoration: none;
}

.login-footer {
  margin-top: 1.5rem;
  font-size: .8rem;
  color: var(--text-dim);
}

.alert {
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: .9rem;
  text-align: left;
}
.alert-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
}

/* ============================================================
   Top navigation bar
   ============================================================ */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.5px;
}

.site-label {
  font-size: .85rem;
  color: var(--text-dim);
  padding: .3rem .75rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.site-switcher select {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .3rem .6rem;
  color: var(--text);
  font-family: 'Exo', sans-serif;
  font-size: .85rem;
  cursor: pointer;
}
.site-switcher select:focus { outline: none; border-color: var(--cyan); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-link {
  font-size: .85rem;
  color: var(--text-dim);
  transition: color .15s;
}
.topbar-link:hover { color: var(--cyan); text-decoration: none; }

.user-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-dim);
}

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* ============================================================
   App layout (sidebar + chat)
   ============================================================ */

.app-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--topbar-h);
}

/* ----- Sidebar ----- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem .75rem;
  overflow-y: auto;
}

.btn-new-chat {
  width: 100%;
  margin-bottom: 1rem;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
}

.conv-item {
  padding: .6rem .75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: .25rem;
}
.conv-item:hover { background: rgba(255,255,255,.05); }
.conv-item.active { background: rgba(0,200,220,.08); border: 1px solid rgba(0,200,220,.2); }

.conv-title {
  font-size: .85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-date {
  font-size: .72rem;
  color: var(--text-dim);
  margin-top: .2rem;
}

.conv-empty {
  font-size: .85rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 1rem;
}

/* ----- Chat area ----- */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Welcome screen */
.welcome-message {
  max-width: 600px;
  margin: 2rem auto;
  text-align: center;
}
.welcome-message h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0 0 .5rem;
}
.welcome-message p {
  color: var(--text-dim);
  margin: 0 0 1.5rem;
}

.capability-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
}

.chip {
  font-size: .78rem;
  padding: .25rem .75rem;
  background: rgba(0,200,220,.08);
  border: 1px solid rgba(0,200,220,.2);
  border-radius: 20px;
  color: var(--cyan);
}

/* Message bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

.message.user-message { align-items: flex-end; }
.message.ai-message   { align-items: flex-start; }

.message-bubble {
  padding: .85rem 1.1rem;
  border-radius: 12px;
  font-size: .95rem;
  line-height: 1.6;
  max-width: 100%;
  word-break: break-word;
}

.user-message .message-bubble {
  background: var(--msg-user-bg);
  border: 1px solid rgba(0,200,220,.15);
  border-bottom-right-radius: 4px;
}

.ai-message .message-bubble {
  background: var(--msg-ai-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Markdown-like formatting inside AI bubbles */
.message-bubble p  { margin: 0 0 .75rem; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { margin: 0 0 .75rem; padding-left: 1.5rem; }
.message-bubble li { margin-bottom: .25rem; }
.message-bubble code {
  background: rgba(0,0,0,.3);
  border-radius: 4px;
  padding: .1em .35em;
  font-size: .88em;
  font-family: 'Courier New', monospace;
}
.message-bubble pre {
  background: rgba(0,0,0,.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .85rem 1rem;
  overflow-x: auto;
  margin: .75rem 0;
}
.message-bubble pre code { background: none; padding: 0; font-size: .85em; }
.message-bubble strong { color: var(--cyan); }

/* Tool call message (shown inline) */
.tool-call-msg {
  font-size: .8rem;
  color: var(--text-dim);
  font-style: italic;
  padding: .3rem .6rem;
  background: rgba(255,255,255,.03);
  border-left: 2px solid var(--border);
  border-radius: 0 4px 4px 0;
  margin: .25rem 0;
  max-width: 780px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.5rem;
}
.typing-indicator span {
  width: 8px; height: 8px;
  background: var(--cyan);
  border-radius: 50%;
  animation: bounce .9s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* Tool banner */
.tool-banner {
  padding: .4rem 1.5rem;
  background: rgba(0,200,220,.06);
  border-top: 1px solid rgba(0,200,220,.15);
  font-size: .8rem;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.tool-banner::before {
  content: '⚙';
  font-size: .9rem;
}

/* Input area */
.input-area {
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem 1rem;
  transition: border-color .15s;
}
.input-wrapper:focus-within { border-color: var(--cyan); }

#user-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'Exo', sans-serif;
  font-size: .95rem;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
}
#user-input::placeholder { color: var(--text-dim); }

.btn-send {
  background: var(--pink);
  border: none;
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  flex-shrink: 0;
  transition: background .15s, opacity .15s;
}
.btn-send:hover    { background: #c4186a; }
.btn-send:disabled { opacity: .4; cursor: not-allowed; }

.input-hint {
  margin: .4rem 0 0;
  font-size: .73rem;
  color: var(--text-dim);
  text-align: right;
}

/* ============================================================
   Buttons (shared)
   ============================================================ */

.btn {
  border: none;
  border-radius: 8px;
  padding: .55rem 1.1rem;
  font-size: .88rem;
  font-weight: 600;
  font-family: 'Exo', sans-serif;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .85; }

.btn-primary {
  background: linear-gradient(135deg, var(--pink), #c4186a);
  color: #fff;
}

.btn-secondary {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: rgba(255,255,255,.1); opacity: 1; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar { display: none; }

  .messages { padding: 1rem; }
  .input-area { padding: .75rem 1rem 1rem; }
}
