/* TADA design tokens — aligned with src/index.css */
:root {
  --background: hsl(210 20% 98%);
  --foreground: hsl(220 20% 10%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(220 20% 10%);
  --primary: hsl(217 91% 60%);
  --primary-foreground: hsl(210 40% 98%);
  --secondary: hsl(210 40% 96.1%);
  --secondary-foreground: hsl(222.2 47.4% 11.2%);
  --muted: hsl(210 40% 96.1%);
  --muted-foreground: hsl(215.4 16.3% 46.9%);
  --accent: hsl(210 40% 96.1%);
  --border: hsl(214.3 31.8% 91.4%);
  --input: hsl(214.3 31.8% 91.4%);
  --ring: hsl(217 91% 60%);
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.06);

  /* Legacy aliases used by demo page */
  --bg: var(--background);
  --sidebar: hsl(220 20% 18%);
  --sidebar-text: hsl(210 40% 96%);
  --accent-legacy: var(--primary);
  --text: var(--foreground);
  --muted-legacy: var(--muted-foreground);

  font-family: "Geist", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav-item {
  display: block;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 0.45rem 0.75rem;
  border-radius: 0.5rem;
  opacity: 0.85;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

.demo-badge {
  margin-top: auto;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fbbf24;
}

.main {
  padding: 1.5rem 2rem 2rem;
  max-width: 900px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.employee-switch {
  font-size: 0.9rem;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.employee-switch select {
  min-width: 220px;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: white;
}

.hero h1 {
  margin: 0 0 0.25rem;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted-foreground);
  font-size: 1.1rem;
}

.chat-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.chat-panel .messages {
  min-height: 320px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.messages {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--primary-foreground);
  border-bottom-right-radius: 0.25rem;
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--muted);
  border-bottom-left-radius: 0.25rem;
}

.bubble.assistant.rich {
  white-space: normal;
}

.bubble.assistant.rich p {
  margin: 0 0 0.5rem;
}

.bubble.assistant.rich p:last-child {
  margin-bottom: 0;
}

.bubble.assistant.rich .section-title {
  font-weight: 600;
  color: var(--foreground);
  margin-top: 0.25rem;
}

.bubble.assistant.rich ul {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.25rem;
}

.bubble.assistant.rich li {
  margin-bottom: 0.35rem;
}

.bubble.assistant.rich li strong {
  color: var(--foreground);
}

.bubble.assistant.rich li.sub {
  margin-left: 0.75rem;
  color: var(--muted-foreground);
  font-size: 0.95em;
}

.stream-status {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  animation: stream-status-pulse 1.4s ease-in-out infinite;
}

.stream-content:empty {
  display: none;
}

@keyframes stream-status-pulse {
  0%,
  100% {
    opacity: 0.55;
  }

  50% {
    opacity: 1;
  }
}

.write-approval-host {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin-bottom: 0.375rem;
  overflow: visible;
}

.write-approval-card {
  position: relative;
  width: fit-content;
  min-width: 11.5rem;
  max-width: 100%;
  overflow: visible;
  border: 1px solid hsl(142 45% 88%);
  border-radius: 0.5rem;
  background: linear-gradient(135deg, hsl(0 0% 100%) 0%, hsl(142 40% 98%) 100%);
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.04);
  animation: write-approval-enter 0.3s ease-out;
}

.write-approval-card--loading {
  background: hsl(0 0% 100%);
}

.write-approval-card--success {
  border-color: hsl(142 45% 88%);
}

.write-approval-deco {
  display: none;
}

.write-approval-body {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem 0.625rem 0.875rem;
  overflow: visible;
}

.write-approval-icon-wrap {
  position: relative;
  flex-shrink: 0;
  width: 2.625rem;
  height: 2.625rem;
  overflow: visible;
}

.write-approval-sparkles {
  display: none;
}

.write-approval-sparkle {
  position: absolute;
  color: hsl(142 55% 72%);
  font-size: 0.625rem;
  line-height: 1;
  opacity: 0;
}

.write-approval-card--success .write-approval-sparkle {
  animation: write-sparkle-pop 0.5s ease forwards;
}

.write-approval-sparkle--a {
  top: 0;
  left: 0;
  animation-delay: 0.05s;
}

.write-approval-sparkle--b {
  bottom: 0;
  right: 0;
  animation-delay: 0.12s;
}

.write-approval-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.625rem;
  height: 2.625rem;
  background: transparent;
  color: hsl(142 64% 41%);
  box-shadow: none;
  overflow: visible;
}

.write-approval-card--loading .write-approval-icon {
  width: 2.125rem;
  height: 2.125rem;
  background: hsl(210 40% 96%);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.write-approval-card--success .write-approval-icon {
  animation: write-icon-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.write-approval-check svg,
.write-approval-check-svg {
  width: 1.75rem;
  height: 1.75rem;
  display: block;
  overflow: visible;
}

.write-approval-card--success .write-approval-check-mark {
  stroke-dasharray: 16;
  stroke-dashoffset: 16;
  animation: write-check-draw 0.45s ease 0.08s forwards;
}

.write-approval-card--success .write-approval-check-ring {
  stroke-dasharray: 42 8;
  stroke-dashoffset: 50;
  animation: write-ring-draw 0.4s ease forwards;
}

.write-approval-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid hsl(214 31.8% 91.4%);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: ep-spin 0.65s linear infinite;
}

.write-approval-title {
  margin: 0;
  padding-right: 0.125rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: hsl(220 25% 12%);
  white-space: nowrap;
}

@keyframes write-ring-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes write-check-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes write-approval-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes write-icon-pop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes write-sparkle-pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.bubble.tool {
  align-self: flex-start;
  font-size: 0.8rem;
  color: var(--muted-foreground);
  background: #fffbeb;
  border: 1px dashed #fcd34d;
}

.chat-form {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--secondary);
}

