.scw-widget {
  --scw-primary: #17a34a;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999999;
  font-family: inherit;
}

.scw-fab {
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--scw-primary), #0f8a3d);
  color: #fff;
  box-shadow: 0 14px 40px rgba(23,163,74,.35);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  transition: all .25s ease;
}

.scw-fab:hover {
  transform: translateY(-2px) scale(1.03);
}

.scw-fab-icon {
  position: absolute;
  transition: all .25s ease;
}

.scw-icon-close {
  opacity: 0;
  transform: scale(.6) rotate(-90deg);
}

.scw-fab.active .scw-icon-chat {
  opacity: 0;
  transform: scale(.6) rotate(90deg);
}

.scw-fab.active .scw-icon-close {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.scw-popup {
  position: absolute;
  bottom: 84px;
  right: 0;
  width: 390px;
  max-width: calc(100vw - 24px);
  height: 680px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(15,23,42,.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(.98);
  transition: all .28s ease;
}

.scw-popup.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.scw-popup-inner,
.scw-screen {
  width: 100%;
  height: 100%;
}

.scw-screen-form {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top right, rgba(23,163,74,.10), transparent 28%),
    radial-gradient(circle at bottom left, rgba(0,0,0,.03), transparent 24%),
    #f8fafc;
}

.scw-popup-header {
  background: linear-gradient(135deg, var(--scw-primary), #11913f);
  color: #fff;
  padding: 24px 20px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.scw-popup-avatar-main {
  width: 58px;
  height: 58px;
  position: relative;
  flex: 0 0 58px;
}

.scw-popup-avatar-fallback,
.scw-chat-avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  border: 2px solid rgba(255,255,255,.25);
  backdrop-filter: blur(8px);
}

.scw-popup-head-text h3 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
}

.scw-popup-head-text p {
  margin: 0;
  font-size: 13px;
  opacity: .92;
}

.scw-online-dot {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #22c55e;
  bottom: 2px;
  left: 2px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 4px rgba(34,197,94,.12);
}

.scw-popup-body {
  padding: 18px;
  flex: 1;
  overflow-y: auto;
}

.scw-welcome-box {
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(15,23,42,.06);
  color: #334155;
  line-height: 2;
  font-size: 14px;
}

.scw-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scw-field-input label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.scw-field-input input,
.scw-field-input textarea {
  width: 100%;
  border: 1px solid #dbe4ee;
  border-radius: 16px;
  padding: 13px 14px;
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: all .2s ease;
  box-sizing: border-box;
}

.scw-field-input input:focus,
.scw-field-input textarea:focus {
  border-color: var(--scw-primary);
  box-shadow: 0 0 0 4px rgba(23,163,74,.10);
}

.scw-start-btn {
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--scw-primary), #129840);
  color: #fff;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(23,163,74,.22);
}

.scw-screen-chat {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top right, rgba(23,163,74,.08), transparent 22%),
    linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
}

.scw-chat-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--scw-primary), #129840);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scw-chat-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scw-chat-avatar {
  width: 48px;
  height: 48px;
  position: relative;
  flex: 0 0 48px;
}

.scw-chat-user-meta strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.scw-chat-user-meta span {
  font-size: 12px;
  opacity: .92;
}

.scw-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scw-msg {
  display: flex;
  max-width: 86%;
}

.scw-msg-admin {
  align-self: flex-start;
}

.scw-msg-user {
  align-self: flex-end;
}

.scw-msg-bubble {
  border-radius: 18px;
  padding: 10px 12px 8px;
  box-shadow: 0 10px 28px rgba(15,23,42,.06);
  word-break: break-word;
}

.scw-msg-admin .scw-msg-bubble {
  background: #fff;
  color: #1e293b;
  border-top-right-radius: 6px;
}

.scw-msg-user .scw-msg-bubble {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  color: #14532d;
  border-top-left-radius: 6px;
}

.scw-msg-text {
  font-size: 14px;
  line-height: 1.9;
}

.scw-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  font-size: 11px;
  margin-top: 8px;
  opacity: .75;
}

.scw-msg-status {
  font-size: 12px;
  color: #64748b;
  min-width: 18px;
  text-align: center;
}

.scw-msg-status .seen {
  color: #1d9bf0;
  font-weight: 700;
}

.scw-chat-tools {
  padding: 10px 12px 12px;
}

.scw-chat-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(255,255,255,.9);
  border: 1px solid #dbe4ee;
  border-radius: 22px;
  padding: 8px;
  box-shadow: 0 10px 24px rgba(15,23,42,.06);
}

.scw-tool-btn,
.scw-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: #f1f5f9;
  cursor: pointer;
  flex: 0 0 42px;
  font-size: 18px;
}

.scw-send-btn {
  background: linear-gradient(135deg, var(--scw-primary), #129840);
  color: #fff;
  box-shadow: 0 10px 22px rgba(23,163,74,.22);
}

.scw-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 14px;
  line-height: 1.8;
  max-height: 120px;
  min-height: 42px;
  padding: 9px 2px 4px;
  box-sizing: border-box;
}

.scw-emoji-panel {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
  background: rgba(255,255,255,.96);
  padding: 12px;
  border-radius: 18px;
  border: 1px solid #dbe4ee;
  box-shadow: 0 10px 24px rgba(15,23,42,.06);
}

.scw-emoji-panel.active {
  display: grid;
}

.scw-emoji-panel button {
  border: none;
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
  font-size: 20px;
  cursor: pointer;
}

.scw-attach-preview {
  display: none;
  margin-bottom: 10px;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: #334155;
}

.scw-attach-preview.active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.scw-attach-remove {
  border: none;
  background: #ef4444;
  color: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.scw-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 34px;
  min-height: 16px;
}

.scw-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  display: block;
  animation: scwTyping 1.2s infinite ease-in-out;
}

.scw-typing-dots span:nth-child(2) { animation-delay: .15s; }
.scw-typing-dots span:nth-child(3) { animation-delay: .30s; }

@keyframes scwTyping {
  0%, 80%, 100% {
    transform: scale(.7);
    opacity: .45;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 520px) {
  .scw-widget {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .scw-popup {
    right: 0;
    left: 0;
    width: auto;
    height: calc(100vh - 92px);
    max-height: calc(100vh - 92px);
    bottom: 78px;
    border-radius: 24px;
  }

  .scw-fab {
    width: 58px;
    height: 58px;
    font-size: 24px;
    margin-right: auto;
  }

  .scw-msg {
    max-width: 92%;
  }
}
