/* Scoped to embed container; parent sites should not style inside .hoc-chat unless intentional */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
}

.hoc-chat {
  --hoc-cream: #faf6f0;
  --hoc-warm-white: #fffefb;
  --hoc-beige: #ebe3d7;
  --hoc-cocoa: #4a3728;
  --hoc-brown: #6b5344;
  --hoc-milk: #8b7355;
  --hoc-accent: #c4a574;
  --hoc-user-bg: #5c4433;
  --hoc-user-fg: #faf6f0;
  --hoc-bot-bg: #ffffff;
  --hoc-bot-border: #e8dfd2;
  --hoc-shadow: 0 12px 40px rgba(74, 55, 40, 0.12);
  --hoc-radius-lg: 20px;
  --hoc-radius-md: 14px;
  --hoc-radius-pill: 999px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--hoc-cocoa);
  line-height: 1.45;
}

.hoc-chat__main {
  min-height: 100dvh;
  margin: 0;
  padding: clamp(0.75rem, 3vw, 1.5rem);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, var(--hoc-cream) 0%, #efe6db 45%, #e5d9cc 100%);
}

.hoc-chat__card {
  width: 100%;
  max-width: 420px;
  height: min(640px, calc(100dvh - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  display: flex;
  flex-direction: column;
  background: var(--hoc-warm-white);
  border-radius: var(--hoc-radius-lg);
  box-shadow: var(--hoc-shadow);
  border: 1px solid rgba(196, 165, 116, 0.25);
  overflow: hidden;
}

.hoc-chat__header {
  flex-shrink: 0;
  padding: 1.25rem 1.25rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--hoc-beige);
  background: linear-gradient(180deg, #fffdfb 0%, var(--hoc-warm-white) 100%);
}

.hoc-chat__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--hoc-cocoa);
}

.hoc-chat__subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--hoc-milk);
  font-weight: 500;
}

.hoc-chat__transcript {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  gap: 0.65rem;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.hoc-chat__transcript::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.hoc-chat__msg-text {
  white-space: pre-line;
}

.hoc-chat__msg {
  max-width: 92%;
  padding: 0.7rem 0.95rem;
  border-radius: var(--hoc-radius-md);
  font-size: 0.88rem;
  animation: hocFadeIn 0.35s ease-out;
}

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

.hoc-chat__msg--bot {
  align-self: flex-start;
  text-align: left;
  background: var(--hoc-bot-bg);
  border: 1px solid var(--hoc-bot-border);
  color: var(--hoc-cocoa);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(74, 55, 40, 0.04);
}

.hoc-chat__msg--bot .hoc-chat__msg-text {
  text-align: left;
}

.hoc-chat__msg--user {
  align-self: flex-end;
  text-align: right;
  background: var(--hoc-user-bg);
  color: var(--hoc-user-fg);
  border-bottom-right-radius: 6px;
}

.hoc-chat__msg--user .hoc-chat__msg-text {
  text-align: right;
}

.hoc-chat__msg--summary {
  align-self: flex-start;
  text-align: left;
  background: linear-gradient(135deg, #fffefb 0%, #f5efe6 100%);
  border: 1px solid var(--hoc-accent);
  border-left: 3px solid var(--hoc-accent);
}

.hoc-chat__msg--summary .hoc-chat__msg-text {
  text-align: left;
}

.hoc-chat__summary-title {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hoc-brown);
}

.hoc-chat__summary-list {
  margin: 0;
  padding-left: 1.1rem;
}

.hoc-chat__summary-list li {
  margin-bottom: 0.25rem;
}

.hoc-chat__typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--hoc-bot-bg);
  border: 1px solid var(--hoc-bot-border);
  border-radius: var(--hoc-radius-md);
  border-bottom-left-radius: 6px;
  animation: hocFadeIn 0.25s ease-out;
}

.hoc-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hoc-milk);
  opacity: 0.45;
  animation: hocBounce 1.1s ease-in-out infinite;
}

.hoc-chat__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.hoc-chat__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes hocBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-4px);
    opacity: 0.85;
  }
}

.hoc-chat__toolbar {
  flex-shrink: 0;
  width: 100%;
  padding: 0.55rem 0.6rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  gap: 0.35rem;
  border-top: 1px solid var(--hoc-beige);
  background: var(--hoc-cream);
  min-height: 2.75rem;
  overflow-x: hidden;
}

.hoc-chat__chip {
  appearance: none;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 550;
  line-height: 1.25;
  padding: 0.32rem 0.45rem;
  border-radius: var(--hoc-radius-pill);
  border: 1px solid rgba(107, 83, 68, 0.35);
  background: #fffefb;
  color: var(--hoc-brown);
  cursor: pointer;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
}

.hoc-chat__chip:hover {
  background: #fff;
  border-color: var(--hoc-accent);
  box-shadow: 0 4px 14px rgba(74, 55, 40, 0.1);
  transform: translateY(-1px);
}

.hoc-chat__chip:active {
  transform: translateY(0);
}

.hoc-chat__chip:focus {
  outline: none;
}

.hoc-chat__chip:focus-visible {
  outline: 2px solid var(--hoc-cocoa);
  outline-offset: 3px;
}

.hoc-chat__chip--primary {
  background: var(--hoc-cocoa);
  color: var(--hoc-cream);
  border-color: var(--hoc-cocoa);
}

.hoc-chat__chip--primary:hover {
  background: var(--hoc-brown);
  border-color: var(--hoc-brown);
  color: var(--hoc-warm-white);
}

@media (max-width: 380px) {
  .hoc-chat__chip {
    font-size: 0.64rem;
    padding: 0.28rem 0.45rem;
  }
}
