/* Professional counselor workbench UI. Loaded after the legacy base styles. */
:root {
  --wb-ink: #18211d;
  --wb-muted: #65706a;
  --wb-subtle: #89928d;
  --wb-line: #e0e6e2;
  --wb-line-strong: #cbd5cf;
  --wb-paper: #ffffff;
  --wb-sidebar: #f4f7f5;
  --wb-panel: #f8faf9;
  --wb-hover: #edf2ef;
  --wb-green: #21694f;
  --wb-green-hover: #19563f;
  --wb-green-soft: #e2eee8;
  --wb-blue: #315f86;
  --wb-blue-soft: #e5edf4;
  --wb-amber: #8a5b12;
  --wb-amber-soft: #f7ead0;
  --wb-red: #9b3838;
  --wb-red-soft: #f6e1e1;
}

body {
  background: var(--wb-paper);
  color: var(--wb-ink);
}

button,
input,
textarea {
  letter-spacing: 0;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.welcome-case:focus-visible {
  outline: 2px solid rgba(33, 105, 79, .28);
  outline-offset: 2px;
}

.app {
  grid-template-columns: 236px minmax(0, 1fr) 316px;
  background: var(--wb-paper);
}

/* Sidebar */
.sidebar {
  background: var(--wb-sidebar);
  border-right: 1px solid var(--wb-line);
}

.sidebar-top {
  padding: 15px 14px 14px;
  border-bottom: 1px solid var(--wb-line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.sidebar-brand img {
  width: 32px;
  height: 32px;
  border: 1px solid var(--wb-line-strong);
  border-radius: 50%;
  flex: 0 0 auto;
}

.sidebar-brand-title {
  color: var(--wb-ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.sidebar-brand-sub {
  color: var(--wb-muted);
  font-size: 11px;
  line-height: 1.25;
  margin-top: 2px;
}

.btn-new {
  height: 38px;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--wb-green);
  border-radius: 6px;
  background: var(--wb-green);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
}

.btn-new:hover {
  background: var(--wb-green-hover);
  border-color: var(--wb-green-hover);
}

.section-title {
  padding: 14px 14px 7px;
  color: var(--wb-subtle);
  font-size: 11px;
  font-weight: 650;
}

.history-list {
  padding: 0 8px 12px;
}

.history-item {
  min-height: 38px;
  margin: 2px 0;
  padding: 9px 10px;
  border-radius: 5px;
  color: var(--wb-muted);
}

.history-item::after {
  content: none;
}

.history-item:hover {
  background: var(--wb-hover);
  color: var(--wb-ink);
}

.history-item.active {
  background: var(--wb-green-soft);
  color: var(--wb-ink);
  box-shadow: inset 3px 0 var(--wb-green);
}

.history-item .title {
  font-size: 13px;
  font-weight: 550;
}

.history-item .actions {
  gap: 1px;
}

.history-item:hover .actions,
.history-item:focus-within .actions {
  opacity: .65;
}

.history-item .actions span {
  padding: 2px 4px;
}

.sidebar-bottom {
  padding: 11px 12px 14px;
  border-top: 1px solid var(--wb-line);
}

.sidebar-user {
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 5px;
  color: var(--wb-muted);
}

.sidebar-user:hover {
  background: var(--wb-hover);
}

.sidebar-user .avatar {
  width: 28px;
  height: 28px;
  background: var(--wb-green-soft);
  color: var(--wb-green);
  font-weight: 700;
}

.logout-btn {
  margin-top: 3px;
  padding: 7px 8px;
  border-radius: 5px;
  color: var(--wb-subtle);
  font-size: 12px;
}

.logout-btn:hover {
  background: var(--wb-hover);
  color: var(--wb-red);
}

/* Main work area */
.main {
  min-width: 0;
  background: var(--wb-paper);
}

.topbar {
  height: 58px;
  min-height: 58px;
  padding: 0 22px;
  gap: 12px;
  border-bottom: 1px solid var(--wb-line);
  background: #fff;
}

.topbar-copy {
  flex: 1;
  min-width: 0;
}

.topbar-title {
  display: block;
  overflow: hidden;
  color: var(--wb-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle,
.summary-toggle,
.insight-close {
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--wb-muted);
  cursor: pointer;
  font-family: inherit;
}

.menu-toggle {
  display: none;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 18px;
}

.summary-toggle {
  display: none;
  min-width: 64px;
  height: 32px;
  gap: 5px;
  padding: 0 9px;
  border-color: var(--wb-line);
  background: var(--wb-panel);
  font-size: 12px;
}

.menu-toggle:hover,
.summary-toggle:hover,
.insight-close:hover {
  border-color: var(--wb-line);
  background: var(--wb-hover);
  color: var(--wb-ink);
}

.messages {
  background: #fff;
}

/* Welcome and sample cases */
.welcome {
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  max-width: 820px;
  min-height: auto;
  margin: 0 auto;
  padding: 34px 28px 28px;
  text-align: left;
}

.welcome-kicker {
  margin-bottom: 5px;
  color: var(--wb-green);
  font-size: 11px;
  font-weight: 700;
}

.welcome h1 {
  margin-bottom: 3px;
  color: var(--wb-ink);
  font-size: 21px;
  font-weight: 750;
  line-height: 1.3;
}

.welcome .sub {
  margin-bottom: 20px;
  color: var(--wb-muted);
  font-size: 12px;
}

.welcome-cases {
  width: 100%;
  max-width: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.welcome-case {
  position: relative;
  min-width: 0;
  min-height: 76px;
  padding: 12px 34px 11px 12px;
  border: 1px solid var(--wb-line);
  border-radius: 6px;
  background: #fff;
  color: var(--wb-ink);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.welcome-case::after {
  content: "→";
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--wb-subtle);
  font-size: 13px;
}

.welcome-case:hover {
  border-color: var(--wb-line-strong);
  background: var(--wb-panel);
  box-shadow: 0 2px 8px rgba(24, 33, 29, .05);
}

.welcome-case .icon {
  display: none;
}

.welcome-case .label {
  display: block;
  overflow-wrap: anywhere;
  margin-bottom: 8px;
  color: var(--wb-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.welcome-case .desc {
  display: block;
  color: var(--wb-muted);
  font-size: 11px;
  line-height: 1.3;
}

/* Conversation document flow */
.msg {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--wb-line);
}

.msg.user {
  margin: 0;
  padding: 0;
  background: #f7f9f8;
}

.msg-group,
.msg.user .msg-group-inner {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 24px 20px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.msg:not(.user) .msg-group,
.msg.user .msg-group-inner {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.msg-label {
  margin-bottom: 7px;
  color: var(--wb-subtle);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.msg-content {
  color: var(--wb-ink);
  font-size: 15px;
  line-height: 1.72;
}

.msg-content h1,
.msg-content h2,
.msg-content h3,
.msg-content h4,
.msg-content h5 {
  color: var(--wb-ink);
}

.msg-content h2 {
  font-size: 16px;
  border-bottom-color: var(--wb-line);
}

.msg-content h3 {
  font-size: 15px;
}

.msg-content h4,
.msg-content h5 {
  color: var(--wb-muted);
  font-size: 14px;
}

.msg-content code,
.msg-content pre {
  background: #f3f6f4;
}

.msg-content blockquote {
  border-left-color: var(--wb-green);
  color: var(--wb-muted);
}

.typing-dots span {
  background: var(--wb-green);
}

.cursor {
  background: var(--wb-green);
}

.error-box {
  border-color: #e9c2c2;
  border-radius: 6px;
  background: var(--wb-red-soft);
  color: var(--wb-red);
}

.retry-btn {
  border-radius: 5px;
  background: var(--wb-red);
}

/* Composer */
.composer-wrap {
  flex: 0 0 auto;
  padding: 12px 24px 10px;
  border-top: 1px solid var(--wb-line);
  background: #fff;
}

.composer {
  width: 100%;
  max-width: 820px;
  min-height: 52px;
  margin: 0 auto;
  padding: 6px 7px 6px 14px;
  border: 1px solid var(--wb-line-strong);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(24, 33, 29, .05);
}

.composer:focus-within {
  border-color: var(--wb-green);
  box-shadow: 0 0 0 3px rgba(33, 105, 79, .10);
}

.composer textarea {
  min-width: 0;
  min-height: 38px;
  max-height: 180px;
  overflow-y: hidden;
  padding: 8px 0;
  color: var(--wb-ink);
  font-size: 15px;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: var(--wb-subtle);
}

.composer .send-btn {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--wb-green);
  font-size: 16px;
}

.composer .send-btn:hover:not(:disabled) {
  background: var(--wb-green-hover);
}

.composer .send-btn:disabled {
  background: var(--wb-line-strong);
}

.composer-footer {
  display: block;
  max-width: 820px;
  margin: 6px auto 0;
  color: var(--wb-subtle);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

/* Insight workspace */
.insight-panel {
  display: flex;
  min-width: 0;
  overflow: hidden;
  flex-direction: column;
  border-left: 1px solid var(--wb-line);
  background: var(--wb-panel);
}

.insight-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  min-height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--wb-line);
  background: #fff;
}

.insight-head strong {
  color: var(--wb-ink);
  font-size: 14px;
  font-weight: 700;
}

.insight-head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.insight-close {
  display: none;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 18px;
}

.status-pill {
  padding: 5px 7px;
  border: 1px solid var(--wb-line);
  border-radius: 4px;
  background: #fff;
  color: var(--wb-muted);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.status-pill.ok {
  border-color: #bfd6c9;
  background: var(--wb-green-soft);
  color: var(--wb-green);
}

.status-pill.warn {
  border-color: #ead4a6;
  background: var(--wb-amber-soft);
  color: var(--wb-amber);
}

.status-pill.danger {
  border-color: #e8c2c2;
  background: var(--wb-red-soft);
  color: var(--wb-red);
}

.insight-scroll {
  display: block;
  overflow-y: auto;
  padding: 0 16px 24px;
}

.panel-block {
  padding: 17px 0 18px;
  border: 0;
  border-bottom: 1px solid var(--wb-line);
  border-radius: 0;
  background: transparent;
}

.panel-block:last-child {
  border-bottom: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--wb-ink);
  font-size: 12px;
  font-weight: 750;
}

.assistant-summary {
  color: var(--wb-ink);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.65;
}

.insight-list {
  display: grid;
  gap: 8px;
}

.insight-item {
  position: relative;
  padding: 0 0 0 14px;
  border: 0;
  color: var(--wb-muted);
  font-size: 12px;
  line-height: 1.55;
}

.insight-item::before {
  content: "";
  position: absolute;
  top: .6em;
  left: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8db3a2;
}

/* Authentication modal */
.auth-overlay {
  background: rgba(24, 33, 29, .42);
  backdrop-filter: blur(3px);
}

.auth-card {
  max-width: 380px;
  padding: 28px;
  border: 1px solid var(--wb-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(24, 33, 29, .18);
}

.auth-card .logo {
  width: 48px;
  height: 48px;
  margin-bottom: 13px;
  border: 1px solid var(--wb-line);
}

.auth-card h1 {
  color: var(--wb-ink);
  font-size: 20px;
}

.auth-tabs {
  border-bottom-color: var(--wb-line);
}

.auth-tab.active {
  border-bottom-color: var(--wb-green);
  color: var(--wb-green);
}

.auth-field input {
  border-color: var(--wb-line-strong);
  border-radius: 6px;
}

.auth-field input:focus {
  border-color: var(--wb-green);
}

.auth-btn {
  border-radius: 6px;
  background: var(--wb-green);
}

.auth-btn:hover {
  background: var(--wb-green-hover);
}

.auth-close {
  color: var(--wb-muted);
}

.overlay {
  background: rgba(24, 33, 29, .34);
  backdrop-filter: blur(1px);
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: #c8cfcb;
}

::-webkit-scrollbar-thumb:hover {
  background: #aeb8b2;
}

/* Tablet: keep history visible, move insight into a drawer. */
@media (max-width: 1180px) {
  .app {
    grid-template-columns: 228px minmax(0, 1fr);
  }

  .summary-toggle {
    display: inline-flex;
  }

  .insight-panel {
    position: fixed;
    z-index: 120;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    box-shadow: -12px 0 32px rgba(24, 33, 29, .14);
    transform: translateX(102%);
    transition: transform .2s ease;
  }

  .insight-panel.open {
    transform: translateX(0);
  }

  .insight-close {
    display: inline-flex;
  }
}

/* Phone */
@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  .app {
    grid-template-columns: 1fr;
    width: 100vw;
    max-width: 100vw;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    z-index: 120;
    top: 0;
    bottom: 0;
    left: 0;
    width: 84%;
    max-width: 300px;
    box-shadow: 12px 0 32px rgba(24, 33, 29, .14);
    transform: translateX(-102%);
    transition: transform .2s ease;
  }

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

  .main,
  .messages,
  .welcome,
  .composer-wrap {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }

  .topbar {
    height: 54px;
    min-height: 54px;
    padding: 0 10px;
    gap: 8px;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar-title {
    font-size: 14px;
  }

  .summary-toggle {
    min-width: 52px;
    height: 32px;
    padding: 0 8px;
  }

  .welcome {
    padding: 24px 14px 18px;
  }

  .welcome-kicker {
    font-size: 10px;
  }

  .welcome h1 {
    font-size: 19px;
  }

  .welcome .sub {
    margin-bottom: 16px;
  }

  .welcome-cases {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .welcome-case {
    min-height: 74px;
    padding: 10px 28px 10px 10px;
  }

  .welcome-case::after {
    top: 10px;
    right: 9px;
  }

  .welcome-case .label {
    margin-bottom: 6px;
    font-size: 12px;
  }

  .welcome-case .desc {
    font-size: 10px;
  }

  .msg-group,
  .msg.user .msg-group-inner {
    padding: 15px 14px 17px;
  }

  .msg-content {
    font-size: 14px;
    line-height: 1.68;
  }

  .composer-wrap {
    padding: 9px 10px 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .composer {
    min-height: 48px;
    padding: 5px 6px 5px 11px;
  }

  .composer textarea {
    min-height: 34px;
    max-height: 112px;
    padding: 7px 0;
    font-size: 14px;
  }

  .composer .send-btn {
    width: 34px;
    height: 34px;
  }

  .composer-footer {
    display: none;
  }

  .insight-head {
    height: 54px;
    min-height: 54px;
  }

  .overlay.show {
    z-index: 110;
  }
}

@media (max-width: 380px) {
  .welcome-case {
    min-height: 70px;
  }

  .summary-toggle {
    min-width: 34px;
    width: 34px;
    padding: 0;
    font-size: 11px;
  }
}
