/* ============================================================================
 * smash-assist.css — Floating chat bubble for the Смаш assistant
 * All styles scoped under .smash-assist namespace to avoid bleeding into pages.
 * Date: 2026-05-30
 * Spec: _design/smash-assistant-spec-2026-05-30.md
 * Voice: Burger King MK-style — SMASH orange, warm cream, sentence case body.
 * ========================================================================== */

/* --- Design tokens (scoped to the assistant root) --- */
.smash-assist {
  /* SMASH brand palette */
  --sa-orange: #d9480f;
  --sa-orange-hover: #c03e0a;
  --sa-orange-light: #ff7a3a;
  --sa-cream: #fdf6ec;
  --sa-cream-dark: #f5e9d4;
  --sa-ink: #1a1410;
  --sa-ink-soft: #4a3a30;
  --sa-white: #ffffff;
  --sa-muted: #8a7d72;
  --sa-border: rgba(26, 20, 16, 0.08);
  --sa-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  --sa-shadow-lift: 0 12px 36px rgba(217, 72, 15, 0.32);
  --sa-error: #b00020;
  --sa-warn: #b87333;

  /* sizing */
  --sa-bubble: 64px;
  --sa-panel-w: 380px;
  --sa-panel-h: 520px;
  --sa-radius: 18px;
  --sa-radius-msg: 16px;
  --sa-radius-pill: 999px;

  /* type */
  --sa-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;

  /* z-index pinned high so it floats above page content */
  --sa-z: 2147483000;

  font-family: var(--sa-font);
  color: var(--sa-ink);
  font-size: 15px;
  line-height: 1.45;
}

/* --- Hidden bootstrap (when JS not yet mounted) --- */
.smash-assist[hidden] {
  display: none !important;
}

/* --- The floating bubble (closed state) --- */
.smash-assist__bubble {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: var(--sa-bubble);
  height: var(--sa-bubble);
  border-radius: 50%;
  background: var(--sa-orange);
  color: var(--sa-white);
  border: 2px solid var(--sa-white);
  box-shadow: var(--sa-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: var(--sa-z);
  transition: transform 0.18s ease, box-shadow 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--sa-font);
  padding: 0;
}

.smash-assist__bubble:hover,
.smash-assist__bubble:focus-visible {
  transform: scale(1.05);
  box-shadow: var(--sa-shadow-lift);
  background: var(--sa-orange-hover);
  outline: none;
}

.smash-assist__bubble:focus-visible {
  outline: 3px solid var(--sa-orange-light);
  outline-offset: 3px;
}

.smash-assist__bubble-icon {
  font-size: 28px;
  line-height: 1;
  display: block;
  user-select: none;
  -webkit-user-select: none;
}

.smash-assist__bubble-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* subtle pulse every 30s — disabled on reduced motion */
.smash-assist__bubble--pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--sa-orange);
  opacity: 0;
  animation: sa-pulse 2s ease-out 1;
  pointer-events: none;
}

@keyframes sa-pulse {
  0% { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* --- First-visit hint toast --- */
.smash-assist__hint {
  position: fixed;
  right: 24px;
  bottom: calc(24px + var(--sa-bubble) + 12px);
  background: var(--sa-white);
  color: var(--sa-ink);
  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: var(--sa-shadow);
  font-size: 14px;
  font-weight: 500;
  z-index: var(--sa-z);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  animation: sa-slide-in 0.3s ease-out;
}

.smash-assist__hint-close {
  background: transparent;
  border: 0;
  color: var(--sa-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.smash-assist__hint-close:hover {
  color: var(--sa-ink);
}

@keyframes sa-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- The chat panel (open state) --- */
.smash-assist__panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: var(--sa-panel-w);
  height: var(--sa-panel-h);
  max-height: calc(100vh - 48px);
  background: var(--sa-cream);
  border-radius: var(--sa-radius);
  box-shadow: var(--sa-shadow-lift);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--sa-z);
  animation: sa-panel-in 0.22s ease-out;
  border: 1px solid var(--sa-border);
}

@keyframes sa-panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Panel header --- */
.smash-assist__header {
  background: var(--sa-orange);
  color: var(--sa-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.smash-assist__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sa-white);
  color: var(--sa-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.smash-assist__title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  line-height: 1.1;
  flex: 1;
  min-width: 0;
}

.smash-assist__status {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.9;
  display: block;
  margin-top: 2px;
}

.smash-assist__status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #58e58a;
  margin-right: 5px;
  vertical-align: middle;
  animation: sa-pulse-dot 2s ease-in-out infinite;
}

@keyframes sa-pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.smash-assist__lang {
  background: rgba(255, 255, 255, 0.18);
  color: var(--sa-white);
  border: 0;
  padding: 6px 10px;
  border-radius: var(--sa-radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sa-font);
  letter-spacing: 0.5px;
}

.smash-assist__lang:hover { background: rgba(255, 255, 255, 0.28); }

.smash-assist__close {
  background: transparent;
  border: 0;
  color: var(--sa-white);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  font-family: var(--sa-font);
}

.smash-assist__close:hover { background: rgba(255, 255, 255, 0.18); }

/* --- Message list --- */
.smash-assist__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--sa-cream);
}

