/* ─────────────────────────────────────────────────────────────
   Sparky AI Panel — right sidebar, light mode
───────────────────────────────────────────────────────────── */

/* ── Panel shell ─────────────────────────────────────────── */

#sparky-panel {
  width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: var(--text-primary);
}

/* ── Messages area ────────────────────────────────────────── */

#sparky-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

#sparky-messages::-webkit-scrollbar         { width: 4px; }
#sparky-messages::-webkit-scrollbar-track   { background: transparent; }
#sparky-messages::-webkit-scrollbar-thumb   { background: var(--border-dark); border-radius: 2px; }

/* ── Welcome / empty state ────────────────────────────────── */

#sparky-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 14px 12px;
  gap: 6px;
  min-height: 0;
}

#sparky-welcome.hidden {
  display: none;
}

.sparky-welcome-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 4px;
  flex-shrink: 0;
}

.sparky-welcome-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.sparky-welcome-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Suggestion chips */
#sparky-suggestions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.sparky-suggest-btn {
  width: 100%;
  padding: 7px 11px;
  background: #F3F1EC;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: background 0.12s, border-color 0.12s;
}

.sparky-suggest-btn:hover {
  background: #EDEAE4;
  border-color: var(--border-dark);
}

/* ── Chat messages ─────────────────────────────────────────── */

.chat-msg {
  max-width: 96%;
  padding: 7px 10px;
  border-radius: 8px;
  line-height: 1.5;
  word-break: break-word;
  font-size: 12px;
  flex-shrink: 0;
}

.chat-msg.user {
  background: #FEF3C7;
  border: 1px solid rgba(217, 119, 6, 0.2);
  color: #92400E;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.chat-msg.ai {
  background: #F3F1EC;
  border: 1px solid var(--border);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
  white-space: pre-wrap;
}

.chat-msg.system {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-style: italic;
  font-size: 11px;
  align-self: center;
  text-align: center;
  max-width: 100%;
  padding: 2px 4px;
}

.chat-msg.typing {
  background: #F3F1EC;
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 0;
}

.typing-dots span {
  display: block;
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: ai-bounce 1.1s infinite ease-in-out;
  opacity: 0.5;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes ai-bounce {
  0%, 80%, 100% { transform: translateY(0);   opacity: 0.4; }
  40%           { transform: translateY(-4px); opacity: 1;   }
}

/* ── Pending-changes bar ──────────────────────────────────── */

#sparky-pending-bar {
  display: none;          /* shown via JS when AI has suggestions */
  gap: 6px;
  padding: 7px 8px;
  border-top: 2px solid #fcd34d;
  background: #fffbeb;
  flex-shrink: 0;
}

.pending-accept,
.pending-decline {
  flex: 1;
  padding: 5px 0;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}

.pending-accept {
  background: #16a34a;
  border: none;
  color: #fff;
}
.pending-accept:hover { background: #15803d; }

.pending-decline {
  background: transparent;
  border: 1px solid var(--border-dark);
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}
.pending-decline:hover { background: #F3F1EC; color: var(--text-primary); }

/* ── Input area ───────────────────────────────────────────── */

#sparky-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-sidebar);
}

#sparky-input {
  flex: 1;
  background: #F3F1EC;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

#sparky-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(217,119,6,0.1);
}

#sparky-input::placeholder { color: var(--text-sub); }


/* ── RESPONSIVE ──────────────────────────────────────────── */

/* Stacked under the canvas rather than beside it, and capped so the canvas
   keeps the majority of the screen. */
@media (max-width: 1024px) and (min-height: 600px) {
  #sparky-panel {
    width: 100%;
    height: 30vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 640px) {
  #sparky-panel {
    height: 26vh;
  }
}
