.chat-widget {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  font-family: 'Nunito', sans-serif;
}

.chat-fab {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: #f5c518;
  color: #1a4a1a;
  font-size: 1.7rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(26, 74, 26, 0.35);
}

.chat-fab:hover {
  transform: scale(1.06);
}

.chat-fab:focus-visible,
.chat-close:focus-visible,
#chatSend:focus-visible,
#chatInput:focus-visible {
  outline: 2px solid #f5c518;
  outline-offset: 2px;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 6rem));
  background: #ffffff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(11, 32, 14, 0.35);
}

.chat-panel[hidden] {
  display: none;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  background: #1a4a1a;
  color: #f5d77a;
}

.chat-close {
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}

.chat-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: #ffffff;
  border-bottom: 1px solid rgba(26, 74, 26, 0.12);
}

.chat-actions[hidden],
.chat-log[hidden],
.chat-form[hidden],
.lead-form[hidden] {
  display: none;
}

.chat-zalo,
.chat-order {
  flex: 1;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.6rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  border: 0;
}

.chat-zalo {
  background: #0068ff;
  color: #ffffff;
}

.chat-order {
  background: #f5c518;
  color: #1a4a1a;
}

.lead-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.8rem;
  overflow-y: auto;
  background: #fffde7;
}

.lead-form input,
.lead-form textarea {
  font: inherit;
  font-size: 16px;
  min-height: 42px;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(26, 74, 26, 0.25);
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
}

.lead-form small {
  color: #1a2a1a;
  opacity: 0.75;
}

.lead-buttons {
  display: flex;
  gap: 0.5rem;
}

.lead-buttons button {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#leadBack {
  background: #e7f7e8;
  color: #1a4a1a;
}

#leadSubmit {
  background: #1a4a1a;
  color: #ffffff;
}

#leadSubmit:disabled {
  opacity: 0.5;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #fffde7;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-msg {
  max-width: 85%;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  color: #1a2a1a;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-msg.bot {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid rgba(26, 74, 26, 0.12);
}

.chat-msg a {
  color: #2d7a2d;
  text-decoration: underline;
}

.chat-msg.user {
  align-self: flex-end;
  background: #2d7a2d;
  color: #ffffff;
}

.chat-msg.typing {
  opacity: 0.6;
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid rgba(26, 74, 26, 0.12);
  background: #ffffff;
}

#chatInput {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 0.9rem;
  font: inherit;
  font-size: 16px;
  border: 1px solid rgba(26, 74, 26, 0.25);
  border-radius: 999px;
}

#chatSend {
  min-height: 44px;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background: #1a4a1a;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

#chatSend:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 760px) {
  .chat-widget {
    bottom: 5.4rem;
  }

  .chat-panel {
    height: min(480px, calc(100vh - 9rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-fab:hover {
    transform: none;
  }
}