.smash-assist__messages::-webkit-scrollbar { width: 6px; }
.smash-assist__messages::-webkit-scrollbar-track { background: transparent; }
.smash-assist__messages::-webkit-scrollbar-thumb {
  background: var(--sa-cream-dark);
  border-radius: 3px;
}

.smash-assist__msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--sa-radius-msg);
  font-size: 14.5px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: sa-msg-in 0.22s ease-out;
}

@keyframes sa-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.smash-assist__msg--bot {
  align-self: flex-start;
  background: var(--sa-white);
  color: var(--sa-ink);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--sa-border);
}

.smash-assist__msg--user {
  align-self: flex-end;
  background: var(--sa-orange);
  color: var(--sa-white);
  border-bottom-right-radius: 6px;
}

.smash-assist__msg--error {
  align-self: flex-start;
  background: rgba(176, 0, 32, 0.08);
  color: var(--sa-error);
  border: 1px solid rgba(176, 0, 32, 0.2);
  font-size: 13.5px;
}

.smash-assist__msg--warn {
  align-self: flex-start;
  background: rgba(184, 115, 51, 0.1);
  color: var(--sa-warn);
  border: 1px solid rgba(184, 115, 51, 0.25);
  font-size: 13.5px;
}

/* --- Typing indicator --- */
.smash-assist__typing {
  align-self: flex-start;
  background: var(--sa-white);
  border: 1px solid var(--sa-border);
  border-bottom-left-radius: 6px;
  border-radius: var(--sa-radius-msg);
  padding: 12px 14px;
  display: flex;
  gap: 4px;
}

.smash-assist__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sa-muted);
  animation: sa-typing 1.2s ease-in-out infinite;
}

.smash-assist__typing span:nth-child(2) { animation-delay: 0.15s; }
.smash-assist__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sa-typing {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* --- Suggestion chips --- */
.smash-assist__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.smash-assist__chip {
  background: var(--sa-white);
  color: var(--sa-orange);
  border: 1px solid var(--sa-orange);
  padding: 6px 12px;
  border-radius: var(--sa-radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sa-font);
  transition: background 0.15s ease, color 0.15s ease;
}

.smash-assist__chip:hover {
  background: var(--sa-orange);
  color: var(--sa-white);
}

.smash-assist__chip:focus-visible {
  outline: 2px solid var(--sa-orange);
  outline-offset: 2px;
}

/* --- Input area --- */
.smash-assist__inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--sa-white);
  border-top: 1px solid var(--sa-border);
  flex-shrink: 0;
}

.smash-assist__input {
  flex: 1;
  resize: none;
  border: 1px solid var(--sa-border);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 14.5px;
  font-family: var(--sa-font);
  background: var(--sa-cream);
  color: var(--sa-ink);
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease;
}

.smash-assist__input:focus {
  border-color: var(--sa-orange);
}

.smash-assist__input::placeholder {
  color: var(--sa-muted);
}

.smash-assist__send {
  background: var(--sa-orange);
  color: var(--sa-white);
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  transition: background 0.15s ease, transform 0.1s ease;
  font-family: var(--sa-font);
  padding: 0;
}

.smash-assist__send:hover:not(:disabled) {
  background: var(--sa-orange-hover);
}

.smash-assist__send:active:not(:disabled) { transform: scale(0.95); }

.smash-assist__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.smash-assist__send:focus-visible {
  outline: 2px solid var(--sa-orange-light);
  outline-offset: 2px;
}

/* --- Footer (small attribution line) --- */
.smash-assist__footer {
  padding: 6px 12px 8px;
  font-size: 11px;
  color: var(--sa-muted);
  text-align: center;
  background: var(--sa-white);
  border-top: 1px solid var(--sa-border);
  flex-shrink: 0;
}

.smash-assist__footer strong {
  color: var(--sa-ink-soft);
  font-weight: 600;
}

/* --- Mobile responsive (full-screen takeover under 520px) --- */
@media (max-width: 519px) {
  .smash-assist__panel {
    right: 0;
    bottom: 0;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .smash-assist__bubble {
    width: 56px;
    height: 56px;
    right: 16px;
    bottom: 16px;
  }

  .smash-assist__hint {
    right: 16px;
    bottom: calc(16px + 56px + 12px);
    max-width: calc(100vw - 32px);
  }

  .smash-assist__bubble-icon {
    font-size: 24px;
  }
}

/* --- Reduced motion: disable pulses & slide-ins --- */
@media (prefers-reduced-motion: reduce) {
  .smash-assist__bubble,
  .smash-assist__bubble--pulse::after,
  .smash-assist__hint,
  .smash-assist__panel,
  .smash-assist__msg,
  .smash-assist__typing span,
  .smash-assist__status-dot {
    animation: none !important;
    transition: none !important;
  }
}

/* --- High-contrast / forced-colors fallback --- */
@media (forced-colors: active) {
  .smash-assist__bubble,
  .smash-assist__send,
  .smash-assist__msg--user {
    border: 2px solid CanvasText;
  }
}

/* --- Print: hide entirely --- */
@media print {
  .smash-assist { display: none !important; }
}
