/*
 * HSC Sizing Assistant — widget styles.
 * Minimal Intercom/Fin-inspired chat. Light theme, generous whitespace,
 * rounded bubbles, soft suggestion pills. All selectors scoped under
 * .hsc-widget / .hsc-bubble so the bundle can be shadow-DOM'd or iframed
 * without colliding with the host site.
 */

:host, .hsc-widget, .hsc-bubble {
  --hsc-accent: #1F2937;          /* near-black; user bubble + send */
  --hsc-accent-hover: #0B1220;
  --hsc-orange: #E87020;          /* brand pop, used sparingly */
  --hsc-bg: #FFFFFF;
  --hsc-surface: #F6F7F9;         /* bot bubble fill */
  --hsc-surface-2: #FAFAFB;       /* input strip background */
  --hsc-border: #ECECEF;
  --hsc-border-strong: #DFE0E4;
  --hsc-text: #0B1220;
  --hsc-text-2: #4B5563;
  --hsc-text-3: #8A8F98;
  --hsc-green: #16A34A;
  --hsc-warn: #B45309;
  --hsc-warn-bg: #FFF7E6;

  --hsc-radius-md: 14px;
  --hsc-radius-lg: 18px;
  --hsc-shadow: 0 16px 48px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.06);

  font-family: 'Plus Jakarta Sans', 'DM Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -------- Launcher bubble -------- */
.hsc-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--hsc-accent);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 9999;
  border: none;
}
.hsc-bubble:hover {
  transform: translateY(-2px);
  background: var(--hsc-accent-hover);
}
.hsc-bubble.hidden {
  transform: scale(0.6);
  opacity: 0;
  pointer-events: none;
}

/* -------- Widget shell -------- */
.hsc-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 384px;
  height: 640px;
  max-height: calc(100vh - 48px);
  background: var(--hsc-bg);
  border-radius: var(--hsc-radius-lg);
  box-shadow: var(--hsc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  transform-origin: bottom right;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.18s ease;
  color: var(--hsc-text);
}
.hsc-widget.hidden {
  transform: scale(0.96) translateY(12px);
  opacity: 0;
  pointer-events: none;
}
.hsc-widget * { box-sizing: border-box; }

/* -------- Header -------- */
.hsc-header {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--hsc-border);
  background: var(--hsc-bg);
}
.hsc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--hsc-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  position: relative;
  flex-shrink: 0;
}
.hsc-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  background: var(--hsc-green);
  border-radius: 50%;
  border: 2px solid var(--hsc-bg);
}
.hsc-header-info { flex: 1; min-width: 0; }
.hsc-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--hsc-text);
  letter-spacing: -0.01em;
}
.hsc-sub {
  font-size: 12.5px;
  color: var(--hsc-text-3);
  margin-top: 1px;
}
.hsc-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--hsc-text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.hsc-close:hover {
  background: var(--hsc-surface);
  color: var(--hsc-text);
}

/* -------- Hidden tracker (state-only, not rendered visually) -------- */
.hsc-tracker-hidden {
  display: none !important;
}

/* -------- Messages -------- */
.hsc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--hsc-border-strong) transparent;
}
.hsc-messages::-webkit-scrollbar { width: 6px; }
.hsc-messages::-webkit-scrollbar-thumb { background: var(--hsc-border-strong); border-radius: 6px; }
.hsc-messages::-webkit-scrollbar-track { background: transparent; }

