/* Lightning Design System look: SLDS colour tokens, spacing and components, written by hand (no SLDS CSS bundle). */

:root {
  --brand: #0176d3;            /* color-brand-base-50 */
  --brand-dark: #014486;       /* color-brand-base-30 */
  --brand-darker: #032d60;
  --brand-band: #1b96ff;
  --page-bg: #f3f3f3;
  --card-bg: #ffffff;
  --border: #e5e5e5;
  --input-border: #c9c9c9;
  --text: #181818;
  --text-weak: #444444;
  --text-placeholder: #747474;
  --inbound-bg: #f3f3f3;
  --outbound-bg: #0176d3;
  --domain-bg: #ebf7e6;
  --domain-border: #91db8b;
  --success: #2e844a;
  --error: #ba0517;
  --error-bg: #fef1ee;
  --focus-ring: 0 0 3px #0176d3;
  --radius: 0.25rem;
  --card-radius: 0.25rem;
  --shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.1);
  font-family: "Salesforce Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
}

/* --- Global header and app navigation ---------------------------------------------------------------------------- */

.global-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 3.125rem;
  padding: 0 1rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.global-header__logo { height: 2.25rem; width: auto; }
.global-header__app { font-size: 1.125rem; font-weight: 400; color: var(--text); }

.app-nav {
  display: flex;
  align-items: stretch;
  height: 2.5rem;
  padding: 0 1rem;
  background: #ffffff;
  border-bottom: 3px solid var(--brand);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.12);
  position: relative;
  z-index: 1;
}

.app-nav__tab {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
}

.app-nav__tab.is-active {
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--brand);
  background: #f3f9ff;
}

/* The light-blue band behind the top of the page, as in Lightning Experience. */
.brand-band {
  position: absolute;
  top: calc(3.125rem + 2.5rem + 3px);
  left: 0;
  right: 0;
  height: 12rem;
  background: linear-gradient(180deg, #cfe9fe 0%, rgba(207, 233, 254, 0) 100%);
  pointer-events: none;
}

/* --- Page -------------------------------------------------------------------------------------------------------- */

.page {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
}

.page-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  padding: 1rem;
}

.page-header__title { display: flex; align-items: center; gap: 0.75rem; }
.page-header__actions { display: flex; align-items: center; }

.eyebrow { margin: 0; font-size: 0.75rem; color: var(--text-weak); }
h1 { margin: 0; font-size: 1.125rem; font-weight: 700; line-height: 1.25; }
h2 { margin: 0; font-size: 1rem; font-weight: 700; }

.page-header__details {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.page-header__details dt { font-size: 0.75rem; color: var(--text-weak); }
.page-header__details dd { margin: 0.125rem 0 0; font-size: 0.8125rem; }
.page-header__details code { font-family: inherit; }

/* Standard icons: white glyph on a coloured tile. */
.icon-tile {
  display: inline-flex;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
}

.icon-tile img { width: 100%; height: 100%; }
.icon-tile--agent-home { background: var(--brand-darker); }
.icon-tile--bot { background: #107cad; }
.icon-tile--user { background: #7f8de1; }
.icon-tile--domain { background: #ff5d2d; }
.icon-tile--small { width: 2rem; height: 2rem; border-radius: 50%; }

/* Utility icons are drawn as masks, so they take the button's text colour. */
.utility-icon {
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  margin-right: 0.5rem;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.utility-icon--send { --icon: url("assets/icon-send.svg"); }
.utility-icon--refresh { --icon: url("assets/icon-refresh.svg"); }

/* --- Buttons, badges, inputs ------------------------------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  padding: 0 1rem;
  font: inherit;
  font-size: 0.8125rem;
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid var(--input-border);
  cursor: pointer;
  white-space: nowrap;
}

.button--brand { background: var(--brand); border-color: var(--brand); color: #ffffff; }
.button--brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button--neutral { background: #ffffff; color: var(--brand); }
.button--neutral:hover { background: #f3f3f3; }
.button:disabled { background: #c9c9c9; border-color: #c9c9c9; color: #ffffff; cursor: default; }

.chip {
  height: 1.75rem;
  padding: 0 0.75rem;
  font: inherit;
  font-size: 0.75rem;
  color: var(--brand);
  background: #ffffff;
  border: 1px solid var(--input-border);
  border-radius: 1rem;
  cursor: pointer;
}

.chip:hover { background: #f3f9ff; border-color: var(--brand); }
.chip:disabled { color: #939393; background: #f3f3f3; border-color: var(--border); cursor: default; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 1rem;
}

.badge--success { background: var(--success); color: #ffffff; }

.input {
  flex: 1;
  min-width: 0;
  height: 2rem;
  padding: 0 0.75rem;
  font: inherit;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
}

.input::placeholder { color: var(--text-placeholder); }
.input:disabled { background: #f3f3f3; }

.button:focus-visible, .chip:focus-visible, .input:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

/* --- Chat card --------------------------------------------------------------------------------------------------- */

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 26rem;
}

.card__header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.card__subtitle { margin: 0.25rem 0 0; color: var(--text-weak); }

.chat-list {
  flex: 1;
  margin: 0;
  padding: 1rem;
  list-style: none;
  overflow-y: auto;
  max-height: calc(100vh - 25rem);
  min-height: 14rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-item { display: flex; align-items: flex-end; gap: 0.5rem; max-width: 80%; }
.chat-item--outbound { align-self: flex-end; flex-direction: row-reverse; }

.chat-item__body { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.chat-item--outbound .chat-item__body { align-items: flex-end; }

.chat-message {
  padding: 0.5rem 0.75rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-radius: 0.5rem 0.5rem 0.5rem 0;
  background: var(--inbound-bg);
}

.chat-item--outbound .chat-message {
  color: #ffffff;
  background: var(--outbound-bg);
  border-radius: 0.5rem 0.5rem 0 0.5rem;
}

.chat-item--domain .chat-message { background: var(--domain-bg); border: 1px solid var(--domain-border); }
.chat-item--error .chat-message { color: var(--error); background: var(--error-bg); border: 1px solid #fe9f8a; }

.chat-meta { font-size: 0.75rem; color: var(--text-weak); }

/* Typing indicator: three dots, as in the SLDS chat component. */
.typing { display: inline-flex; gap: 0.25rem; padding: 0.25rem 0; }
.typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #939393;
  animation: typing 1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .typing span { animation: none; opacity: 0.7; }
}

.card__footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: #fafaf9;
  border-radius: 0 0 var(--card-radius) var(--card-radius);
}

.suggestions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.composer { display: flex; gap: 0.5rem; }

.assistive-text {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

@media (max-width: 40rem) {
  .page-header { grid-template-columns: 1fr; }
  .chat-item { max-width: 95%; }
}
