/* Chat9 Widget v0.6.9 - Enquiry Deletion */
:root {
  --chat9-primary: #111;
  --chat9-bg: #fff;
  --chat9-border: #e5e5e5;
  --chat9-text: #111;
  --chat9-light: #f5f5f5;
}

.chat9-widget {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Bubble button */
.chat9-bubble {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 56px;
  height: 56px;
  background: var(--chat9-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}
.chat9-bubble:hover {
  transform: scale(1.05);
}
.chat9-bubble:active {
  transform: scale(0.95);
}

/* Panel - Mobile (full width bottom sheet) */
.chat9-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-height: 90vh;
  background: var(--chat9-bg);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.chat9-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--chat9-border);
  background: var(--chat9-light);
  flex-shrink: 0;
}
.chat9-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--chat9-text);
}
.chat9-close {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
}
.chat9-close:hover {
  background: var(--chat9-border);
}

/* Messages area - v0.6.2 FIXED: removed max-height, let flex handle it */
.chat9-messages {
  flex: 1 1 auto;
  padding: 12px 16px;
  overflow-y: auto;
  min-height: 100px;
  background: var(--chat9-bg);
}
.chat9-msg {
  margin: 8px 0;
  display: flex;
}
.chat9-msg.user {
  justify-content: flex-end;
}
.chat9-bubbletext {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--chat9-light);
  color: var(--chat9-text);
}
.chat9-msg.user .chat9-bubbletext {
  background: var(--chat9-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat9-msg.assistant .chat9-bubbletext {
  border-bottom-left-radius: 4px;
}

/* Quick replies */
.chat9-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--chat9-border);
  background: var(--chat9-bg);
  flex-shrink: 0;
}
.chat9-qr {
  flex: 1 1 calc(50% - 4px);
  min-height: 44px;
  padding: 10px 12px;
  background: var(--chat9-light);
  border: 1px solid var(--chat9-border);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease;
}
.chat9-qr:hover {
  background: #eaeaea;
}
.chat9-qr:active {
  background: #ddd;
}
.chat9-quick-replies.hidden {
  display: none;
}

/* Input area */
.chat9-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--chat9-border);
  background: var(--chat9-light);
  flex-shrink: 0;
}
.chat9-text {
  flex: 1;
  min-height: 44px;
  max-height: 100px;
  padding: 10px 14px;
  border: 1px solid var(--chat9-border);
  border-radius: 22px;
  font-size: 16px; /* Prevents iOS zoom */
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
}
.chat9-text:focus {
  border-color: var(--chat9-primary);
}
.chat9-send {
  min-width: 60px;
  height: 44px;
  padding: 0 16px;
  background: var(--chat9-primary);
  color: #fff;
  border: none;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}
.chat9-send:hover {
  background: #333;
}
.chat9-send:disabled {
  background: #999;
  cursor: not-allowed;
}

/* Typing indicator */
.chat9-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--chat9-light);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.chat9-typing span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: chat9-bounce 1.4s infinite ease-in-out;
}
.chat9-typing span:nth-child(1) { animation-delay: 0s; }
.chat9-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat9-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat9-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Desktop/Tablet - Floating panel */
@media (min-width: 500px) {
  .chat9-panel {
    position: fixed;
    bottom: 80px;
    right: 16px;
    left: auto;
    width: 380px;
    max-height: 600px;
    border-radius: 16px;
  }
  .chat9-qr {
    flex: 1 1 calc(50% - 4px);
  }
}

@media (min-width: 768px) {
  .chat9-panel {
    width: 400px;
    max-height: 700px;
  }
}

/* Contact Form - v0.6.5 FIXED: scrollable within panel */
.chat9-form {
  padding: 16px;
  background: var(--chat9-bg);
  border-top: 1px solid var(--chat9-border);
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.chat9-form-field {
  margin-bottom: 12px;
}
.chat9-form-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--chat9-text);
}
.chat9-form-field .required {
  color: #c00;
}
.chat9-form-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--chat9-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.chat9-form-field input:focus {
  border-color: var(--chat9-primary);
}
.chat9-form-facebook-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--chat9-border);
  border-radius: 8px;
  overflow: hidden;
}
.chat9-form-facebook-wrap:focus-within {
  border-color: var(--chat9-primary);
}
.chat9-fb-prefix {
  padding: 10px 8px 10px 12px;
  background: var(--chat9-light);
  color: #666;
  font-size: 13px;
  white-space: nowrap;
  border-right: 1px solid var(--chat9-border);
}
.chat9-form-facebook-wrap input {
  border: none;
  border-radius: 0;
  flex: 1;
}
.chat9-form-facebook-wrap input:focus {
  border: none;
  outline: none;
}
.chat9-form-submit {
  width: 100%;
  padding: 12px;
  background: var(--chat9-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.chat9-form-submit:hover {
  background: #333;
}
.chat9-form-submit:disabled {
  background: #999;
  cursor: not-allowed;
}

/* Contact Card - v0.6.2 NEW: System-rendered contact links */
.chat9-contact-card {
  background: var(--chat9-light);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 8px;
}
.chat9-contact-card p {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: #666;
}
.chat9-contact-card a {
  display: block;
  padding: 8px 0;
  color: var(--chat9-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.chat9-contact-card a:hover {
  text-decoration: underline;
}
.chat9-contact-card a + a {
  border-top: 1px solid var(--chat9-border);
}

/* v0.6.8: Sticky Contact Card - pinned below header */
.chat9-sticky-contact {
  flex-shrink: 0;
  padding: 8px 16px;
  background: #e8f5e9;
  border-bottom: 1px solid #c8e6c9;
}
.chat9-sticky-contact .chat9-contact-card {
  margin-top: 0;
  background: #fff;
  border: 1px solid #a5d6a7;
}
.chat9-sticky-contact .chat9-contact-card p {
  color: #2e7d32;
  font-weight: 500;
}
.chat9-sticky-contact .chat9-contact-card a {
  color: #1b5e20;
}

/* Closing state indicator */
.chat9-closing-notice {
  text-align: center;
  padding: 8px 16px;
  background: #fffbe6;
  border-top: 1px solid #ffe58f;
  font-size: 12px;
  color: #ad8b00;
  flex-shrink: 0;
}
