/* Bomi — Tesla Team site chatbot */
#tesla-chat-root {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 99999;
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  direction: rtl;
  text-align: right;
  color: #0f1f3d;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#tesla-chat-root * {
  box-sizing: border-box;
}

#tesla-chat-toggle {
  width: 92px;
  height: 108px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  filter: drop-shadow(0 8px 16px rgba(15, 31, 61, 0.28));
  transition: filter 0.15s ease, transform 0.15s ease;
}

#tesla-chat-toggle:hover,
#tesla-chat-toggle:focus-visible {
  filter: drop-shadow(0 10px 20px rgba(15, 31, 61, 0.4));
  outline: none;
}

#tesla-chat-toggle:focus-visible {
  border-radius: 18px;
  box-shadow: 0 0 0 3px #f5b800;
}

#tesla-chat-toggle .bomi {
  width: 92px;
  height: 108px;
  pointer-events: none;
}

#tesla-chat-toggle[aria-expanded="true"] {
  display: none;
}

#tesla-chat-panel {
  display: none;
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 32px));
  background: transparent;
  border-radius: 18px;
  overflow: visible;
  box-shadow: 0 16px 48px rgba(15, 31, 61, 0.32);
  flex-direction: column;
  border: 0;
}

#tesla-chat-root.is-open #tesla-chat-panel {
  display: flex;
}

.tc-head {
  background: #0f1f3d;
  color: #fff;
  padding: 8px 12px 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  border-radius: 18px 18px 0 0;
  overflow: visible;
  position: relative;
  z-index: 2;
  border: 1px solid rgba(15, 31, 61, 0.08);
  border-bottom: 0;
}

.tc-head-mark {
  width: 48px;
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
  position: relative;
  cursor: pointer;
}

.tc-head-mark .bomi {
  width: 48px;
  height: 54px;
  overflow: visible;
}

.tc-head-mark,
.tc-head-mark .bomi-svg {
  overflow: visible;
}

.tc-head-mark .bomi-shadow {
  display: none;
}

.tc-head-text {
  flex: 1;
  min-width: 0;
}

.tc-head-text strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.tc-close {
  background: transparent;
  border: 0;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.tc-close:hover,
.tc-close:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.tc-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 8px;
  background: #f6f7fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 1px solid rgba(15, 31, 61, 0.08);
  border-right: 1px solid rgba(15, 31, 61, 0.08);
}

.tc-msg {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.tc-msg a {
  color: #0f1f3d;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: #f5b800;
}

.tc-msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #ececec;
  border-top-right-radius: 4px;
}

.tc-msg.user {
  align-self: flex-end;
  background: #0f1f3d;
  color: #fff;
  border-top-left-radius: 4px;
}

.tc-msg.user a {
  color: #f5b800;
}

.tc-msg.busy {
  color: #667;
  font-style: normal;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tc-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 14px;
}

.tc-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f5b800;
  display: block;
  animation: tcDot 1s ease-in-out infinite;
}

.tc-dots i:nth-child(2) { animation-delay: 0.15s; }
.tc-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes tcDot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.tc-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
  border-radius: 0 0 18px 18px;
  border: 1px solid rgba(15, 31, 61, 0.08);
  border-top: 1px solid #eee;
  overflow: hidden;
}

.tc-form input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.92rem;
  color: #0f1f3d;
  background: #fafafa;
  min-width: 0;
}

.tc-form input:focus {
  outline: 2px solid #f5b800;
  border-color: #f5b800;
  background: #fff;
}

.tc-form button {
  border: 0;
  background: #f5b800;
  color: #0f1f3d;
  font: inherit;
  font-weight: 800;
  border-radius: 12px;
  padding: 0 14px;
  cursor: pointer;
}

.tc-form button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* —— Bomi mascot (transforms are driven in JS) —— */
.bomi-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.bomi-yawn,
.bomi-zzz,
.bomi-hearts,
.bomi-question,
.bomi-think-dots,
.bomi-eye-happy,
.bomi-eye-happy-r,
.bomi-eye-closed,
.bomi-eye-dizzy {
  pointer-events: none;
}

