/* Vibhum Assistant — full-screen light theme */

:root {
  --bg-base: #ffffff;
  --bg-subtle: #f9fafb;
  --bg-elevated: #ffffff;
  --bg-hover: #f3f4f6;
  --bg-input: #f4f4f5;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --accent: #6d28d9;
  --accent-hover: #5b21b6;
  --accent-soft: rgba(109, 40, 217, 0.08);
  --accent-glow: rgba(109, 40, 217, 0.12);
  --user-bg: #f3f4f6;
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --max-chat: 48rem;
  --header-h: 56px;
  --sidebar-w: 260px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  color-scheme: light;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 40% at 50% -10%, rgba(109, 40, 217, 0.06), transparent),
    radial-gradient(ellipse 50% 30% at 100% 100%, rgba(99, 102, 241, 0.04), transparent);
  z-index: 0;
}

/* ── Layout: sidebar + main ── */
.layout {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-base);
}

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Sidebar backdrop (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.35);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.sidebar-backdrop.visible {
  display: block;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-height: 0;
}

.layout.sidebar-closed .sidebar {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 10px;
  flex-shrink: 0;
}

.btn-new-chat {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-new-chat:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-open-sidebar {
  display: none;
  margin-right: 4px;
}

.layout.sidebar-closed .btn-open-sidebar {
  display: inline-flex;
}

.sidebar-label {
  padding: 4px 14px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.chat-list::-webkit-scrollbar {
  width: 5px;
}

.chat-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.chat-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 2px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chat-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.chat-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.chat-item-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-date {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-list-empty {
  padding: 16px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

@media (max-width: 768px) {
  .layout:not(.sidebar-closed) .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    width: min(var(--sidebar-w), 85vw);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    display: flex;
  }
}

/* Logo — preserve aspect ratio (wide logo, never stretch) */
.logo-frame {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.logo-frame--header {
  height: 28px;
  max-width: 130px;
}

.logo-frame--welcome {
  height: 44px;
  max-width: 200px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.logo-frame--sm {
  height: 24px;
  max-width: 80px;
  padding: 2px 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.logo-img {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
  display: block;
}

/* ── Header ── */
.header {
  flex-shrink: 0;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  height: 100%;
  padding: 0 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-text h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header-text p {
  margin: 1px 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Messages ── */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  background: var(--bg-subtle);
}

.messages-inner {
  max-width: var(--max-chat);
  margin: 0 auto;
  padding: 32px 24px 48px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

/* Welcome */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 16px;
  min-height: min(70vh, 520px);
}

.welcome-logo {
  margin-bottom: 28px;
}

.welcome h2 {
  margin: 0 0 12px;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}

.welcome .welcome-lead {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 440px;
  font-weight: 500;
}

.welcome .welcome-sub {
  margin: 0 0 32px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 420px;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

@media (max-width: 480px) {
  .suggestions {
    grid-template-columns: 1fr;
  }
}

.suggestion {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.suggestion:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 2px 8px var(--accent-soft);
}

/* Messages */
.message {
  display: flex;
  gap: 14px;
  padding: 20px 0;
  animation: fadeIn 0.3s ease;
  width: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  flex-direction: row-reverse;
}

.message .avatar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  margin-top: 2px;
}

.message.user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  align-items: center;
  justify-content: center;
}

.message.bot .avatar {
  padding: 0;
  background: none;
  border: none;
}

.bubble {
  flex: 1;
  min-width: 0;
  line-height: 1.65;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  max-width: 85%;
  margin-left: auto;
  padding: 12px 16px;
  background: var(--user-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.message.bot .bubble {
  color: var(--text);
  padding: 2px 0;
  white-space: normal;
}

.message.bot .bubble a {
  color: var(--accent);
  text-decoration: none;
}

.message.bot .bubble a:hover {
  text-decoration: underline;
}

.message.bot .bubble strong {
  font-weight: 600;
}

.message.bot .bubble h1,
.message.bot .bubble h2,
.message.bot .bubble h3,
.message.bot .bubble h4,
.message.bot .bubble h5,
.message.bot .bubble h6 {
  margin: 0 0 8px;
  font-weight: 600;
  line-height: 1.35;
}

.message.bot .bubble h1 {
  font-size: 1.25rem;
}

.message.bot .bubble h2 {
  font-size: 1.15rem;
}

.message.bot .bubble h3 {
  font-size: 1.05rem;
}

.message.bot .bubble p {
  margin: 0 0 10px;
}

.message.bot .bubble p:last-child,
.message.bot .bubble ul:last-child,
.message.bot .bubble ol:last-child {
  margin-bottom: 0;
}

.message.bot .bubble ul,
.message.bot .bubble ol {
  margin: 8px 0;
  padding-left: 1.25rem;
}

.message.bot .bubble li + li {
  margin-top: 4px;
}

.message.typing .bubble {
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: none;
}

.typing .bubble span {
  display: block;
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  background: var(--text-muted);
  border-radius: 50%;
  opacity: 0.45;
  animation: typing-pulse 1.4s ease-in-out infinite;
}

.typing .bubble span:nth-child(1) {
  animation-delay: 0s;
}

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

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

@keyframes typing-pulse {
  0%,
  70%,
  100% {
    opacity: 0.35;
    transform: scale(0.9);
  }

  35% {
    opacity: 0.9;
    transform: scale(1);
  }
}

/* ── Composer ── */
.composer {
  flex-shrink: 0;
  padding: 16px 20px 20px;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
}

.composer-wrap {
  max-width: var(--max-chat);
  margin: 0 auto;
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 12px 14px 12px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer-inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  max-height: 200px;
  outline: none;
  color: var(--text);
}

.composer textarea::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.footer-note {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 12px 0 0;
}

.footer-note a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-note a:hover {
  color: var(--accent);
}

.error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #fef2f2;
  color: #b91c1c;
  padding: 10px 20px;
  font-size: 0.85rem;
  border-bottom: 1px solid #fecaca;
  display: none;
}

.error-banner.visible {
  display: block;
}

.layout.has-error .header {
  margin-top: 40px;
}

.layout.has-error.sidebar-closed .header {
  margin-top: 40px;
}