.chat-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  font: inherit;
}

.chat-form button {
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: 0.65rem;
  padding: 0 1.25rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status {
  margin-top: 0.75rem;
  min-height: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

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

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .demo-badge {
    margin-top: 0;
  }
}

/* ── Employee Portal embed (/ep) — TADA Chat UX ── */

html.ep-html,
body.ep-product {
  height: 100%;
  margin: 0;
}

.ep-product {
  background: var(--background);
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ep-product [hidden] {
  display: none !important;
}

.ep-shell {
  flex: 1;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.875rem 1rem 0.625rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ep-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.ep-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.ep-brand-mark {
  display: flex;
  line-height: 0;
}

.ep-brand-text {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--foreground);
}

.ep-employee-badge {
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(100%, 16rem);
}

.ep-hero {
  margin-bottom: 0.625rem;
  flex-shrink: 0;
}

.ep-hero h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.ep-subtitle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted-foreground);
}

.ep-sparkle {
  color: var(--primary);
  flex-shrink: 0;
}

.ep-chat {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ep-chat-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-height: 0;
}

.ep-shortcuts {
  padding: 1rem 1rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.ep-shortcuts-label {
  margin: 0 0 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.ep-messages {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

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

.ep-messages::-webkit-scrollbar-thumb {
  background: hsl(214 31.8% 85%);
  border-radius: 999px;
}

.message-row {
  display: flex;
  gap: 0.625rem;
  animation: ep-fade-in 0.2s ease-out;
}

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

.message-row.assistant {
  justify-content: flex-start;
  align-items: flex-start;
}

.ep-assistant-avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: hsl(217 91% 95%);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.125rem;
}

.ep-assistant-avatar svg {
  width: 0.875rem;
  height: 0.875rem;
}

.message-row.user .bubble {
  max-width: 80%;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 1rem;
  border-top-right-radius: 0.25rem;
  background: var(--primary);
  color: var(--primary-foreground);
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row.assistant .bubble.rich {
  overflow: visible;
}

.message-row.assistant .bubble.rich .write-approval-host {
  width: 100%;
}

.message-row.assistant .bubble {
  max-width: 100%;
  flex: 1;
  min-width: 0;
  padding: 0;
  background: transparent;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--foreground);
}

.message-row.assistant .bubble.rich p {
  margin: 0 0 0.5rem;
  line-height: 1.5;
}

.message-row.assistant .bubble.rich p:last-child {
  margin-bottom: 0;
}

.message-row.assistant .bubble.rich .section-title {
  font-weight: 600;
  color: var(--foreground);
  margin-top: 0.5rem;
}

.message-row.assistant .bubble.rich .section-title:first-child {
  margin-top: 0;
}

.message-row.assistant .bubble.rich ul {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.25rem;
  list-style: disc;
}

.message-row.assistant .bubble.rich li {
  margin-bottom: 0.25rem;
  color: var(--foreground);
}

.message-row.assistant .bubble.rich li.sub {
  margin-left: 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.9375em;
}

.message-row.assistant .bubble.rich li strong,
.message-row.assistant .bubble.rich strong {
  font-weight: 600;
  color: var(--foreground);
}

.ep-busy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem 0.75rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.ep-busy-spinner {
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid hsl(214 31.8% 91.4%);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: ep-spin 0.7s linear infinite;
}

.ep-composer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.ep-composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 0.375rem;
  padding: 0.375rem 0.375rem 0.375rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ep-composer-inner:focus-within {
  border-color: hsl(217 91% 75%);
  box-shadow: 0 0 0 3px hsl(217 91% 60% / 0.12);
}

.ep-composer textarea {
  flex: 1;
  min-height: 2rem;
  max-height: 10rem;
  padding: 0.375rem 0;
  border: none;
  background: transparent;
  resize: none;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.35;
  color: var(--foreground);
  outline: none;
}

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

.ep-send {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.ep-send:hover:not(:disabled) {
  background: hsl(217 91% 54%);
}

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

.ep-send-icon {
  display: block;
}

.ep-send-spinner {
  display: none;
  animation: ep-spin 0.7s linear infinite;
}

.ep-send.is-busy .ep-send-icon {
  display: none;
}

.ep-send.is-busy .ep-send-spinner {
  display: block;
}

.ep-status {
  margin: 0.375rem 0 0;
  min-height: 0;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  text-align: center;
  flex-shrink: 0;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  padding-bottom: 1rem;
}

.quick-actions button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.quick-actions button:hover {
  background: var(--muted);
  border-color: hsl(214 31.8% 85%);
}

.quick-actions button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.quick-actions .qa-icon {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: var(--primary);
}

@keyframes ep-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ep-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 480px) {
  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .ep-shell {
    padding: 0.75rem 0.75rem 1rem;
  }

  .ep-header {
    flex-wrap: wrap;
  }

  .ep-employee-badge {
    max-width: 100%;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }
}

/* Legacy embed class hooks (demo page compatibility) */
.layout.embed-layout {
  display: block;
  min-height: 100vh;
}

.embed-main {
  max-width: none;
  padding: 1rem 1.25rem 1.5rem;
}

.embed-topbar {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.brand-inline {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--foreground);
}

.employee-label {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.embed-hero h1 {
  font-size: 1.5rem;
}

.embed-hero .subtitle {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.embed-chat .messages {
  min-height: 280px;
  max-height: 58vh;
}
