/* Trang trợ lý định giá */

.va-body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

.va-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
}

/* ===== Sidebar ===== */
.va-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.va-sidebar-head {
  display: flex;
  align-items: center;
}

.va-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--teal-strong);
  font-weight: 500;
  text-decoration: none;
  font-size: 0.9rem;
}

.va-back svg {
  width: 18px;
  height: 18px;
}

.va-new-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  font-weight: 500;
}

.va-new-btn:hover {
  background: var(--soft);
}

.va-new-btn svg {
  width: 18px;
  height: 18px;
}

.va-user-scope {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fffdf9;
}

.va-user-kicker {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.va-user-scope strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.va-user-scope small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.va-session-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 2px;
}

.va-session-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: left;
  background: #fffdf9;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.va-session-item:hover {
  border-color: var(--line);
}

.va-session-item.is-active {
  border-color: var(--teal);
  background: var(--blue-soft);
}

.va-session-title {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.va-session-time {
  color: var(--muted);
  font-size: 0.74rem;
}

.va-sidebar-foot {
  display: flex;
  justify-content: center;
}

/* ===== Main ===== */
.va-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  background: var(--page);
}

.va-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 239, 232, 0.92);
  backdrop-filter: blur(10px);
}

.va-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.va-title h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.15;
}

.va-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#vaMenuToggle {
  display: none;
}

.va-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px clamp(16px, 6vw, 120px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.va-message {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: start;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.va-message.user {
  grid-template-columns: 1fr 38px;
}

.va-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  overflow: hidden;
  border-radius: 999px;
  color: var(--ink);
  background: #efe8dc url("assets/guide-avatar.jpg") center 28% / cover;
  font-size: 0.62rem;
  font-weight: 500;
}

.va-message:not(.user) .va-avatar svg {
  opacity: 0;
}

.va-avatar svg {
  width: 20px;
  height: 20px;
}

.va-message.user .va-avatar {
  grid-column: 2;
  grid-row: 1;
  color: var(--ink);
  background: #efe8dc;
}

.va-bubble {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--ink);
  background: #fffdf9;
  line-height: 1.55;
  overflow-x: auto;
  overflow-wrap: anywhere;
}

.va-bubble .response-paragraph {
  margin: 0 0 10px;
}

.va-bubble .response-paragraph:last-child {
  margin-bottom: 0;
}

.va-bubble .report-heading {
  margin: 14px 0 8px;
  color: var(--teal-strong);
  font-size: 0.84rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.va-bubble .chat-table {
  margin: 8px 0 12px;
  min-width: 620px;
  border: 1px solid var(--line);
  table-layout: fixed;
}

.va-bubble .chat-table th,
.va-bubble .chat-table td {
  padding: 9px 10px;
  overflow-wrap: anywhere;
}

.va-bubble .summary-table tbody th,
.va-bubble .chat-table tbody th {
  width: 38%;
  color: var(--teal-strong);
  font-size: 0.8rem;
  text-transform: none;
}

.factor-sign {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 600;
}

.factor-sign.up {
  color: #155b34;
  background: #dff2e5;
}

.factor-sign.down {
  color: #8b342a;
  background: #ffe2dc;
}

.va-bubble .suggestion-table thead th {
  width: auto;
  color: var(--muted);
  background: #f7f3ec;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.va-bubble .suggestion-table tbody th {
  width: 34%;
}

.report-note {
  margin-top: 12px;
  border-left: 3px solid var(--teal);
  padding: 8px 10px;
  color: var(--ink);
  background: var(--soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.va-bubble .report-list {
  margin-top: 6px;
}

.va-message.user .va-bubble {
  grid-column: 1;
  grid-row: 1;
  border-color: var(--line-strong);
  background: var(--soft);
}

.va-intro {
  max-width: 720px;
  margin: auto;
  text-align: center;
  color: var(--muted);
}

.va-intro-portrait {
  display: block;
  width: 132px;
  height: 132px;
  margin: 0 auto 16px;
  object-fit: cover;
  object-position: center 28%;
  border-radius: 36px;
}

.va-intro h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.4rem;
}

.va-intro p {
  margin: 0 0 20px;
  line-height: 1.5;
}

.va-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.va-chips button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--teal-strong);
  background: #fffdf9;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.va-chips button:hover {
  border-color: var(--teal);
  background: var(--blue-soft);
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--teal);
  animation: typing-dot 1s infinite ease-in-out;
}

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

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

