/* AI Support Chat Widget (v2 — floating modal) */

/* ── Wrap — default compact state ─────────────────────────────────── */
.sc-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 420px;
  height: 480px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  transition: width 0.2s, height 0.2s, top 0.2s, left 0.2s, bottom 0.2s, right 0.2s, transform 0.2s;
}

.sc-wrap.hidden { display: none; }

/* ── Expanded state ───────────────────────────────────────────────── */
.sc-wrap.expanded {
  position: fixed;
  top: 50%;
  left: 50%;
  bottom: auto;
  right: auto;
  transform: translate(-50%, -50%);
  width: 560px;
  height: 600px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

/* ── Backdrop ─────────────────────────────────────────────────────── */
.sc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 199;
  transition: background 0.2s;
}
.sc-modal-backdrop.hidden { display: none; }
.sc-modal-backdrop.sc-backdrop-dim { background: rgba(0,0,0,0.4); }

/* ── Header ───────────────────────────────────────────────────────── */
.sc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
}

.sc-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sc-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sc-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--rose-bg);
  border: 1px solid rgba(194, 105, 122, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sc-avatar svg {
  width: 16px;
  height: 16px;
  color: var(--rose);
}

.sc-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--cream);
}

.sc-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.sc-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4ade80;
  animation: scPulse 2s infinite;
}

@keyframes scPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Header buttons (clear, expand, close) */
.sc-clear,
.sc-expand,
.sc-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted2);
  cursor: pointer;
  transition: all 0.15s;
}

.sc-clear:hover,
.sc-expand:hover,
.sc-close:hover {
  color: var(--cream);
  border-color: rgba(240, 232, 224, 0.15);
}

.sc-clear svg,
.sc-expand svg,
.sc-close svg {
  width: 13px;
  height: 13px;
}

/* ── Messages ─────────────────────────────────────────────────────── */
.sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sc-messages::-webkit-scrollbar { width: 3px; }
.sc-messages::-webkit-scrollbar-thumb { background: var(--muted2); border-radius: 2px; }

.sc-bubble {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.sc-bubble.user { align-self: flex-end; }
.sc-bubble.assistant { align-self: flex-start; }

.sc-bubble-text {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.sc-bubble.user .sc-bubble-text {
  background: var(--rose-dim, rgba(194, 105, 122, 0.15));
  color: var(--cream);
  border-bottom-right-radius: 3px;
}

.sc-bubble.assistant .sc-bubble-text {
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--cream);
  border-bottom-left-radius: 3px;
}

/* ── Markdown in bubbles ─────────────────────────────────────────── */
.sc-bubble-text.sc-md { white-space: normal }
.sc-bubble-text strong { font-weight: 600; color: var(--cream) }
.sc-bubble-text em { font-style: italic; opacity: 0.9 }
.sc-inline-code {
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--ff-mono, monospace);
  font-size: 12px;
}
.sc-code-block {
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--ff-mono, monospace);
  font-size: 12px;
  line-height: 1.5;
  margin: 6px 0;
  white-space: pre-wrap;
}
.sc-md-list {
  margin: 4px 0;
  padding-left: 18px;
}
.sc-md-list li {
  margin-bottom: 2px;
  line-height: 1.5;
}

/* ── Input ────────────────────────────────────────────────────────── */
.sc-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border2);
  flex-shrink: 0;
}

.sc-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--ff-body);
  font-size: 13px;
  font-weight: 300;
  color: var(--cream);
  resize: none;
  min-height: 22px;
  max-height: 100px;
  line-height: 1.5;
  padding-bottom: 2px;
}

.sc-input::placeholder { color: var(--muted2); }
.sc-input:disabled { opacity: 0.5; }

