/* app/assets/stylesheets/ai_chat.css
   BRES AI Chat — full-page layout with sidebar
   Loaded only on AI chat pages via content_for :head
*/

/* ── Shell ───────────────────────────────────────────────── */
.bres-ai-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #F7F9FC;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.bres-ai-sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #111827;
  color: #E5E7EB;
  padding: 0;
  overflow: hidden;
}

.bres-ai-sidebar-header {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.bres-ai-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
}

.bres-ai-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem .75rem;
  background: rgba(198,167,86,.15);
  border: 1px solid rgba(198,167,86,.3);
  border-radius: .5rem;
  color: #C6A756;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
  text-decoration: none;
}
.bres-ai-new-btn:hover { background: rgba(198,167,86,.25); }

.bres-ai-session-list {
  flex: 1;
  overflow-y: auto;
  padding: .5rem;
}

.bres-ai-session-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem;
  border-radius: .5rem;
  color: #9CA3AF;
  font-size: .78rem;
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: .15rem;
}
.bres-ai-session-item span { overflow: hidden; text-overflow: ellipsis; }
.bres-ai-session-item:hover { background: rgba(255,255,255,.06); color: #E5E7EB; }
.bres-ai-session-item.active { background: rgba(198,167,86,.12); color: #C6A756; }
.bres-ai-session-item svg { flex-shrink: 0; opacity: .5; }
.bres-ai-session-item.active svg { opacity: 1; }

.bres-ai-sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
}

.bres-ai-context-badge {
  display: inline-flex;
  align-items: center;
  padding: .25rem .65rem;
  background: rgba(255,255,255,.06);
  border-radius: 9999px;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #6B7280;
}
.bres-ai-context-badge.admin { background: rgba(239,68,68,.1); color: #F87171; }

/* ── Main area ───────────────────────────────────────────── */
.bres-ai-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bres-ai-header {
  padding: 1.25rem 2rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,.06);
  background: white;
  flex-shrink: 0;
}
.bres-ai-title {
  font-size: 1rem;
  font-weight: 700;
  color: #111;
  margin: 0;
  letter-spacing: -.02em;
}
.bres-ai-subtitle {
  font-size: .72rem;
  color: #9CA3AF;
  margin: .15rem 0 0;
}

/* ── Messages ────────────────────────────────────────────── */
.bres-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

/* Empty state */
.bres-ai-empty {
  text-align: center;
  margin: auto;
  max-width: 420px;
  padding: 2rem 1rem;
}
.bres-ai-empty-icon {
  width: 64px; height: 64px;
  background: white;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  color: #C6A756;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.bres-ai-empty-title {
  font-size: 1.1rem; font-weight: 700; color: #111;
  letter-spacing: -.02em; margin: 0 0 .4rem;
}
.bres-ai-empty-lead {
  font-size: .82rem; color: #888; line-height: 1.7; margin: 0 0 1.5rem;
}
.bres-ai-suggestions {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center;
}
.bres-ai-suggestion {
  padding: .45rem .9rem;
  background: white;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.bres-ai-suggestion:hover {
  border-color: #C6A756;
  color: #C6A756;
  background: rgba(198,167,86,.04);
}

/* Message bubbles */
.bres-ai-msg {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  max-width: 820px;
  width: 100%;
}
.bres-ai-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.bres-ai-msg--user .bres-ai-msg-content {
  background: #111827;
  color: white;
  border-radius: 1rem 1rem 0 1rem;
}
.bres-ai-msg--assistant .bres-ai-msg-content {
  background: white;
  border: 1px solid rgba(0,0,0,.07);
  border-radius: 1rem 1rem 1rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.bres-ai-msg-avatar {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
}
.bres-ai-msg--user .bres-ai-msg-avatar {
  background: #111827;
  color: white;
}
.bres-ai-msg--assistant .bres-ai-msg-avatar {
  background: linear-gradient(135deg, #C6A756, #a88632);
  color: white;
}

.bres-ai-msg-body { display: flex; flex-direction: column; gap: .4rem; flex: 1; min-width: 0; }

.bres-ai-msg-content {
  padding: .75rem 1rem;
  font-size: .875rem;
  line-height: 1.75;
  color: #111;
  word-wrap: break-word;
}
.bres-ai-msg-content p { margin: 0 0 .5rem; }
.bres-ai-msg-content p:last-child { margin: 0; }

/* Citations */
.bres-ai-citations {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: 0 .2rem;
}
.bres-ai-citation-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .55rem;
  background: rgba(198,167,86,.08);
  border: 1px solid rgba(198,167,86,.2);
  border-radius: 9999px;
  font-size: .65rem;
  color: #7a6430;
}
.bres-ai-citation-chip em { color: #aaa; font-style: normal; }

.bres-ai-msg-meta {
  display: flex;
  gap: .75rem;
  font-size: .65rem;
  color: #bbb;
  padding: 0 .2rem;
}

/* Typing indicator */
.bres-ai-typing .bres-ai-msg-content {
  padding: .65rem 1rem;
  display: flex;
  gap: .3rem;
  align-items: center;
}
.bres-ai-dot {
  width: 7px; height: 7px;
  background: #C6A756;
  border-radius: 50%;
  animation: bres-ai-bounce 1.2s infinite;
}
.bres-ai-dot:nth-child(2) { animation-delay: .2s; }
.bres-ai-dot:nth-child(3) { animation-delay: .4s; }
@keyframes bres-ai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* Stream target */
.bres-ai-stream-target {
  font-size: .875rem;
  line-height: 1.75;
  color: #111;
  padding: 0 .2rem;
  white-space: pre-wrap;
}

/* ── Input bar ───────────────────────────────────────────── */
.bres-ai-input-bar {
  padding: 1rem 2rem 1.25rem;
  background: white;
  border-top: 1px solid rgba(0,0,0,.06);
  flex-shrink: 0;
}
.bres-ai-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  background: #F7F9FC;
  border: 1.5px solid rgba(0,0,0,.1);
  border-radius: 1rem;
  padding: .5rem .5rem .5rem .85rem;
  transition: border-color .2s;
}
.bres-ai-input-wrap:focus-within { border-color: #C6A756; }

.bres-ai-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-size: .875rem;
  line-height: 1.6;
  color: #111;
  max-height: 160px;
  overflow-y: auto;
  font-family: inherit;
  padding: .25rem 0;
}
.bres-ai-input::placeholder { color: #aaa; }

.bres-ai-send-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  background: #111827;
  border: none;
  border-radius: .625rem;
  display: flex; align-items: center; justify-content: center;
  color: white;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.bres-ai-send-btn:hover { background: #C6A756; }

.bres-ai-disclaimer {
  font-size: .67rem;
  color: #ccc;
  margin: .5rem 0 0;
  text-align: center;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .bres-ai-sidebar { display: none; }
  .bres-ai-messages { padding: 1rem; }
  .bres-ai-input-bar { padding: .75rem 1rem 1rem; }
  .bres-ai-header { padding: 1rem; }
}
