/* Chat emil motion + shell-pro integration */

:root {
  --chat-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Shell-pro: same topbar as Wallet / VELA ── */
body.chat-shell-pro {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
}

body.chat-shell-pro #chat-topbar {
  display: none;
}

body.chat-shell-pro #chat-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.chat-shell-pro #chat-layout-pro {
  flex: 1;
  min-height: 0;
}

/* Mobile: compact app header */
@media (max-width: 1023px) {
  #chat-topbar {
    display: flex;
  }
  #chat-workspace-head {
    display: none;
  }
}

@media (min-width: 1024px) {
  #chat-workspace-head {
    display: flex;
  }
}

/* ── Workspace head (inside main column) ── */
#chat-workspace-head {
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--s1);
}

.chat-workspace-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-1);
}

.chat-workspace-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* ── 3-column grid ── */
@media (min-width: 1024px) {
  #chat-layout-pro {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 260px;
    min-height: 0;
  }

  #chat-sidebar-pro,
  #chat-context-pro {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  #chat-main {
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 1023px) {
  #chat-layout-pro {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  #chat-sidebar-pro,
  #chat-context-pro {
    display: none;
  }
}

/* ── Sidebar ── */
.chat-sidebar-head {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.chat-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-sidebar-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-sidebar-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-1);
}

.chat-new-btn {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--brand-ink, #1A1A2E);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms var(--chat-ease-out), filter 160ms ease;
}

.chat-new-btn:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .chat-new-btn:hover {
    filter: brightness(1.06);
  }
}

.chat-search-wrap {
  display: block;
}

.chat-search {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-md);
  background: var(--s1);
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 160ms ease;
}

.chat-search:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-color: var(--brand-primary);
}

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

#chat-sidebar-pro .session-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition:
    transform 140ms var(--chat-ease-out),
    background 160ms ease,
    border-color 160ms ease;
}

#chat-sidebar-pro .session-item:active {
  transform: scale(0.98);
}

#chat-sidebar-pro .session-item.active,
#chat-sidebar-pro .session-item:hover {
  background: var(--s1);
  border-color: var(--border);
  color: var(--text-1);
}

#chat-sidebar-pro {
  background: var(--s2);
  border-right: 1px solid var(--border);
}

#chat-context-pro {
  border-left: 1px solid var(--border);
  background: var(--s1);
  padding: 14px;
  overflow-y: auto;
  gap: 10px;
}

/* ── Context cards ── */
.chat-pro-context-card {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-bottom: 0;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-pro-context-kicker {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-primary);
}

.chat-pro-context-card strong {
  display: block;
  color: var(--text-1);
  font-size: 14px;
  margin: 0;
}

.chat-pro-context-copy {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-3);
  text-wrap: pretty;
}

.chat-context-btn {
  margin-top: 4px;
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms var(--chat-ease-out), filter 160ms ease, background 160ms ease;
}

.chat-context-btn:active {
  transform: scale(0.97);
}

.chat-context-btn--primary {
  border: none;
  background: var(--brand-primary);
  color: #fff;
}

.chat-context-btn--ghost {
  border: 1px solid var(--border-md);
  background: var(--s1);
  color: var(--text-1);
}

@media (hover: hover) and (pointer: fine) {
  .chat-context-btn--primary:hover {
    filter: brightness(1.05);
  }
  .chat-context-btn--ghost:hover {
    background: var(--brand-primary-dim);
  }
}

/* ── Emil interaction fixes ── */
.chip,
.mode-btn,
.intent-cta-btn,
.upgrade-card-btn,
#send-btn {
  transition:
    transform 140ms var(--chat-ease-out),
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
}

.chip:active,
.mode-btn:active,
.intent-cta-btn:active,
.upgrade-card-btn:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover {
    transform: translateY(-1px);
  }
}

.q-bar-fill {
  transition: width 280ms var(--chat-ease-out);
}

/* Message enter — functional, short */
@keyframes chatBubbleIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

body.chat-motion-ready .msg-row {
  animation: chatBubbleIn 220ms var(--chat-ease-out) both;
}

/* First paint workspace */
@keyframes chatWorkspaceIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

body.chat-motion-ready #chat-sidebar-pro {
  animation: chatWorkspaceIn 240ms var(--chat-ease-out) forwards;
}

body.chat-motion-ready #chat-main {
  animation: chatWorkspaceIn 260ms var(--chat-ease-out) 40ms forwards;
  opacity: 0;
}

body.chat-motion-ready #chat-context-pro {
  animation: chatWorkspaceIn 240ms var(--chat-ease-out) 80ms forwards;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  body.chat-motion-ready #chat-sidebar-pro,
  body.chat-motion-ready #chat-main,
  body.chat-motion-ready #chat-context-pro,
  body.chat-motion-ready .msg-row {
    animation: none;
    opacity: 1;
  }

  .chip,
  .mode-btn,
  #send-btn {
    transition: none;
  }
}