.sc-send {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--rose);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.sc-send:hover { background: #d4788a; }
.sc-send:disabled { opacity: 0.4; cursor: not-allowed; }

.sc-send svg {
  width: 13px;
  height: 13px;
  color: #fff;
}

.sc-footer {
  padding: 6px 14px 10px;
  font-size: 10px;
  color: var(--muted2);
  text-align: center;
  flex-shrink: 0;
}

/* ── Navigation button (inline in message) ────────────────────────── */
.sc-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 14px;
  background: var(--rose-bg);
  border: 1px solid rgba(194,105,122,0.3);
  border-radius: 8px;
  color: var(--rose);
  font-family: var(--ff-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.sc-nav-btn:hover { background: rgba(194,105,122,0.15); }
.sc-nav-btn svg { width: 13px; height: 13px; }

/* ── Escalation card (inline in message) ──────────────────────────── */
.sc-escalate-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
}
.sc-escalate-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--rose-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sc-escalate-icon svg { width: 14px; height: 14px; color: var(--rose); }
.sc-escalate-text { flex: 1; min-width: 0; }
.sc-escalate-label { font-size: 12px; font-weight: 500; color: var(--cream); }
.sc-escalate-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.sc-escalate-btn {
  padding: 6px 12px;
  background: var(--rose);
  border: none;
  border-radius: 7px;
  color: #fff;
  font-family: var(--ff-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.sc-escalate-btn:hover { background: #d4788a; }

/* ── Ticket modal ─────────────────────────────────────────────────── */
.sc-ticket-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sc-ticket-modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 420px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
.sc-ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border2);
}
.sc-ticket-title {
  font-family: var(--ff-display);
  font-size: 16px;
  font-weight: 400;
  color: var(--cream);
}
.sc-ticket-close {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted2); cursor: pointer; transition: all 0.15s;
}
.sc-ticket-close:hover { color: var(--cream); }
.sc-ticket-close svg { width: 13px; height: 13px; }
.sc-ticket-body { padding: 16px 20px; }
.sc-ticket-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.sc-ticket-input, .sc-ticket-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--ff-body);
  font-size: 13px;
  color: var(--cream);
  outline: none;
  transition: border-color 0.15s;
  resize: none;
  box-sizing: border-box;
}
.sc-ticket-input:focus,
.sc-ticket-textarea:focus { border-color: rgba(194,105,122,0.3); }
.sc-ticket-input::placeholder,
.sc-ticket-textarea::placeholder { color: var(--muted2); }
.sc-ticket-convo-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}
.sc-ticket-convo-note svg { color: var(--green); flex-shrink: 0; }
.sc-ticket-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border2);
}
.sc-ticket-cancel {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  font-family: var(--ff-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.sc-ticket-cancel:hover { color: var(--cream); border-color: rgba(240,232,224,0.15); }
.sc-ticket-submit {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  background: var(--rose);
  color: #fff;
  font-family: var(--ff-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.sc-ticket-submit:hover { background: #d4788a; }
.sc-ticket-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Launch button (in help screen) ───────────────────────────────── */
.sc-launch-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 12px;
  color: var(--cream);
  font-family: var(--ff-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 16px;
  margin-bottom: 20px;
}
.sc-launch-btn:hover {
  border-color: rgba(194,105,122,0.3);
  background: var(--bg2);
}
.sc-launch-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--rose-bg);
  border: 1px solid rgba(194, 105, 122, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sc-launch-icon svg {
  width: 16px;
  height: 16px;
  color: var(--rose);
}
.sc-launch-text {
  flex: 1;
  text-align: left;
}
.sc-launch-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--cream);
}
.sc-launch-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.sc-launch-arrow {
  color: var(--muted2);
  flex-shrink: 0;
}
.sc-launch-arrow svg {
  width: 16px;
  height: 16px;
}

/* ── Floating action button (persistent) ──────────────────────────── */
.sc-fab-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 198;
}
.sc-fab-wrap.hidden { display: none; }

.sc-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--rose);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(194, 105, 122, 0.4);
  transition: all 0.2s;
}
.sc-fab:hover {
  background: #d4788a;
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(194, 105, 122, 0.5);
}
.sc-fab svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

/* Dismiss X — appears on hover */
.sc-fab-dismiss {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.15s;
  z-index: 1;
}
.sc-fab-wrap:hover .sc-fab-dismiss {
  opacity: 1;
  transform: scale(1);
}
.sc-fab-dismiss:hover {
  background: var(--bg3);
  border-color: rgba(240, 232, 224, 0.2);
}
.sc-fab-dismiss svg {
  width: 10px;
  height: 10px;
  color: var(--muted);
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .sc-wrap {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .sc-wrap.expanded {
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  .sc-ticket-modal { width: 92%; }
}
