/* SIMC Assistant — static chatbot widget */
:root {
  --simc-primary: #9c1b1f;
  --simc-primary-dark: #7a1419;
  --simc-primary-light: #ffe9ea;
  --simc-text: #1f1f1f;
  --simc-text-muted: #666;
  --simc-bg: #ffffff;
  --simc-bg-alt: #f6f6f7;
  --simc-border: #e4e4e7;
  --simc-user-bubble: #9c1b1f;
  --simc-user-text: #ffffff;
  --simc-bot-bubble: #f1f1f3;
  --simc-bot-text: #1f1f1f;
  --simc-shadow: 0 12px 40px rgba(0,0,0,.18);
}

#simc-bot-root, #simc-bot-root * {
  box-sizing: border-box;
  font-family: 'Open Sans', 'Noto Sans', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.4;
}

/* Floating launcher — raw image, no circle wrapper, image itself is the button.
   Lifted above the site's existing NOTICE bar in the bottom-right corner. */
#simc-bot-launcher {
  position: fixed;
  right: 24px;
  bottom: 150px;
  width: 100px;
  height: 100px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  z-index: 2147483646;
  display: block;
  transition: transform .18s ease;
  animation: simc-bot-breathe 3.6s ease-in-out infinite;
}
#simc-bot-launcher:hover { transform: translateY(-3px) scale(1.05); }
#simc-bot-launcher img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.22));
}
#simc-bot-launcher svg {
  width: 100%;
  height: 100%;
  display: block;
  color: var(--simc-primary);
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.22));
}
@keyframes simc-bot-breathe {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

/* Teaser bubble — floating card that appears above the launcher
   to invite visitors to open the chat (dismissable via X). */
#simc-bot-teaser {
  position: fixed;
  right: 24px;
  /* sits above the launcher: launcher-bottom (150) + launcher-height (100) + gap */
  bottom: 258px;
  width: 260px;
  max-width: calc(100vw - 48px);
  background: #ffffff;
  color: #1f1f1f;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(10, 30, 60, 0.18), 0 2px 6px rgba(10, 30, 60, 0.08);
  padding: 12px 14px 14px;
  font-family: "Open Sans", "Noto Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  z-index: 2147483646;
  opacity: 0;
  transform: translateY(10px) scale(.96);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  cursor: pointer;
}
#simc-bot-teaser.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#simc-bot-teaser.is-leaving {
  opacity: 0;
  transform: translateY(6px) scale(.98);
  pointer-events: none;
}
/* Little triangle pointing down toward the launcher */
#simc-bot-teaser::after {
  content: "";
  position: absolute;
  right: 36px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgba(10, 30, 60, 0.06);
}
.simc-bot-teaser-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.simc-bot-teaser-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
}
.simc-bot-teaser-avatar--fallback {
  background: var(--simc-primary, #c8102e);
}
.simc-bot-teaser-title {
  font-size: 14px;
  font-weight: 700;
  color: #111c3a;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.simc-bot-teaser-close {
  background: transparent;
  border: 0;
  padding: 4px;
  margin: -4px -4px -4px 0;
  color: #8a98a7;
  cursor: pointer;
  border-radius: 6px;
  line-height: 0;
  transition: background .15s ease, color .15s ease;
}
.simc-bot-teaser-close:hover {
  background: #f3f4f6;
  color: #111c3a;
}
.simc-bot-teaser-body {
  font-size: 14.5px;
  line-height: 1.4;
  color: #333;
  padding-left: 2px;
}
@media (max-width: 1024px) {
  #simc-bot-teaser { right: 20px; bottom: 245px; }
}
@media (max-width: 640px) {
  #simc-bot-teaser {
    right: calc(14px + env(safe-area-inset-right, 0px));
    bottom: calc(220px + env(safe-area-inset-bottom, 0px));
    width: 240px;
  }
  #simc-bot-teaser::after { right: 30px; }
}

/* External close FAB — replaces launcher when panel is open */
#simc-bot-close-fab {
  position: fixed;
  right: 24px;
  bottom: 150px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--simc-primary);
  color: #fff;
  border: none;
  box-shadow: var(--simc-shadow);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2147483646;
  transition: transform .15s ease, background .2s ease;
}
#simc-bot-close-fab:hover { background: var(--simc-primary-dark); transform: rotate(90deg); }
#simc-bot-launcher .simc-bot-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: #ffcc00;
  color: #000;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Chat panel — sits above the launcher which is above the NOTICE bar */
