/* ─── Writing Assistant — Chat Panel ────────────────────────────────────── */

/* Toggle button */
.wa-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-popover);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.wa-toggle-icon {
  font-size: 24px;
  line-height: 1;
}

/* Chat panel */
.wa-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: var(--z-popover);
  width: 400px;
  height: 520px;
  background: #1e1e2e;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.wa-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.wa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #181825;
  border-bottom: 1px solid #313244;
}

.wa-header-title {
  font-size: 14px;
  font-weight: 600;
  color: #cdd6f4;
  letter-spacing: 0.02em;
}

.wa-close {
  background: none;
  border: none;
  color: #6c7086;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.wa-close:hover {
  color: #f38ba8;
}

/* Quick action chips row */
.wa-quick-actions {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: #1e1e2e;
  border-bottom: 1px solid #313244;
  overflow-x: auto;
  flex-shrink: 0;
}

.wa-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid #45475a;
  background: #313244;
  color: #bac2de;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.wa-chip:hover {
  background: #45475a;
  color: #cdd6f4;
  border-color: #585b70;
}

/* Messages area */
.wa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wa-messages::-webkit-scrollbar {
  width: 6px;
}

.wa-messages::-webkit-scrollbar-thumb {
  background: #45475a;
  border-radius: 3px;
}

.wa-messages::-webkit-scrollbar-track {
  background: transparent;
}

/* Message bubbles */
.wa-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.wa-msg--user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.wa-msg--assistant {
  align-self: flex-start;
  background: #313244;
  color: #cdd6f4;
  border-bottom-left-radius: 4px;
}

/* Message sub-elements */
.wa-msg-action {
  font-weight: 500;
  margin-bottom: 6px;
  color: #a6e3a1;
}

.wa-msg-error {
  color: #f38ba8;
  font-size: 12px;
}

.wa-msg-clarify {
  margin-bottom: 8px;
  color: #f9e2af;
}

.wa-msg-result {
  margin-top: 6px;
  font-size: 12px;
  color: #bac2de;
}

.wa-msg-result strong {
  color: #cdd6f4;
}

.wa-msg-result pre {
  margin: 6px 0 0;
  padding: 8px;
  background: #181825;
  border-radius: 6px;
  font-size: 11px;
  overflow-x: auto;
  color: #a6adc8;
}

.wa-issue-list {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 12px;
}

.wa-issue-list li {
  margin-bottom: 2px;
}

.wa-rewritten {
  background: #181825;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: #a6adc8;
  margin-top: 4px;
  max-height: 120px;
  overflow-y: auto;
}

.wa-json {
  max-height: 100px;
  overflow-y: auto;
}

/* Action buttons within messages */
.wa-msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.wa-action-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid #45475a;
  background: #45475a;
  color: #cdd6f4;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}

.wa-action-btn:hover {
  background: #585b70;
}

.wa-action-accept {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.wa-action-accept:hover {
  background: #1d4ed8;
}

/* Clarification options */
.wa-clarify-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.wa-clarify-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #45475a;
  background: #1e1e2e;
  color: #89b4fa;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.wa-clarify-btn:hover {
  background: #313244;
  border-color: #89b4fa;
}

/* Next-step suggestion chips */
.wa-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.wa-suggestion-chip {
  padding: 3px 10px;
  border-radius: 10px;
  border: 1px solid #45475a;
  background: transparent;
  color: #89b4fa;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.wa-suggestion-chip:hover {
  background: rgba(137, 180, 250, 0.1);
  border-color: #89b4fa;
}

/* Typing indicator */
.wa-typing {
  color: #6c7086;
  font-style: italic;
  font-size: 12px;
}

/* Input area */
.wa-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #313244;
  background: #181825;
}

.wa-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #45475a;
  background: #1e1e2e;
  color: #cdd6f4;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.wa-input::placeholder {
  color: #6c7086;
}

.wa-input:focus {
  border-color: #2563eb;
}

.wa-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.wa-send:hover {
  background: #1d4ed8;
}

/* ─── Mobile: full-width bottom sheet ─────────────────────────────────── */

@media (max-width: 480px) {
  .wa-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 70vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .wa-panel--open {
    transform: translateY(0);
  }

  .wa-toggle {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .wa-toggle-icon {
    font-size: 20px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .wa-panel {
    width: 340px;
    height: 460px;
    right: 16px;
    bottom: 80px;
  }
}
