/* ==========================================
   NOBLE REALTY — CHAT ASSISTANT WIDGET
   ========================================== */

.chatbot-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: var(--radius-full);
  background-color: var(--color-accent);
  color: var(--color-primary);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-premium);
  transition: var(--transition-smooth);
}

.chatbot-launcher:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
}

.chatbot-launcher:focus-visible,
.chatbot-panel button:focus-visible,
.chatbot-panel input:focus-visible,
.chatbot-panel select:focus-visible,
.chatbot-panel textarea:focus-visible {
  outline: 3px solid var(--color-accent-dark);
  outline-offset: 2px;
}

.chatbot-launcher svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  transition: var(--transition-smooth);
}

.chatbot-launcher .icon-close {
  position: absolute;
  opacity: 0;
  transform: scale(0.6);
}

.chatbot-launcher.is-open .icon-chat {
  opacity: 0;
  transform: scale(0.6);
}

.chatbot-launcher.is-open .icon-close {
  opacity: 1;
  transform: scale(1);
}

.chatbot-launcher .chatbot-ping {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #dc2626;
  border: 2px solid var(--color-bg-white);
}

.chatbot-launcher .chatbot-ping[hidden] {
  display: none;
}

.chatbot-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background-color: var(--color-bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border-light);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: var(--transition-smooth);
}

.chatbot-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chatbot-header {
  background-color: var(--color-primary);
  color: var(--color-text-light);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chatbot-header .chatbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--color-accent);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-headings);
  font-weight: 700;
  flex-shrink: 0;
}

.chatbot-header .chatbot-header-text {
  flex: 1;
  min-width: 0;
}

.chatbot-header h2 {
  font-family: var(--font-headings);
  font-size: 1rem;
  letter-spacing: 0.03em;
  margin: 0;
  color: var(--color-text-light);
}

.chatbot-header p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--color-text-muted-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-header p .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #22c55e;
  display: inline-block;
}

.chatbot-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted-light);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  line-height: 0;
  flex-shrink: 0;
}

.chatbot-close:hover {
  color: var(--color-text-light);
  background-color: rgba(255, 255, 255, 0.08);
}

.chatbot-close svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.chatbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--color-bg-light);
  scroll-behavior: smooth;
}

.chatbot-body:focus {
  outline: none;
}

.chat-msg {
  max-width: 85%;
  font-size: 0.875rem;
  line-height: 1.45;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  word-wrap: break-word;
}

.chat-msg.bot {
  align-self: flex-start;
  background-color: var(--color-bg-white);
  color: var(--color-text-dark);
  border: 1px solid var(--color-border-light);
  border-bottom-left-radius: 2px;
}

.chat-msg.user {
  align-self: flex-end;
  background-color: var(--color-primary);
  color: var(--color-text-light);
  border-bottom-right-radius: 2px;
}

.chat-msg.system-note {
  align-self: center;
  background: none;
  border: none;
  color: var(--color-text-muted-dark);
  font-size: 0.72rem;
  text-align: center;
  padding: 2px 8px;
  max-width: 100%;
}

.chat-msg p {
  margin: 0 0 8px;
}

.chat-msg p:last-child {
  margin-bottom: 0;
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background-color: var(--color-bg-white);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 2px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-text-muted-dark);
  animation: chatTypingBounce 1.2s infinite ease-in-out;
}

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

@keyframes chatTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-quick-replies {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}

.chat-quick-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-accent);
  background-color: var(--color-bg-white);
  color: var(--color-accent-dark);
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: left;
}

.chat-quick-btn:hover {
  background-color: var(--color-accent);
  color: var(--color-primary);
}

.chat-quick-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-form {
  align-self: stretch;
  background-color: var(--color-bg-white);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-form-title {
  font-family: var(--font-headings);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: var(--color-text-dark);
  margin: 0 0 2px;
}

.chat-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted-dark);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chat-field input,
.chat-field select,
.chat-field textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 8px 10px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-light);
  color: var(--color-text-dark);
  box-sizing: border-box;
}

.chat-field textarea {
  resize: vertical;
  min-height: 60px;
}

.chat-field input:focus,
.chat-field select:focus,
.chat-field textarea:focus {
  border-color: var(--color-accent);
  outline: none;
}

.chat-field.has-error input,
.chat-field.has-error select,
.chat-field.has-error textarea {
  border-color: #dc2626;
}

.chat-field-error {
  display: none;
  color: #dc2626;
  font-size: 0.7rem;
  margin-top: 3px;
}

.chat-field.has-error .chat-field-error {
  display: block;
}

.chat-form-row {
  display: flex;
  gap: 8px;
}

.chat-form-row .chat-field {
  flex: 1;
  min-width: 0;
}

.chat-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.chat-form-submit {
  flex: 1;
  background-color: var(--color-accent);
  color: var(--color-primary);
  border: none;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.chat-form-submit:hover {
  background-color: var(--color-accent-hover);
}

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

.chat-form-cancel {
  background: transparent;
  border: 1px solid var(--color-border-light);
  color: var(--color-text-muted-dark);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
}

.chat-form-cancel:hover {
  background-color: var(--color-bg-light);
}

.chat-mini-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(10, 14, 23, 0.25);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chatbot-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border-light);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  background-color: var(--color-bg-white);
}

.chatbot-footer input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 10px 12px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-full);
  background-color: var(--color-bg-light);
  color: var(--color-text-dark);
}

.chatbot-footer input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.chatbot-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: var(--color-text-light);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.chatbot-send:hover {
  background-color: var(--color-accent);
  color: var(--color-primary);
}

.chatbot-send svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.chatbot-restart {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--color-border-light);
  color: var(--color-text-muted-dark);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-restart:hover {
  background-color: var(--color-bg-light);
}

.chatbot-restart svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Screen-reader only live region text */
.chatbot-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================
   RESPONSIVE — MOBILE FULL SCREEN
   ========================================== */
@media (max-width: 480px) {
  .chatbot-panel {
    right: 12px;
    left: 12px;
    bottom: 88px;
    width: auto;
    max-width: none;
    height: calc(100vh - 110px);
    max-height: none;
  }

  .chatbot-launcher {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-panel,
  .chatbot-launcher,
  .chat-typing span {
    transition: none;
    animation: none;
  }
}