#simc-bot-panel {
  position: fixed;
  right: 24px;
  bottom: 225px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 260px);
  background: var(--simc-bg);
  border-radius: 16px;
  box-shadow: var(--simc-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483647;
  transform-origin: bottom right;
  animation: simc-bot-pop .18s ease-out;
}
#simc-bot-panel.simc-open { display: flex; }

@keyframes simc-bot-pop {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.simc-bot-head {
  background: var(--simc-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.simc-bot-head .simc-bot-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}
.simc-bot-head .simc-bot-avatar svg { width: 20px; height: 20px; }
.simc-bot-head-title { flex: 1; }
.simc-bot-head-title .t1 { font-weight: 700; font-size: 15px; }
.simc-bot-head-title .t2 {
  font-size: 11px;
  opacity: .95;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.simc-bot-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25);
  display: inline-block;
  animation: simc-bot-pulse 1.8s ease-in-out infinite;
}
@keyframes simc-bot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}
.simc-bot-close {
  background: none; border: none; color: #fff; cursor: pointer; padding: 6px;
  border-radius: 6px; opacity: .9;
}
.simc-bot-close:hover { background: rgba(255,255,255,.15); }

/* Messages */
.simc-bot-messages {
  flex: 1; overflow-y: auto;
  padding: 14px;
  background: var(--simc-bg-alt);
  display: flex; flex-direction: column; gap: 10px;
}
.simc-bot-messages::-webkit-scrollbar { width: 6px; }
.simc-bot-messages::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 3px; }

.simc-bot-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: simc-bot-msg-in .32s ease-out backwards;
}
@keyframes simc-bot-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.simc-bot-msg.simc-bot-user {
  align-self: flex-end;
  background: var(--simc-user-bubble);
  color: var(--simc-user-text);
  border-bottom-right-radius: 4px;
}
.simc-bot-msg.simc-bot-bot {
  align-self: flex-start;
  background: var(--simc-bot-bubble);
  color: var(--simc-bot-text);
  border-bottom-left-radius: 4px;
}
.simc-bot-msg .simc-bot-source {
  display: inline-block;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--simc-primary);
  text-decoration: none;
  font-weight: 600;
}
.simc-bot-msg .simc-bot-source:hover { text-decoration: underline; }

/* Typing dots */
.simc-bot-typing {
  align-self: flex-start;
  background: var(--simc-bot-bubble);
  padding: 10px 14px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.simc-bot-typing span {
  display: inline-block;
  width: 7px; height: 7px;
  background: #999;
  border-radius: 50%;
  margin: 0 2px;
  animation: simc-bot-typing 1.2s infinite ease-in-out both;
}
.simc-bot-typing span:nth-child(2) { animation-delay: .15s; }
.simc-bot-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes simc-bot-typing {
  0%, 80%, 100% { opacity: .3; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Suggested chips */
.simc-bot-suggests-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--simc-text-muted);
  margin: 10px 0 -2px 2px;
  text-transform: uppercase;
}
.simc-bot-suggests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.simc-bot-chip {
  background: #fff;
  border: 1.5px solid var(--simc-primary);
  color: var(--simc-primary);
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
  font-weight: 600;
  animation: simc-bot-chip-in .35s ease-out backwards;
}
.simc-bot-chip:hover {
  background: var(--simc-primary);
  color: #fff;
}
.simc-bot-chip:active { transform: scale(.96); }
.simc-bot-suggests .simc-bot-chip:nth-child(1) { animation-delay: .05s; }
.simc-bot-suggests .simc-bot-chip:nth-child(2) { animation-delay: .11s; }
.simc-bot-suggests .simc-bot-chip:nth-child(3) { animation-delay: .17s; }
.simc-bot-suggests .simc-bot-chip:nth-child(4) { animation-delay: .23s; }
.simc-bot-suggests .simc-bot-chip:nth-child(5) { animation-delay: .29s; }
@keyframes simc-bot-chip-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Fallback card (no-match) — clean, bot-bubble style with a pill-shaped CTA */
.simc-bot-fallback {
  background: #f1f1f3;
  border: none;
  padding: 16px 18px;
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  margin-top: 4px;
  align-self: flex-start;
  max-width: 90%;
  animation: simc-bot-msg-in .32s ease-out backwards;
}
.simc-bot-fallback .fb-title {
  font-weight: 600;
  color: var(--simc-text);
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.4;
}
.simc-bot-fallback .fb-body {
  color: var(--simc-text);
  font-size: 13.5px;
  margin-bottom: 14px;
  line-height: 1.5;
}
.simc-bot-fallback .fb-cta {
  display: inline-block;
  background: var(--simc-primary);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  transition: background .18s ease, transform .12s ease;
}
.simc-bot-fallback .fb-cta:hover {
  background: var(--simc-primary-dark);
  transform: translateY(-1px);
}
.simc-bot-fallback .fb-cta:active { transform: translateY(0); }

/* Input bar */
.simc-bot-input-wrap {
  padding: 10px;
  background: #fff;
  border-top: 1px solid var(--simc-border);
  display: flex;
  gap: 8px;
  align-items: center;
}
.simc-bot-input {
  flex: 1;
  border: 1px solid var(--simc-border);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  min-height: 40px;
}
.simc-bot-input:focus { border-color: var(--simc-primary); }
.simc-bot-send {
  background: var(--simc-primary);
  color: #fff;
  border: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.simc-bot-send:hover { background: var(--simc-primary-dark); }
.simc-bot-send svg { width: 18px; height: 18px; }

/* Footer note */
.simc-bot-footer {
  text-align: center;
  padding: 6px;
  background: #fff;
  border-top: 1px solid var(--simc-border);
  font-size: 10.5px;
  color: var(--simc-text-muted);
}
.simc-bot-footer a { color: var(--simc-primary); text-decoration: none; }

/* ===================================================================
 * Responsive breakpoints
 * =================================================================== */

/* Tablet — slightly wider, keep floating; still clears NOTICE bar */
@media (min-width: 641px) and (max-width: 1024px) {
  #simc-bot-panel {
    width: 420px;
    height: 620px;
    right: 20px;
    bottom: 215px;
    max-height: calc(100vh - 245px);
  }
  #simc-bot-launcher {
    right: 20px;
    bottom: 145px;
    width: 92px; height: 92px;
  }
}

