/* ============================================================
   Sparky — TeslaBytes AI chat widget
   Dark theme, Tesla-red accent. Class prefix: tb-
   ============================================================ */

.tb-root { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }

/* ── Floating trigger ── */
.tb-widget-trigger { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9000; }

.tb-trigger-btn {
  display: flex; align-items: center; gap: 0.5rem;
  background: linear-gradient(135deg, #17171d 0%, #23111a 100%);
  border: 1px solid #E31937;
  border-radius: 2rem;
  padding: 0.625rem 1.05rem 0.625rem 0.85rem;
  cursor: pointer; color: #fff;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em;
  box-shadow: 0 4px 20px rgba(227, 25, 55, 0.35), 0 2px 8px rgba(0,0,0,0.6);
  transition: all 0.2s ease; white-space: nowrap;
}
.tb-trigger-btn:hover {
  background: linear-gradient(135deg, #23111a 0%, #300f19 100%);
  border-color: #ff2d4d;
  box-shadow: 0 6px 28px rgba(255, 45, 77, 0.35), 0 4px 12px rgba(0,0,0,0.7);
  transform: translateY(-2px);
}
.tb-trigger-icon { font-size: 1.2rem; line-height: 1; }
.tb-trigger-label { color: #fff; }

@keyframes tb-pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(1.12); } }
.tb-pulse { animation: tb-pulse 1.2s ease-in-out infinite; display: inline-block; }

/* ── Chat panel ── */
.tb-panel {
  position: fixed; bottom: 5.5rem; right: 1.5rem; z-index: 9001;
  width: 360px; height: 460px;
  background: #0d0d12; border: 1px solid #26262e; border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 0 1px rgba(227,25,55,0.10);
  animation: tb-panel-in 0.2s ease;
}
@keyframes tb-panel-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.tb-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #16070c 0%, #200a11 100%);
  border-bottom: 1px solid #2a1a1f; flex-shrink: 0;
}
.tb-panel-title { display: flex; align-items: center; gap: 0.5rem; }
.tb-panel-icon { font-size: 1.15rem; }
.tb-panel-name {
  font-size: 0.95rem; font-weight: 800; color: #f3f0ea; letter-spacing: 0.02em;
}
.tb-panel-badge {
  background: linear-gradient(135deg, #E31937, #a3122a);
  color: #fff; font-size: 0.55rem; font-weight: 800;
  padding: 2px 6px; border-radius: 3px; letter-spacing: 0.08em;
}
.tb-close-btn {
  background: none; border: none; color: #888; font-size: 1rem; cursor: pointer;
  padding: 0.25rem 0.4rem; border-radius: 4px; line-height: 1; transition: color 0.15s, background 0.15s;
}
.tb-close-btn:hover { color: #ff2d4d; background: rgba(227,25,55,0.12); }

.tb-disclaimer {
  font-size: 0.63rem; color: #6b6b78; text-align: center;
  padding: 0.4rem 1rem; background: #0a0a0e; border-bottom: 1px solid #1a1a20;
  flex-shrink: 0; letter-spacing: 0.02em;
}

/* ── Conversation ── */
.tb-conversation {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 1rem;
  scrollbar-width: thin; scrollbar-color: #2a2a32 transparent;
}
.tb-conversation::-webkit-scrollbar { width: 4px; }
.tb-conversation::-webkit-scrollbar-thumb { background: #2a2a32; border-radius: 2px; }

.tb-empty-state { text-align: center; padding: 1rem 0.5rem; }
.tb-empty-text { color: #8a8a98; font-size: 0.82rem; line-height: 1.55; margin: 0 0 1rem; }
.tb-suggestions { display: flex; flex-direction: column; gap: 0.4rem; }
.tb-suggestion-chip {
  background: #15151b; border: 1px solid #2a2a32; border-radius: 7px;
  color: #d8d3e0; font-size: 0.75rem; padding: 0.45rem 0.75rem;
  cursor: pointer; text-align: left; transition: all 0.15s; font-family: inherit;
}
.tb-suggestion-chip:hover { border-color: #E31937; background: #1c0e12; color: #fff; }

/* ── Q&A ── */
.tb-qa-pair { display: flex; flex-direction: column; gap: 0.5rem; }
.tb-question-bubble { display: flex; align-items: flex-start; gap: 0.5rem; justify-content: flex-end; }
.tb-question-icon { font-size: 0.85rem; opacity: 0.6; margin-top: 0.15rem; flex-shrink: 0; order: 1; }
.tb-question-text {
  background: #1c0e12; border: 1px solid #3a1a22; border-radius: 10px 10px 2px 10px;
  padding: 0.5rem 0.75rem; color: #efe7dc; font-size: 0.8rem; line-height: 1.5; margin: 0; max-width: 88%;
}
.tb-answer-bubble { display: flex; align-items: flex-start; gap: 0.5rem; }
.tb-bot-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.15rem; }
.tb-answer-content {
  background: #121218; border: 1px solid #232330; border-radius: 2px 10px 10px 10px;
  padding: 0.55rem 0.8rem; max-width: 88%;
}
.tb-answer-text { color: #cfcbd8; font-size: 0.8rem; line-height: 1.6; margin: 0; }

.tb-answer-links { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.5rem; }
.tb-link-pill {
  display: inline-flex; align-items: center;
  background: #1a0d11; border: 1px solid rgba(227,25,55,0.4); border-radius: 5px;
  color: #ff8a9c; font-size: 0.68rem; padding: 0.25rem 0.5rem; text-decoration: none;
  transition: all 0.15s; white-space: nowrap;
}
.tb-link-pill:hover { border-color: #ff2d4d; background: #2a0f16; color: #ffb3c0; }

.tb-loading-state { display: flex; align-items: center; gap: 0.625rem; padding: 0.25rem 0; }
.tb-loading-text { color: #6b6b78; font-size: 0.78rem; font-style: italic; }

.tb-streaming { min-height: 1.2em; }
.tb-cursor { display: inline-block; animation: tb-blink 0.8s step-start infinite; color: #E31937; margin-left: 1px; }
@keyframes tb-blink { 50% { opacity: 0; } }

/* ── Input ── */
.tb-input-area { padding: 0.625rem 0.75rem 0.75rem; background: #0a0a0e; border-top: 1px solid #1e1e24; flex-shrink: 0; }
.tb-input-row { display: flex; gap: 0.5rem; align-items: center; }
.tb-input {
  flex: 1; background: #15151b; border: 1px solid #2a2a32; border-radius: 8px;
  color: #efe7dc; font-size: 0.8rem; font-family: inherit; padding: 0.55rem 0.75rem;
  outline: none; transition: border-color 0.2s, box-shadow 0.2s; min-width: 0;
}
.tb-input::placeholder { color: #55555f; }
.tb-input:focus { border-color: #E31937; box-shadow: 0 0 0 2px rgba(227,25,55,0.15); }
.tb-input:disabled { opacity: 0.5; cursor: not-allowed; }
.tb-send-btn {
  width: 34px; height: 34px; background: linear-gradient(135deg, #a3122a 0%, #E31937 100%);
  border: none; border-radius: 8px; color: #fff; font-size: 1.05rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.15s; line-height: 1;
}
.tb-send-btn:hover:not(:disabled) { background: linear-gradient(135deg, #c0142f 0%, #ff2d4d 100%); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(227,25,55,0.4); }
.tb-send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.tb-char-count { font-size: 0.65rem; color: #6b6b78; text-align: right; margin-top: 0.25rem; padding-right: 0.25rem; }

/* ── Mobile: bottom sheet ── */
@media (max-width: 600px) {
  .tb-widget-trigger { bottom: 1rem; right: 1rem; }
  .tb-trigger-label { display: none; }
  .tb-trigger-btn { padding: 0; border-radius: 50%; width: 52px; height: 52px; justify-content: center; }
  .tb-trigger-icon { font-size: 1.5rem; }
  .tb-panel {
    bottom: 0; left: 0; right: 0; width: 100%; height: 72vh; max-height: 540px;
    border-radius: 16px 16px 0 0; border-left: none; border-right: none; border-bottom: none;
    animation: tb-panel-slide-up 0.25s ease;
  }
  @keyframes tb-panel-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
}
