.online-chat-root {
  --online-chat-accent: #1f6feb;
  --online-chat-bg: #ffffff;
  --online-chat-border: rgba(15, 23, 42, 0.08);
  --online-chat-text: #0f172a;
  --online-chat-muted: #64748b;
  --online-chat-shadow: 0 28px 80px rgba(15, 23, 42, 0.18);
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--online-chat-text);
}

.online-chat-root[data-online-chat-mode="floating"] {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99999;
}

.online-chat-floating-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.online-chat-hint {
  border: 0;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
  cursor: pointer;
  position: relative;
  animation: online-chat-hint-float 3.2s ease-in-out infinite;
}

.online-chat-hint::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  transform: rotate(45deg);
  border-radius: 2px;
}

.online-chat-root-open .online-chat-hint {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.online-chat-launcher {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--online-chat-accent), #22c55e);
  color: #fff;
  padding: 16px 22px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--online-chat-shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  position: relative;
  animation: online-chat-launcher-breath 2.8s ease-in-out infinite;
}

.online-chat-launcher::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: inherit;
  border: 2px solid color-mix(in srgb, var(--online-chat-accent) 50%, white);
  opacity: 0.65;
  animation: online-chat-pulse 2.2s ease-out infinite;
}

.online-chat-launcher-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.18);
}

.online-chat-panel {
  display: none;
  width: min(380px, calc(100vw - 24px));
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 14%);
  border: 1px solid var(--online-chat-border);
  border-radius: 22px;
  box-shadow: var(--online-chat-shadow);
  overflow: hidden;
}

.online-chat-panel-open {
  display: block;
}

.online-chat-root[data-online-chat-mode="floating"] .online-chat-panel {
  margin-top: 12px;
}

.online-chat-root[data-online-chat-mode="inline"] .online-chat-panel,
.online-chat-root[data-online-chat-mode="embed"] .online-chat-panel {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 640px;
}

.online-chat-embed-body {
  margin: 0;
  background: transparent;
}

.online-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 14px;
}

.online-chat-header-title {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.1;
  font-weight: 700;
}

.online-chat-header p,
.online-chat-meta,
.online-chat-status-text,
.online-chat-empty,
.online-chat-message-time {
  color: var(--online-chat-muted);
}

.online-chat-header p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.online-chat-close {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--online-chat-muted);
}

.online-chat-meta {
  padding: 0 20px 16px;
  font-size: 13px;
}

.online-chat-messages {
  min-height: 300px;
  max-height: 360px;
  overflow-y: auto;
  padding: 0 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.online-chat-empty {
  padding: 18px;
  background: #eef6ff;
  border-radius: 16px;
}

.online-chat-message {
  max-width: 88%;
  padding: 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
}

.online-chat-message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 100%;
}

.online-chat-message-row.visitor {
  justify-content: flex-end;
}

.online-chat-message-row.admin {
  justify-content: flex-start;
}

.online-chat-avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
}

.online-chat-avatar.visitor {
  order: 2;
  background: #dbeafe;
  color: #1d4ed8;
}

.online-chat-avatar.admin {
  background: #d1fae5;
  color: #047857;
}

.online-chat-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.online-chat-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.online-chat-message.visitor {
  margin-left: auto;
  background: linear-gradient(135deg, var(--online-chat-accent), #0ea5e9);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.online-chat-message.admin {
  background: #eff6ff;
  border-bottom-left-radius: 6px;
}

.online-chat-message.visitor .online-chat-message-time,
.online-chat-message.visitor .online-chat-message-label {
  color: rgba(255, 255, 255, 0.82);
}

.online-chat-message-label {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.online-chat-message-time {
  font-size: 11px;
  margin-top: 8px;
}

.online-chat-form {
  padding: 18px 20px 20px;
  background: #fff;
  border-top: 1px solid var(--online-chat-border);
}

.online-chat-input {
  width: 100%;
  min-height: 104px;
  border-radius: 16px;
  border: 1px solid #dbe4f0;
  resize: vertical;
  padding: 14px;
  box-sizing: border-box;
  font: inherit;
}

.online-chat-input:focus {
  outline: 2px solid color-mix(in srgb, var(--online-chat-accent) 40%, white);
  border-color: var(--online-chat-accent);
}

.online-chat-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.online-chat-status-text {
  font-size: 12px;
  line-height: 1.4;
  margin-right: auto;
}

.online-chat-status-text:empty {
  display: none;
}

.online-chat-submit {
  border: 0;
  border-radius: 999px;
  background: var(--online-chat-accent);
  color: #fff;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.online-chat-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .online-chat-root[data-online-chat-mode="floating"] {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }

  .online-chat-root[data-online-chat-mode="floating"] .online-chat-panel {
    width: 100%;
  }

  .online-chat-launcher {
    width: 100%;
    justify-content: center;
  }

  .online-chat-hint {
    max-width: calc(100vw - 48px);
  }
}

@keyframes online-chat-pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.08);
    opacity: 0;
  }
  100% {
    transform: scale(1.12);
    opacity: 0;
  }
}

@keyframes online-chat-launcher-breath {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes online-chat-hint-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