/* Mobile — full-screen with safe-area padding, dynamic viewport height */
@media (max-width: 640px) {
  #simc-bot-panel {
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;           /* better for iOS: shrinks with on-screen keyboard */
    max-height: 100dvh;
    border-radius: 0;
    animation: simc-bot-slide-up .22s ease-out;
    transform-origin: bottom center;
  }
  @keyframes simc-bot-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Launcher: smaller + safe-area aware (notch/home-bar on iPhone)
     Lifted above the site's NOTICE bar in bottom-right */
  #simc-bot-launcher {
    right: calc(14px + env(safe-area-inset-right, 0px));
    bottom: calc(130px + env(safe-area-inset-bottom, 0px));
    width: 82px; height: 82px;
  }

  /* Head: respect top safe area (iPhone notch) */
  .simc-bot-head {
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  .simc-bot-head-title .t1 { font-size: 16px; }
  .simc-bot-head-title .t2 { font-size: 12px; }
  .simc-bot-close { padding: 10px; min-width: 44px; min-height: 44px; }

  /* Messages text size up for readability */
  .simc-bot-msg { font-size: 14.5px; max-width: 88%; padding: 11px 14px; }
  .simc-bot-messages { padding: 14px 14px 18px; }

  /* Chips bigger for finger tap */
  .simc-bot-chip { padding: 10px 14px; font-size: 13.5px; }

  /* Input: 16px font prevents iOS auto-zoom on focus */
  .simc-bot-input {
    font-size: 16px;
    padding: 12px 16px;
    min-height: 44px;
  }
  .simc-bot-input-wrap {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }
  .simc-bot-send { width: 48px; height: 48px; }

  /* Fallback card bigger */
  .simc-bot-fallback { padding: 16px; }
  .simc-bot-fallback .fb-cta { padding: 12px 18px; font-size: 14px; }

  /* Footer: hide on tiny phones to save vertical space */
  .simc-bot-footer { padding: 5px 10px; font-size: 10px; }
}

/* Very small / landscape phones — compress header */
@media (max-width: 480px) and (orientation: landscape) {
  #simc-bot-panel .simc-bot-head { padding-top: 10px; padding-bottom: 10px; }
  .simc-bot-head .simc-bot-avatar { width: 32px; height: 32px; font-size: 13px; }
  .simc-bot-footer { display: none; }
}

/* Reduce-motion users */
@media (prefers-reduced-motion: reduce) {
  #simc-bot-panel, .simc-bot-typing span { animation: none !important; }
  #simc-bot-launcher { transition: none; }
}
