/* ================================================================
   Starchild Chat Panel — sc-chat-* styles.
   Neutral premium scheme: ivory/graphite with subtle indigo accent.
   ================================================================ */

.sc-chat-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: min(680px, calc(100vh - 100px));
  margin-top: 68px;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  z-index: 40;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(18,22,19,.12);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.22,1,.36,1);
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  overflow: hidden;
}

.sc-chat-panel--open {
  transform: translateX(0);
}

.sc-chat-toggle {
  position: absolute;
  left: -42px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line-hi);
  border-right: none;
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  cursor: pointer;
  transition: left .28s cubic-bezier(.22,1,.36,1), background .15s, color .15s;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  user-select: none;
  white-space: nowrap;
}

.sc-chat-toggle:hover {
  background: var(--line);
  color: var(--ink);
}

.sc-chat-toggle svg {
  transform: rotate(90deg);
}

.sc-chat-panel--open .sc-chat-toggle {
  display: none;
}

.sc-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.sc-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sc-chat-head::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-indigo);
  margin-right: 8px;
  flex-shrink: 0;
}

.sc-chat-head-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -.01em;
  color: var(--ink);
}

.sc-chat-close {
  width: 28px;
  height: 28px;
  border-radius: var(--rad-sm);
  border: none;
  background: var(--bg-sage);
  color: var(--ink-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}

.sc-chat-close:hover {
  background: var(--line);
  color: var(--ink);
}

.sc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.sc-chat-msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: scChatFadeIn .2s ease;
}

@keyframes scChatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sc-chat-msg--ai {
  align-self: flex-start;
}

.sc-chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.sc-chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  background: var(--line);
  color: var(--ink);
  flex-shrink: 0;
}

.sc-chat-msg-avatar::after {
  content: 'A';
  font: 700 12px var(--font-mono);
}

.sc-chat-msg-text {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  word-break: break-word;
}

.sc-chat-msg--ai .sc-chat-msg-text {
  background: var(--bg-sage);
  border-bottom-left-radius: 4px;
}

.sc-chat-msg--user .sc-chat-msg-text {
  background: var(--ink);
  color: var(--bg-elev);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.sc-chat-msg--typing .sc-chat-msg-text {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}

.sc-chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-dim);
  display: inline-block;
  animation: scChatDotBounce 1.2s infinite ease-in-out;
}

.sc-chat-dot:nth-child(1) { animation-delay: 0s; }
.sc-chat-dot:nth-child(2) { animation-delay: .2s; }
.sc-chat-dot:nth-child(3) { animation-delay: .4s; }

@keyframes scChatDotBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

.sc-chat-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.sc-chat-input-row input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--rad-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}

.sc-chat-input-row input::placeholder {
  color: var(--ink-low);
}

.sc-chat-input-row input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 2px rgba(99,102,241,.18);
}

.sc-chat-input-row input:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.sc-chat-send {
  width: 36px;
  height: 36px;
  border-radius: var(--rad-sm);
  border: none;
  background: var(--ink);
  color: var(--bg-elev);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}

.sc-chat-send:hover:not(:disabled) {
  background: var(--accent-indigo);
  color: #fff;
}

.sc-chat-send:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.sc-chat-msg--login-cta .sc-chat-msg-text {
  background: var(--bg-sage);
}

.sc-chat-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--rad-sm);
  background: var(--ink);
  color: var(--bg-elev);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s, color .15s;
}

.sc-chat-login-btn:hover {
  background: var(--accent-indigo);
  color: #fff;
}

@media (max-width: 768px) {
  .sc-chat-panel {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    height: calc(100vh - 60px);
    margin-top: 60px;
  }
}
