@import url("spark-ai-brand.css");

/* SparkHelper — floating chat widget */

.spark-helper-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem 0.6rem 0.7rem;
  border: 2.5px solid var(--eng-red, #d81f26);
  border-radius: 28px;
  background: var(--surface-card, #fff);
  color: var(--eng-red-deep, #8b1a1a);
  font-family: "Special Elite", "Courier New", Courier, monospace;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.13);
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.spark-helper-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.spark-helper-fab__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.spark-helper-fab__label {
  line-height: 1.2;
}

/* Panel */
.spark-helper-panel {
  display: none;
  position: fixed;
  bottom: 4.5rem;
  right: 1.25rem;
  z-index: 9001;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(520px, calc(100vh - 6rem));
  border: 2px solid var(--eng-red, #d81f26);
  border-radius: 14px;
  background: var(--surface-card, #fff);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  flex-direction: column;
  overflow: hidden;
  font-family: "Special Elite", "Courier New", Courier, monospace;
}

.spark-helper-panel.is-open {
  display: flex;
}

.spark-helper-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(216, 31, 38, 0.25);
  background: var(--surface-muted, #fafafa);
}

.spark-helper-panel__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--eng-red-deep, #8b1a1a);
}

.spark-helper-panel__close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  color: #666;
}

.spark-helper-panel__close:hover {
  color: #000;
}

.spark-helper-panel__messages {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 180px;
  max-height: 340px;
}

.spark-helper-msg {
  max-width: 88%;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.spark-helper-msg--user {
  align-self: flex-end;
  background: var(--eng-red, #d81f26);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.spark-helper-msg--assistant {
  align-self: flex-start;
  background: var(--surface-muted, #f3f3f3);
  color: var(--eng-red-deep, #8a0000);
  border-bottom-left-radius: 3px;
}

.spark-helper-msg--system {
  align-self: center;
  text-align: center;
  font-size: 0.78rem;
  color: #888;
  font-style: italic;
  max-width: 95%;
}

.spark-helper-msg--thinking {
  opacity: 0.95;
  position: relative;
  overflow: hidden;
  animation: spark-think-pulse 1.5s ease-in-out infinite;
}

@keyframes spark-think-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(216, 31, 38, 0); }
  50% { box-shadow: 0 0 12px rgba(216, 31, 38, 0.14); }
}

.spark-thinking-shimmer {
  display: block;
  height: 3px;
  margin-top: 0.45rem;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(216, 31, 38, 0.35),
    transparent
  );
  background-size: 200% 100%;
  animation: spark-shimmer 1.2s linear infinite;
}

@keyframes spark-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spark-thinking-label {
  font-weight: 800;
  color: var(--eng-red-deep, #8b1a1a);
}

.spark-thinking-dots span {
  animation: spark-dot 1.2s ease-in-out infinite;
  opacity: 0.25;
}

.spark-thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.spark-thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes spark-dot {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

.spark-helper-panel__compose {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid rgba(216, 31, 38, 0.25);
  background: var(--surface-muted, #fafafa);
}

.spark-helper-panel__input {
  flex: 1;
  padding: 0.45rem 0.6rem;
  border: 2px solid rgba(216, 31, 38, 0.35);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  resize: none;
  min-height: 36px;
  max-height: 72px;
  background: var(--surface-card, #fff);
  color: var(--eng-red-deep, #8a0000);
}

.spark-helper-panel__input:focus {
  outline: none;
  border-color: var(--eng-red, #d81f26);
}

.spark-helper-panel__send {
  padding: 0.4rem 0.7rem;
  border: 2px solid var(--eng-red, #d81f26);
  border-radius: 8px;
  background: var(--eng-red, #d81f26);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.spark-helper-panel__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.spark-helper-panel__send:hover:not(:disabled) {
  background: var(--eng-red-deep, #8b1a1a);
  border-color: var(--eng-red-deep, #8b1a1a);
}

body.has-enginuity-done-bar .spark-helper-fab {
  bottom: calc(var(--enginuity-done-bar-offset, 7.5rem) + 0.65rem);
}

body.has-enginuity-done-bar .spark-helper-panel {
  bottom: calc(var(--enginuity-done-bar-offset, 7.5rem) + 4rem);
}

@media (max-width: 768px) {
  body.has-enginuity-done-bar .spark-helper-panel {
    bottom: calc(var(--enginuity-done-bar-offset, 8.5rem) + 3.5rem);
  }
}

@media (max-width: 480px) {
  .spark-helper-fab__label {
    display: none;
  }

  .spark-helper-fab {
    padding: 0.65rem;
    border-radius: 50%;
  }

  .spark-helper-panel {
    right: 0.5rem;
    bottom: 4rem;
    width: calc(100vw - 1rem);
  }
}
