.tgsc-root {
  --tgsc-widget-width: 380px;
  --tgsc-widget-height: 560px;
  --tgsc-offset-bottom: 20px;
  --tgsc-offset-right: 20px;
  --tgsc-button-bg: #9333ea;
  --tgsc-icon-size: 18px;

  position: fixed;
  right: var(--tgsc-offset-right);
  bottom: var(--tgsc-offset-bottom);
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.tgsc-toggle {
  height: 58px;
  border: none;
  border-radius: 999px;
  padding: 0 18px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: var(--tgsc-button-bg);
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.25);
  position: relative;
}

.tgsc-toggle-icon {
  width: calc(var(--tgsc-icon-size) + 16px);
  height: calc(var(--tgsc-icon-size) + 16px);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.tgsc-toggle-icon-image {
  width: var(--tgsc-icon-size);
  height: var(--tgsc-icon-size);
  object-fit: contain;
  display: block;
}

.tgsc-toggle-icon svg {
  width: var(--tgsc-icon-size);
  height: var(--tgsc-icon-size);
}

.tgsc-toggle-icon-only {
  width: 58px;
  padding: 0;
  justify-content: center;
}

.tgsc-toggle-label {
  font-size: 15px;
  font-weight: 600;
}

.tgsc-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.45);
  pointer-events: none;
}

.tgsc-widget {
  width: var(--tgsc-widget-width);
  height: var(--tgsc-widget-height);
  position: absolute;
  right: 0;
  bottom: 74px;
  border: 1px solid #d9dbe1;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 20px 36px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
}

.tgsc-manager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #0f172a;
  color: #ffffff;
}

.tgsc-manager-avatar-wrap {
  width: 40px;
  height: 40px;
  position: relative;
  flex-shrink: 0;
}

.tgsc-manager-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
}

.tgsc-manager-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1f2937;
  font-weight: 700;
}

.tgsc-manager-online {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  position: absolute;
  right: 0;
  bottom: 1px;
  border: 2px solid #0f172a;
  background: #22c55e;
}

.tgsc-manager-online.tgsc-manager-offline {
  background: #9ca3af;
}

.tgsc-manager-name {
  font-size: 14px;
  font-weight: 600;
}

.tgsc-manager-status {
  font-size: 12px;
  color: #cbd5e1;
}

.tgsc-close {
  margin-left: auto;
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.tgsc-queue-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.tgsc-queue-label {
  font-size: 12px;
  color: #334155;
}

.tgsc-queue {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px;
}

.tgsc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #f8fafc;
}

.tgsc-msg {
  margin-bottom: 10px;
  max-width: 90%;
}

.tgsc-msg-visitor {
  margin-left: auto;
  text-align: right;
}

.tgsc-msg-manager {
  margin-right: auto;
}

.tgsc-msg-author {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 3px;
}

.tgsc-msg-body {
  display: inline-block;
  padding: 8px 10px;
  border-radius: 10px;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}

.tgsc-msg-text {
  white-space: pre-wrap;
}

.tgsc-msg-status {
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.7;
}

.tgsc-msg-image {
  margin-top: 6px;
  max-width: 220px;
  border-radius: 8px;
  display: block;
}

.tgsc-msg-file {
  display: inline-block;
  margin-top: 6px;
}

.tgsc-msg-download {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 12px;
  text-decoration: none;
  background: #ffffff;
  color: #0f172a;
}

.tgsc-msg-video {
  margin-top: 6px;
  max-width: 220px;
  max-height: 280px;
  border-radius: 8px;
  display: block;
  background: #000;
}

.tgsc-msg-visitor .tgsc-msg-body {
  background: var(--tgsc-button-bg);
  color: #ffffff;
}

.tgsc-msg-manager .tgsc-msg-body {
  background: #e2e8f0;
  color: #0f172a;
}

.tgsc-typing {
  font-size: 12px;
  color: #64748b;
  padding: 0 12px 8px;
  background: #f8fafc;
}

.tgsc-rating {
  padding: 8px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff7ed;
}

.tgsc-rating-title {
  font-size: 12px;
  color: #7c2d12;
  margin-bottom: 6px;
}

.tgsc-rating-stars {
  display: flex;
  gap: 6px;
}

.tgsc-rate-btn {
  border: none;
  background: transparent;
  color: #f59e0b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.tgsc-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
}

.tgsc-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.tgsc-file {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

.tgsc-send,
.tgsc-attach {
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  color: #ffffff;
  cursor: pointer;
}

.tgsc-send {
  background: var(--tgsc-button-bg);
}

.tgsc-attach {
  background: #334155;
}

.tgsc-send:disabled,
.tgsc-attach:disabled,
.tgsc-input:disabled {
  opacity: 0.7;
}

@media (max-width: 640px) {
  .tgsc-root {
    right: 10px;
    bottom: 10px;
  }

  .tgsc-widget {
    width: min(94vw, var(--tgsc-widget-width));
    height: min(78vh, var(--tgsc-widget-height));
    bottom: 68px;
  }

  .tgsc-form {
    gap: 6px;
    padding: 8px;
  }

  .tgsc-input {
    font-size: 16px;
    padding: 10px;
  }

  .tgsc-send,
  .tgsc-attach {
    padding: 10px 11px;
    min-width: 56px;
  }
}