.hsc-msg {
  display: flex;
  flex-direction: column;
  animation: hsc-slide 0.24s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.hsc-msg-bot { align-items: flex-start; }
.hsc-msg-user { align-items: flex-end; }
.hsc-msg + .hsc-msg-bot,
.hsc-msg + .hsc-msg-user {
  margin-top: 4px;
}
@keyframes hsc-slide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hsc-bubble-msg {
  max-width: 86%;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  word-wrap: break-word;
}
.hsc-msg-bot .hsc-bubble-msg {
  background: var(--hsc-surface);
  color: var(--hsc-text);
  border-radius: 16px 16px 16px 4px;
}
.hsc-msg-user .hsc-bubble-msg {
  background: var(--hsc-accent);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
/* Reserved <em> (internal trusted HTML — e.g. SKU highlight in add-to-cart). */
.hsc-bubble-msg em {
  font-style: normal;
  font-weight: 600;
  color: var(--hsc-orange);
}
/* Markdown-rendered italic from bot text — distinct from internal <em>. */
.hsc-bubble-msg em.md-em {
  font-style: italic;
  font-weight: inherit;
  color: inherit;
}
/* Markdown bold from bot text. */
.hsc-bubble-msg strong {
  font-weight: 700;
  color: inherit;
}
.hsc-msg-bot .hsc-bubble-msg a {
  color: var(--hsc-orange);
  font-weight: 600;
  text-decoration: none;
}
.hsc-msg-bot .hsc-bubble-msg a:hover { text-decoration: underline; }

/* -------- Typing indicator -------- */
.hsc-typing-wrap .hsc-typing-dots {
  background: var(--hsc-surface);
  border-radius: 16px 16px 16px 4px;
  padding: 12px 14px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.hsc-dot {
  width: 6px;
  height: 6px;
  background: var(--hsc-text-3);
  border-radius: 50%;
  animation: hsc-bounce 1.2s ease-in-out infinite;
}
.hsc-dot:nth-child(2) { animation-delay: 0.15s; }
.hsc-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes hsc-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* -------- Inline cards (summary / quote / route) -------- */
.hsc-card {
  max-width: 86%;
  background: var(--hsc-bg);
  border: 1px solid var(--hsc-border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 2px;
}
.hsc-card-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hsc-text-3);
  margin-bottom: 8px;
}
.hsc-eyebrow-green { color: var(--hsc-green); }

.hsc-summary-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hsc-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.hsc-summary-k { color: var(--hsc-text-3); }
.hsc-summary-v {
  color: var(--hsc-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hsc-quote-top { margin-bottom: 10px; }
.hsc-quote-model {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--hsc-text);
}
.hsc-quote-spec {
  margin-top: 3px;
  font-size: 13px;
  color: var(--hsc-text-2);
  line-height: 1.5;
}
.hsc-quote-warning {
  background: var(--hsc-warn-bg);
  color: var(--hsc-warn);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 10px;
}
.hsc-quote-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hsc-border);
}
.hsc-quote-price { display: flex; flex-direction: column; }
.hsc-quote-price-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--hsc-text-3);
}
.hsc-quote-price-amt {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--hsc-text);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.hsc-partno {
  font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--hsc-text-2);
  background: var(--hsc-surface);
  padding: 5px 8px;
  border-radius: 6px;
  letter-spacing: 0.01em;
  word-break: break-all;
  text-align: right;
}

.hsc-route .hsc-route-text {
  font-size: 13.5px;
  color: var(--hsc-text-2);
  line-height: 1.55;
}

/* -------- Suggested replies (Fin-style chips) -------- */
.hsc-qr-floating {
  padding: 0 16px 6px;
}
.hsc-qr-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.hsc-qr {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 8px 14px;
  border: 1px solid var(--hsc-border-strong);
  background: var(--hsc-bg);
  color: var(--hsc-text);
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  line-height: 1.2;
}
.hsc-qr:hover {
  background: var(--hsc-surface);
  border-color: var(--hsc-accent);
}
.hsc-qr:active { transform: scale(0.98); }
.hsc-qr.primary {
  background: var(--hsc-accent);
  border-color: var(--hsc-accent);
  color: #fff;
}
.hsc-qr.primary:hover {
  background: var(--hsc-accent-hover);
  border-color: var(--hsc-accent-hover);
}
.hsc-qr.alt {
  /* fallback styling — same as default */
}

/* -------- Input -------- */
.hsc-input-area {
  background: var(--hsc-bg);
  border-top: 1px solid var(--hsc-border);
}
.hsc-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 14px;
}
.hsc-text-input {
  flex: 1;
  background: var(--hsc-surface);
  border: 1px solid transparent;
  color: var(--hsc-text);
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s;
}
.hsc-text-input::placeholder { color: var(--hsc-text-3); }
.hsc-text-input:focus {
  background: var(--hsc-bg);
  border-color: var(--hsc-border-strong);
}
.hsc-text-input:disabled { opacity: 0.55; cursor: not-allowed; }
.hsc-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: var(--hsc-accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.15s, transform 0.1s;
}
.hsc-send:hover:not(:disabled) { background: var(--hsc-accent-hover); }
.hsc-send:active:not(:disabled) { transform: scale(0.95); }
.hsc-send:disabled {
  background: var(--hsc-border-strong);
  cursor: not-allowed;
}

/* -------- Small viewports -------- */
@media (max-width: 480px) {
  .hsc-widget {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 8px;
    height: calc(100vh - 16px);
    max-height: none;
  }
}
