:root {
  --ecoabc-chat-primary: #2f9e44;
  --ecoabc-chat-primary-dark: #237032;
  --ecoabc-chat-bg: #ffffff;
  --ecoabc-chat-surface: #f6f8f7;
  --ecoabc-chat-text: #1f2933;
  --ecoabc-chat-muted: #6b7280;
  --ecoabc-chat-border: #e5e7eb;
  --ecoabc-chat-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
  --ecoabc-chat-radius: 18px;
}

.ecoabc-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  font-family: inherit;
}

.ecoabc-chat__toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--ecoabc-chat-primary), var(--ecoabc-chat-primary-dark));
  color: #fff;
  box-shadow: var(--ecoabc-chat-shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ecoabc-chat__toggle:hover,
.ecoabc-chat__toggle:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 22px 50px rgba(47, 158, 68, 0.35);
  outline: none;
}

.ecoabc-chat__toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ecoabc-chat__toggle-icon svg {
  display: block;
  width: 26px;
  height: 26px;
}

.ecoabc-chat.is-open .ecoabc-chat__toggle {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

.ecoabc-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 24px));
  background: var(--ecoabc-chat-bg);
  border: 1px solid var(--ecoabc-chat-border);
  border-radius: var(--ecoabc-chat-radius);
  box-shadow: var(--ecoabc-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ecoabc-chat__panel[hidden] {
  display: none !important;
}

.ecoabc-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--ecoabc-chat-primary), var(--ecoabc-chat-primary-dark));
  color: #fff;
}

.ecoabc-chat__title {
  display: block;
  font-size: 16px;
}

.ecoabc-chat__subtitle {
  display: block;
  font-size: 12px;
  opacity: 0.9;
}

.ecoabc-chat__close {
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ecoabc-chat__intro {
  display: grid;
  gap: 10px;
  padding: 12px 16px 0;
}

.ecoabc-chat__intro label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--ecoabc-chat-muted);
}

.ecoabc-chat__intro input {
  border: 1px solid var(--ecoabc-chat-border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.ecoabc-chat__intro.is-hidden {
  display: none;
}

.ecoabc-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--ecoabc-chat-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ecoabc-chat__bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.ecoabc-chat__bubble time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.65;
}

.ecoabc-chat__bubble.is-customer {
  align-self: flex-end;
  background: var(--ecoabc-chat-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ecoabc-chat__bubble.is-admin {
  align-self: flex-start;
  background: #fff;
  color: var(--ecoabc-chat-text);
  border: 1px solid var(--ecoabc-chat-border);
  border-bottom-left-radius: 4px;
}

.ecoabc-chat__sender {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ecoabc-chat-primary-dark);
  margin-bottom: 6px;
}

.ecoabc-chat__text {
  white-space: pre-wrap;
  word-break: break-word;
}

.ecoabc-chat__bubble.is-system {
  align-self: center;
  background: transparent;
  color: var(--ecoabc-chat-muted);
  font-size: 12px;
  text-align: center;
}

.ecoabc-chat__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--ecoabc-chat-border);
  background: #fff;
}

.ecoabc-chat__form textarea {
  resize: none;
  border: 1px solid var(--ecoabc-chat-border);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  min-height: 44px;
}

.ecoabc-chat__send {
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  background: var(--ecoabc-chat-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.ecoabc-chat__send:disabled {
  opacity: 0.6;
  cursor: wait;
}

@media (max-width: 480px) {
  .ecoabc-chat {
    right: 12px;
    bottom: 12px;
  }

  .ecoabc-chat__toggle-label {
    display: none;
  }

  .ecoabc-chat__toggle {
    width: 56px;
    height: 56px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .ecoabc-chat__panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    right: -8px;
    bottom: -8px;
    border-radius: 16px;
  }

  .ecoabc-chat__form {
    grid-template-columns: 1fr;
  }

  .ecoabc-chat__send {
    width: 100%;
    padding: 12px;
  }
}