/* Speech bubble */
.bomi-bubble {
  position: absolute;
  z-index: 3;
  background: #fff;
  color: #0f1f3d;
  border: 2px solid #0f1f3d;
  border-radius: 12px 12px 4px 12px;
  padding: 4px 8px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
  max-width: 200px;
  opacity: 0;
  transform: translateY(4px) scale(0.92);
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(15, 31, 61, 0.18);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.bomi-bubble.is-on {
  opacity: 1;
  transform: translateY(0) scale(1);
}
#tesla-chat-toggle .bomi-bubble {
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translate(-50%, 6px) scale(0.92);
  border-radius: 12px 12px 12px 4px;
  white-space: nowrap;
  text-align: center;
  max-width: min(180px, 70vw);
}
#tesla-chat-toggle .bomi-bubble.is-on {
  transform: translate(-50%, 0) scale(1);
}
.tc-head-mark .bomi-bubble {
  right: calc(100% + 8px);
  left: auto;
  top: 2px;
  bottom: auto;
  max-width: 160px;
  white-space: nowrap;
  text-align: center;
  border-radius: 12px 12px 4px 12px;
}

/* Confetti burst (triggered for a moment on celebrate) */
.bomi-confetti {
  position: absolute;
  inset: -8px -6px 0 -18px;
  pointer-events: none;
  overflow: visible;
}
#tesla-chat-toggle .bomi-confetti {
  inset: -20px -12px 0 -12px;
}
.bomi-confetti i {
  position: absolute;
  top: 40%;
  left: 50%;
  width: 5px;
  height: 8px;
  border-radius: 1px;
  opacity: 0;
  background: #f5b800;
}
.bomi-confetti i:nth-child(even) { background: #0f1f3d; }
.bomi-confetti i:nth-child(3n) { background: #fff; border: 1px solid #0f1f3d; }
#tesla-chat-root.is-celebrate .bomi-confetti i {
  animation: bomiConfetti 1.1s ease-out forwards;
}
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(1) { left: 20%; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(2) { left: 35%; animation-delay: 0.05s; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(3) { left: 50%; animation-delay: 0.1s; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(4) { left: 65%; animation-delay: 0.08s; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(5) { left: 80%; animation-delay: 0.14s; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(6) { left: 28%; animation-delay: 0.18s; width: 6px; height: 6px; border-radius: 50%; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(7) { left: 58%; animation-delay: 0.12s; width: 6px; height: 6px; border-radius: 50%; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(8) { left: 72%; animation-delay: 0.2s; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(9) { left: 42%; animation-delay: 0.16s; }
#tesla-chat-root.is-celebrate .bomi-confetti i:nth-child(10) { left: 12%; animation-delay: 0.22s; }

@keyframes bomiConfetti {
  0% { opacity: 1; transform: translate(-50%, 0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + 18px), -48px) rotate(180deg) scale(0.8); }
}

@media (prefers-reduced-motion: reduce) {
  .tc-dots i,
  #tesla-chat-root.is-celebrate .bomi-confetti i,
  .bomi-bubble {
    animation: none !important;
    transition: none !important;
  }
  #tesla-chat-root.is-celebrate .bomi-confetti i { opacity: 0; }
}

@media (max-width: 480px) {
  #tesla-chat-root {
    left: 10px;
    bottom: 10px;
  }
  #tesla-chat-panel {
    width: calc(100vw - 20px);
    height: min(72vh, calc(100vh - 20px));
  }
  #tesla-chat-toggle {
    width: 84px;
    height: 98px;
  }
}

.tc-ltr {
  unicode-bidi: isolate;
  direction: ltr;
  display: inline-block;
}

.tc-mail {
  color: #0f1f3d;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: #f5b800;
}

.tc-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.tc-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #0f1f3d;
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 0.9rem;
  border: 2px solid #f5b800;
  line-height: 1.4;
}

.tc-link-btn:hover,
.tc-link-btn:focus-visible {
  background: #16284d;
  outline: none;
}

.tc-link-btn-title {
  color: #fff;
}

.tc-msg.bot .tc-link-btn {
  color: #fff;
}
