.ecs-chat-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1050;
  font-family: inherit;
}

.ecs-chat-fab {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, #0dcaf0 0%, #0d6efd 100%);
  color: #fff;
  box-shadow: 0 18px 40px rgba(2, 10, 25, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.ecs-chat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: min(360px, calc(100vw - 36px));
  height: 460px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(10, 30, 60, 0.18);
  background: var(--bs-body-bg);
  box-shadow: 0 24px 60px rgba(2, 10, 25, 0.22);
  display: none;
}

.ecs-chat-widget.open .ecs-chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.ecs-chat-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bs-tertiary-bg);
  border-bottom: 1px solid rgba(10, 30, 60, 0.12);
}

.ecs-chat-title {
  font-weight: 800;
  color: var(--bs-body-color);
}

.ecs-chat-close {
  border: 0;
  background: transparent;
  color: var(--bs-secondary-color);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.ecs-chat-close:hover {
  background: rgba(13, 110, 253, 0.08);
  color: var(--bs-body-color);
}

.ecs-chat-body {
  padding: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ecs-chat-messages {
  flex: 1 1 auto;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.ecs-chat-typing {
  flex: 0 0 auto;
  margin-top: 10px;
  padding: 6px 2px 0 2px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: var(--bs-secondary-color);
  font-size: 13px;
}

.ecs-chat-typing-text {
  font-style: italic;
  line-height: 1.1;
}

.ecs-chat-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ecs-chat-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(13, 110, 253, 0.55);
  display: inline-block;
  animation: ecsChatTyping 1.2s infinite ease-in-out;
}

.ecs-chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.ecs-chat-typing-dots span:nth-child(3) {
  animation-delay: 0.30s;
}

@keyframes ecsChatTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-2px); opacity: 1; }
}

.ecs-chat-msg {
  display: flex;
}

.ecs-chat-user {
  justify-content: flex-end;
}

.ecs-chat-bot {
  justify-content: flex-start;
}

.ecs-chat-bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--bs-body-color);
  background: var(--bs-tertiary-bg);
  border: 1px solid rgba(10, 30, 60, 0.10);
}

.ecs-chat-user .ecs-chat-bubble {
  background: rgba(13, 110, 253, 0.10);
  border-color: rgba(13, 110, 253, 0.22);
}

.ecs-chat-footer {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  background: var(--bs-body-bg);
  border-top: 1px solid rgba(10, 30, 60, 0.12);
}

.ecs-chat-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(10, 30, 60, 0.18);
  padding: 10px 12px;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
}

.ecs-chat-input:focus {
  outline: none;
  border-color: rgba(13, 110, 253, 0.55);
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.18);
}

.ecs-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  background: var(--bs-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ecs-chat-widget.busy .ecs-chat-send {
  opacity: 0.7;
  cursor: not-allowed;
}

.ecs-chat-modal {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: min(360px, calc(100vw - 36px));
  height: 460px;
  z-index: 1060;
}

.ecs-chat-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 18px;
}

.ecs-chat-modal-card {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 14px;
  border-radius: 16px;
  background: var(--bs-body-bg);
  border: 1px solid rgba(10, 30, 60, 0.18);
  box-shadow: 0 24px 60px rgba(2, 10, 25, 0.22);
  padding: 12px;
}

.ecs-chat-modal-title {
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--bs-body-color);
}

.ecs-chat-modal-form {
  display: grid;
  gap: 10px;
}

.ecs-chat-modal-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(10, 30, 60, 0.18);
  padding: 10px 12px;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
}

.ecs-chat-modal-input:focus {
  outline: none;
  border-color: rgba(13, 110, 253, 0.55);
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.18);
}

.ecs-chat-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ecs-chat-modal-btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.ecs-chat-modal-btn.primary {
  background: var(--bs-primary);
  color: #fff;
}

.ecs-chat-modal-btn.secondary {
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
}

.ecs-chat-modal-status {
  font-size: 12px;
  color: var(--bs-danger);
  min-height: 16px;
}

@media (max-width: 480px) {
  .ecs-chat-panel {
    height: 70vh;
  }

  .ecs-chat-modal {
    height: 70vh;
  }
}