.typing-label {
  color: var(--muted);
  font-size: 0.86rem;
}

/* ===== Composer ===== */
.va-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px clamp(16px, 6vw, 120px);
  border-top: 1px solid var(--line);
  background: #fffdf9;
}

.va-chat-form textarea {
  flex: 1 1 auto;
  min-height: 48px;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fffdf9;
  line-height: 1.45;
  outline: none;
}

.va-chat-form textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 93, 78, 0.16);
}

.va-chat-form .primary-button {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 12px;
}

.va-chat-form .primary-button svg {
  width: 20px;
  height: 20px;
}

/* ===== Mobile ===== */
@media (max-width: 860px) {
  .va-shell {
    grid-template-columns: 1fr;
  }

  .va-sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 18px 40px rgba(36, 48, 43, 0.16);
  }

  .va-sidebar.is-open {
    transform: translateX(0);
  }

  #vaMenuToggle {
    display: inline-flex;
  }

  .va-bubble .suggestion-table tbody th {
    width: 40%;
  }
}

@keyframes typing-dot {
  0%,
  80%,
  100% {
    opacity: 0.45;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.va-body.va-embedded {
  height: 100vh;
  background: transparent;
}

.va-body.va-embedded .va-shell {
  grid-template-columns: 220px minmax(0, 1fr);
  height: 100vh;
}

.va-body.va-embedded .va-sidebar {
  gap: 10px;
  padding: 12px;
}

.va-body.va-embedded .va-back {
  display: none;
}

.va-body.va-embedded .va-new-btn {
  min-height: 40px;
}

.va-body.va-embedded .va-main {
  height: 100vh;
}

.va-body.va-embedded .va-topbar {
  min-height: 58px;
  padding: 10px 12px;
}

.va-body.va-embedded .va-title {
  gap: 10px;
}

.va-body.va-embedded .va-title .brand-mark {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.va-body.va-embedded .va-title h1 {
  font-size: 0.96rem;
}

.va-body.va-embedded .va-title p {
  font-size: 0.76rem;
}

.va-body.va-embedded .va-chat-log {
  gap: 12px;
  padding: 12px;
}

.va-body.va-embedded .va-message {
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  max-width: 100%;
}

.va-body.va-embedded .va-message.user {
  grid-template-columns: minmax(0, 1fr) 30px;
}

.va-body.va-embedded .va-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  font-size: 0.62rem;
}

.va-body.va-embedded .va-avatar svg {
  width: 17px;
  height: 17px;
}

.va-body.va-embedded .va-bubble {
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.86rem;
  line-height: 1.48;
}

.va-body.va-embedded .va-bubble .chat-table {
  min-width: 540px;
  font-size: 0.8rem;
}

.va-body.va-embedded .va-bubble .chat-table th,
.va-body.va-embedded .va-bubble .chat-table td {
  padding: 8px;
}

.va-body.va-embedded .va-chat-form {
  gap: 8px;
  padding: 10px 12px;
}

.va-body.va-embedded .va-chat-form textarea {
  min-height: 42px;
  max-height: 112px;
  border-radius: var(--radius);
  padding: 10px 12px;
}

.va-body.va-embedded .va-chat-form .primary-button {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
}

.va-body.va-embedded .va-intro {
  max-width: 520px;
}

.va-body.va-embedded .va-intro h2 {
  font-size: 1.12rem;
}

.va-body.va-embedded .va-chips {
  grid-template-columns: 1fr;
}

@media (max-width: 860px) {
  .va-body.va-embedded .va-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .va-body.va-embedded .va-sidebar {
    position: static;
    width: auto;
    transform: none;
    box-shadow: none;
  }

  .va-body.va-embedded #vaMenuToggle {
    display: none;
  }
}

@media (max-width: 640px) {
  .va-body.va-embedded .va-shell {
    grid-template-columns: 1fr;
  }

  .va-body.va-embedded .va-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(280px, calc(100vw - 52px));
    transform: translateX(-100%);
    box-shadow: 0 18px 40px rgba(36, 48, 43, 0.16);
  }

  .va-body.va-embedded .va-sidebar.is-open {
    transform: translateX(0);
  }

  .va-body.va-embedded #vaMenuToggle {
    display: inline-flex;
  }

  .va-body.va-embedded .va-bubble .chat-table {
    min-width: 500px;
  }
}
