/* ============================================================
   Claude Support Chat Widget — chat.css
   ============================================================ */

/* ── CSS Custom Properties ────────────────────────────────── */
:root {
  --cs-blue:       #2271b1;
  --cs-blue-dark:  #1a5a8f;
  --cs-blue-light: #d0e8f8;
  --cs-white:      #ffffff;
  --cs-gray-50:    #f8f9fa;
  --cs-gray-100:   #f0f2f5;
  --cs-gray-200:   #e4e6ea;
  --cs-gray-400:   #9ca3af;
  --cs-gray-600:   #6b7280;
  --cs-gray-800:   #1f2937;
  --cs-radius:     16px;
  --cs-shadow:     0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.10);
  --cs-btn-size:   60px;
  --cs-z:          9999;
  --cs-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base Widget Container ────────────────────────────────── */
#claude-support-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--cs-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cs-gray-800);
}

/* ── Floating Toggle Button ───────────────────────────────── */
.claude-support-toggle {
  position: relative;
  width: var(--cs-btn-size);
  height: var(--cs-btn-size);
  border-radius: 50%;
  background: var(--cs-blue);
  color: var(--cs-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(34, 113, 177, 0.45);
  transition: background var(--cs-transition), transform var(--cs-transition), box-shadow var(--cs-transition);
  outline-offset: 3px;
}

.claude-support-toggle:hover {
  background: var(--cs-blue-dark);
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(34, 113, 177, 0.55);
}

.claude-support-toggle:active {
  transform: scale(0.97);
}

.claude-support-toggle svg {
  width: 26px;
  height: 26px;
  transition: opacity var(--cs-transition), transform var(--cs-transition);
}

.claude-support-toggle .icon-chat {
  position: absolute;
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.claude-support-toggle .icon-close {
  position: absolute;
  opacity: 0;
  transform: scale(0.6) rotate(-90deg);
}

/* When panel is open, swap icons */
#claude-support-widget.panel-open .claude-support-toggle .icon-chat {
  opacity: 0;
  transform: scale(0.6) rotate(90deg);
}

#claude-support-widget.panel-open .claude-support-toggle .icon-close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Notification badge */
.claude-support-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #e53e3e;
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--cs-white);
}

/* ── Chat Panel ───────────────────────────────────────────── */
.claude-support-panel {
  position: absolute;
  bottom: calc(var(--cs-btn-size) + 12px);
  right: 0;
  width: 380px;
  height: 520px;
  background: var(--cs-white);
  border-radius: var(--cs-radius);
  box-shadow: var(--cs-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Animation */
  transform-origin: bottom right;
  transform: scale(0.85) translateY(10px);
  opacity: 0;
  transition: transform var(--cs-transition), opacity var(--cs-transition);
  pointer-events: none;
}

.claude-support-panel:not([hidden]) {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Override hidden attribute for animation (use class toggle instead) */
.claude-support-panel[hidden] {
  display: flex !important; /* keep in DOM for animation */
  pointer-events: none;
}

/* ── Header ───────────────────────────────────────────────── */
.claude-support-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--cs-blue);
  color: var(--cs-white);
  flex-shrink: 0;
}

.claude-support-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.claude-support-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.claude-support-avatar svg {
  width: 20px;
  height: 20px;
}

.claude-support-header-name {
  font-weight: 600;
  font-size: 15px;
}

