/* 现代客服小部件样式（借鉴合从风格） */
:root {
  --widget-primary: #3b82f6;
  --widget-primary-hover: #2563eb;
  --widget-bg: #f3f6fb;
  --widget-surface: #ffffff;
  --widget-border: #e8eef5;
  --widget-text: #1e293b;
  --widget-muted: #64748b;
  --widget-radius: 16px;
  --widget-shadow: 0 4px 24px rgba(59, 130, 246, 0.08);
}

.widget-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--widget-bg);
}

.widget-header {
  background: linear-gradient(180deg, #eef6ff 0%, #f8fbff 55%, #ffffff 100%);
  border-bottom: 1px solid var(--widget-border);
  padding: 0.85rem 1rem 0.7rem;
  flex-shrink: 0;
}

.widget-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.widget-header .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
  flex-shrink: 0;
  overflow: hidden;
}

.widget-header .brand-logo.has-image {
  background: #f3f4f6;
  box-shadow: none;
}

.widget-header .brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.widget-header .header-info h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--widget-text);
  line-height: 1.2;
}

.widget-header .header-subtitle {
  font-size: 0.72rem;
  color: var(--widget-muted);
  margin-top: 0.1rem;
}

.widget-header .header-status {
  display: none !important;
  font-size: 0.68rem;
  color: var(--widget-muted);
  margin-top: 0.35rem;
  padding-left: 3.25rem;
}

.widget-header .header-status.connected { color: #10b981; }
.widget-header .header-status.disconnected { color: #ef4444; }
.widget-header .header-status.connecting { color: #f59e0b; }

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--widget-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: #fff;
  color: var(--widget-primary);
}

.icon-btn.active {
  color: var(--widget-primary);
  background: rgba(59, 130, 246, 0.12);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  background: var(--widget-bg);
}

.welcome-card {
  background: var(--widget-surface);
  border-radius: var(--widget-radius);
  padding: 1rem;
  box-shadow: var(--widget-shadow);
  border: 1px solid var(--widget-border);
  max-width: 92%;
  align-self: flex-start;
}

.welcome-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--widget-text);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.faq-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.faq-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: #f0f6ff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--widget-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
}

.faq-item:hover {
  background: #e0efff;
  border-color: #93c5fd;
}

.faq-item .faq-chevron {
  color: #94a3b8;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.quick-actions {
  display: flex;
  gap: 0.45rem;
  padding: 0.5rem 1rem 0;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar { display: none; }

.quick-pill {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--widget-border);
  background: var(--widget-surface);
  color: var(--widget-text);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}

.quick-pill:hover {
  border-color: #93c5fd;
  color: var(--widget-primary);
}

.quick-pill.primary {
  background: var(--widget-primary);
  border-color: var(--widget-primary);
  color: #fff;
}

.quick-pill.primary:hover {
  background: var(--widget-primary-hover);
}

.widget-input {
  flex-shrink: 0;
  padding: 0.5rem 1rem 0.85rem;
  background: var(--widget-surface);
  border-top: 1px solid var(--widget-border);
  position: relative;
}

.input-pill {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  background: #f8fafc;
  border: 1px solid var(--widget-border);
  border-radius: 999px;
  padding: 0.35rem 0.35rem 0.35rem 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-pill:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background: #fff;
}

.input-pill textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.45;
  min-height: 22px;
  max-height: 100px;
  padding: 0.35rem 0;
  color: var(--widget-text);
}

.input-tools {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.tool-btn,
.send-circle {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  flex: 0 0 36px;
  box-sizing: border-box;
  padding: 0;
}

.tool-btn {
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--widget-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.tool-btn svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: currentColor;
}

.tool-btn:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.1);
  color: var(--widget-primary);
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-btn.recording {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  animation: pulse-rec 1s infinite;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.send-circle {
  border: none;
  border-radius: 50%;
  background: var(--widget-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.send-circle:hover:not(:disabled) {
  background: var(--widget-primary-hover);
  transform: scale(1.05);
}

.send-circle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.send-circle svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
  margin-left: 1px;
}

.emoji-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 1rem;
  right: 1rem;
  background: var(--widget-surface);
  border: 1px solid var(--widget-border);
  border-radius: 12px;
  padding: 0.65rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 20;
  max-height: 180px;
  overflow-y: auto;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.2rem;
}

.emoji-btn {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  line-height: 1;
}

.emoji-btn:hover {
  background: #f0f6ff;
}

/* 消息气泡现代化 */
.widget-shell .message {
  max-width: 82%;
  border-radius: 14px;
  padding: 0.7rem 0.95rem;
  font-size: 0.9rem;
}

.widget-shell .message.sent {
  background: var(--widget-primary);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.widget-shell .message.sent .meta {
  color: rgba(255, 255, 255, 0.92);
}

.widget-shell .message.sent .read-receipt.read {
  color: #fff;
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.widget-shell .message.received {
  background: var(--widget-surface);
  border: 1px solid var(--widget-border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--widget-shadow);
}

.widget-shell .message.assistant {
  background: var(--widget-surface);
  border: 1px solid #dbeafe;
  box-shadow: var(--widget-shadow);
}

.widget-shell .message.assistant .meta {
  color: var(--widget-primary);
}

.voice-recording-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #fef2f2;
  color: #dc2626;
  font-size: 0.82rem;
  border-top: 1px solid #fecaca;
}

.voice-recording-bar.hidden { display: none; }

.message-audio {
  width: 100%;
  min-width: 200px;
  max-width: 260px;
  height: 36px;
}

.offline-form-card {
  margin: 12px 0 4px;
  padding: 14px 16px;
  background: var(--widget-surface);
  border: 1px solid var(--widget-border);
  border-radius: 12px;
  box-shadow: var(--widget-shadow);
}

.offline-form-hint {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--widget-text);
  line-height: 1.5;
}

.offline-form-field {
  display: block;
  margin-bottom: 10px;
}

.offline-form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--widget-muted);
}

.offline-form-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--widget-border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--widget-text);
  background: #fff;
  box-sizing: border-box;
}

.offline-form-field input:focus {
  outline: none;
  border-color: var(--widget-primary);
}

.offline-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.offline-form-submit {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: #10b981;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.offline-form-submit svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.offline-form-submit:hover {
  background: #059669;
}

.widget-header .header-status.offline-service {
  color: #f59e0b;
}

#chat-screen.widget-shell {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  box-shadow: 0 8px 40px rgba(15, 23, 42, 0.1);
  border-left: 1px solid var(--widget-border);
  border-right: 1px solid var(--widget-border);
  align-items: stretch;
  justify-content: flex-start;
}

.embed-mode .widget-shell {
  max-width: none;
  margin: 0;
  box-shadow: none;
  border: none;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.embed-mode .widget-header {
  padding: 0.7rem 0.85rem 0.55rem;
}

.embed-mode .widget-messages {
  padding: 0.75rem;
}

@media (max-width: 480px) {
  .quick-pill { font-size: 0.75rem; padding: 0.35rem 0.7rem; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
}
