/* ============================================================================
   Answers — chat history sidebar + header sign-in/account controls
   Slide-over panel inside the phone-width chat card (see answers-webchat.css
   for .answers-chat), following the same design tokens as the rest of the app.
   ========================================================================== */

/* Depends on design-tokens.css being <link>ed first (no @import:
   imported URLs can't carry the ?v= cache-busting version the HTML uses). */
.answers-chat {
  position: relative; /* anchors the absolutely-positioned history panel */
}

/* ---- Header controls (right side, after title) --------------------------- */
.answers-header__controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.answers-header__history-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ans-blue-500);
  cursor: pointer;
}
/* `display: flex` above otherwise wins over the UA stylesheet's
   `[hidden] { display: none }` (author styles beat user-agent styles at
   equal specificity), so the JS toggling `.hidden` would do nothing without
   this explicit override. */
.answers-header__history-btn[hidden] { display: none; }
.answers-header__history-btn svg { width: 19px; height: 19px; }
.answers-header__history-btn:hover { background: #f1f4f8; }

.answers-header__signin-wrap { position: relative; }
.answers-header__signin {
  border: 1px solid #cdd9e8;
  border-radius: var(--ans-r-chip);
  background: var(--ans-surface);
  color: var(--ans-blue-500);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}
.answers-header__signin:hover { border-color: var(--ans-blue-500); }
.answers-header__signin-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  background: var(--ans-surface);
  border-radius: 12px;
  box-shadow: var(--ans-shadow-card);
  overflow: hidden;
}
.answers-header__signin-menu[hidden] { display: none; } /* see history-btn[hidden] note above */
.answers-header__signin-menu a {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ans-ink);
  text-decoration: none;
}
.answers-header__signin-menu a:hover { background: #f5f7fb; }

.answers-header__user {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--ans-grad-avatar);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Slide-over history panel --------------------------------------------- */
.history-panel {
  position: absolute;
  inset: 0 auto 0 0;
  width: 82%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--ans-surface);
  box-shadow: 0 0 28px rgba(0, 20, 45, 0.28);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 20;
}
.history-panel.is-open { transform: translateX(0); }

.history-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 40, 80, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 19;
}
.history-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.history-panel__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
  box-shadow: var(--ans-shadow-header);
}
.history-panel__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ans-navy-900);
}
.history-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ans-slate);
  cursor: pointer;
}
.history-panel__close svg { width: 13px; height: 13px; }
.history-panel__close:hover { background: #f1f4f8; }

.history-panel__new {
  flex-shrink: 0;
  margin: 12px 14px;
  padding: 10px;
  border: 1px dashed #cdd9e8;
  border-radius: var(--ans-r-input);
  background: transparent;
  color: var(--ans-blue-500);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.history-panel__new:hover { background: #f6f9fd; }

.history-panel__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 14px;
}
.history-panel__empty {
  padding: 12px;
  font-size: 12.5px;
  color: var(--ans-slate-400);
  text-align: center;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 10px;
  margin-bottom: 2px;
}
.history-row:hover,
.history-row--active { background: #f1f4f8; }

.history-row__link {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 8px;
  text-decoration: none;
}
.history-row__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ans-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-row__time {
  font-size: 11px;
  color: var(--ans-slate-400);
}

.history-row__action {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--ans-slate-400);
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}
.history-row__action:hover { background: #e3e9f1; color: var(--ans-ink); }