.claude-support-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  opacity: 0.9;
  margin-top: 1px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.online  { background: #4ade80; }
.status-dot.offline { background: #f87171; }

.claude-support-close-btn {
  background: transparent;
  border: none;
  color: var(--cs-white);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity var(--cs-transition), background var(--cs-transition);
}

.claude-support-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.claude-support-close-btn svg {
  width: 20px;
  height: 20px;
}

/* ── Contact Form ─────────────────────────────────────────── */
.claude-support-contact-form {
  padding: 10px 14px 6px;
  background: var(--cs-gray-50);
  border-bottom: 1px solid var(--cs-gray-200);
  flex-shrink: 0;
}

.contact-form-intro {
  font-size: 12px;
  color: var(--cs-gray-600);
  margin: 0 0 6px;
}

.claude-support-input-field {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--cs-gray-200);
  border-radius: 8px;
  font-size: 13px;
  color: var(--cs-gray-800);
  background: var(--cs-white);
  margin-bottom: 5px;
  transition: border-color 0.2s;
}

.claude-support-input-field:focus {
  outline: none;
  border-color: var(--cs-blue);
  box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
}

.claude-support-input-field:last-child {
  margin-bottom: 0;
}

/* ── Messages ─────────────────────────────────────────────── */
.claude-support-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.claude-support-messages::-webkit-scrollbar {
  width: 4px;
}

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

.claude-support-messages::-webkit-scrollbar-thumb {
  background: var(--cs-gray-200);
  border-radius: 2px;
}

/* Message wrapper */
.cs-message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: cs-msg-in 0.2s ease-out;
}

@keyframes cs-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cs-message.user-message {
  align-self: flex-end;
  align-items: flex-end;
}

.cs-message.agent-message {
  align-self: flex-start;
  align-items: flex-start;
}

/* Bubble */
.cs-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.user-message .cs-bubble {
  background: var(--cs-blue);
  color: var(--cs-white);
  border-bottom-right-radius: 4px;
}

.agent-message .cs-bubble {
  background: var(--cs-gray-100);
  color: var(--cs-gray-800);
  border-bottom-left-radius: 4px;
}

/* Streaming agent message — grows as text arrives */
.agent-message.streaming .cs-bubble {
  background: var(--cs-gray-100);
}

/* Timestamp */
.cs-timestamp {
  font-size: 11px;
  color: var(--cs-gray-400);
  margin-top: 3px;
  padding: 0 2px;
}

/* Links inside agent messages */
.agent-message .cs-bubble a {
  color: var(--cs-blue);
  text-decoration: underline;
}

/* Bold */
.agent-message .cs-bubble strong {
  font-weight: 600;
}

/* Code blocks */
.agent-message .cs-bubble code {
  background: var(--cs-gray-200);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}

/* ── Typing Indicator ─────────────────────────────────────── */
.claude-support-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 8px;
  flex-shrink: 0;
}

.claude-support-typing[hidden] {
  display: none;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--cs-gray-100);
  padding: 8px 12px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--cs-gray-400);
  border-radius: 50%;
  animation: cs-bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cs-bounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1;   }
}

.typing-label {
  font-size: 12px;
  color: var(--cs-gray-400);
  font-style: italic;
}

/* ── Input Area ───────────────────────────────────────────── */
.claude-support-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--cs-gray-200);
  background: var(--cs-white);
  flex-shrink: 0;
}

.claude-support-textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--cs-gray-200);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--cs-gray-800);
  background: var(--cs-gray-50);
  line-height: 1.45;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.claude-support-textarea:focus {
  outline: none;
  border-color: var(--cs-blue);
  background: var(--cs-white);
  box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
}

.claude-support-textarea::placeholder {
  color: var(--cs-gray-400);
}

.claude-support-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--cs-blue);
  color: var(--cs-white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--cs-transition), transform var(--cs-transition);
}

.claude-support-send-btn:hover:not(:disabled) {
  background: var(--cs-blue-dark);
  transform: scale(1.08);
}

.claude-support-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.claude-support-send-btn:disabled {
  background: var(--cs-gray-200);
  color: var(--cs-gray-400);
  cursor: not-allowed;
}

.claude-support-send-btn svg {
  width: 18px;
  height: 18px;
}

/* ── Mobile Responsive ────────────────────────────────────── */
@media (max-width: 480px) {
  #claude-support-widget {
    bottom: 16px;
    right: 16px;
  }

  .claude-support-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform-origin: bottom center;
  }

  .claude-support-panel:not([hidden]) {
    transform: translateY(0);
  }

  .claude-support-panel[hidden] {
    transform: translateY(100%);
  }
}

/* ── Accessibility ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .claude-support-toggle,
  .claude-support-panel,
  .cs-message,
  .typing-dot {
    transition: none;
    animation: none;
  }
}
