/* Cognicores chatbot widget — scoped styles.
 *
 * All selectors are namespaced under .cgc-chat-* to avoid colliding with
 * the host page's CSS. Variables on the root container (.cgc-chat) let
 * the embed override colors via inline style or stylesheet.
 *
 * Layout: vertical flex, fixed-height (configurable). Messages scroll.
 * Input + contact link sit at the bottom.
 */

.cgc-chat {
  --cgc-bg:          #ffffff;
  --cgc-bg-alt:      #faf6f2;
  --cgc-text:        #1f2328;
  --cgc-text-muted:  #6e7681;
  --cgc-primary:     #c8835a;
  --cgc-primary-fg:  #ffffff;
  --cgc-bot-bg:      #f3f0ed;
  --cgc-user-bg:     #c8835a;
  --cgc-user-fg:     #ffffff;
  --cgc-border:      #e8dfd6;
  --cgc-radius:      14px;

  display: flex;
  flex-direction: column;
  height: 560px;
  max-height: 80vh;
  background: var(--cgc-bg);
  color: var(--cgc-text);
  border: 1px solid var(--cgc-border);
  border-radius: var(--cgc-radius);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.cgc-chat__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}

.cgc-chat__messages::-webkit-scrollbar { width: 8px; }
.cgc-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.cgc-chat__bubble {
  display: block;
  max-width: 80%;
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.cgc-chat__bubble--bot {
  background: var(--cgc-bot-bg);
  color: var(--cgc-text);
  border-bottom-left-radius: 4px;
  margin-right: auto;
}

.cgc-chat__bubble--user {
  background: var(--cgc-user-bg);
  color: var(--cgc-user-fg);
  border-bottom-right-radius: 4px;
  margin-left: auto;
}

.cgc-chat__bubble--system {
  background: transparent;
  color: var(--cgc-text-muted);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  margin: 4px auto;
  padding: 4px 8px;
}

.cgc-chat__bubble--bot .cgc-chat__cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--cgc-text-muted);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cgc-blink 1s steps(2, start) infinite;
}

@keyframes cgc-blink {
  to { visibility: hidden; }
}

/* Inline contact form (rendered as a chat-bubble companion) */

.cgc-chat__form {
  margin: 8px 0 8px 0;
  padding: 14px;
  background: var(--cgc-bg-alt);
  border: 1px solid var(--cgc-border);
  border-radius: 10px;
  max-width: 420px;
}

.cgc-chat__form-title {
  font-size: 13px;
  color: var(--cgc-text-muted);
  margin-bottom: 8px;
}

.cgc-chat__form-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  margin-bottom: 8px;
  border: 1px solid var(--cgc-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--cgc-text);
  background: var(--cgc-bg);
}

.cgc-chat__form-input:focus {
  outline: none;
  border-color: var(--cgc-primary);
  box-shadow: 0 0 0 2px rgba(200, 131, 90, 0.2);
}

.cgc-chat__form-error {
  color: #c53030;
  font-size: 13px;
  margin: 4px 0 8px;
  min-height: 1em;
}

.cgc-chat__form-submit {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--cgc-primary);
  color: var(--cgc-primary-fg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.cgc-chat__form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cgc-chat__form-submit:hover:not(:disabled) {
  filter: brightness(1.06);
}

.cgc-chat__form--sent {
  background: #ecfdf5;
  border-color: #34d399;
  color: #065f46;
  text-align: center;
  padding: 10px 14px;
}

/* Bottom dock: contact link + input + send button */

.cgc-chat__dock {
  border-top: 1px solid var(--cgc-border);
  padding: 10px 12px 12px;
  background: var(--cgc-bg);
}

.cgc-chat__contact-link {
  display: inline-block;
  margin: 0 0 8px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--cgc-text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cgc-chat__contact-link:hover {
  color: var(--cgc-primary);
}

.cgc-chat__contact-link[disabled] {
  color: var(--cgc-text-muted);
  text-decoration: none;
  cursor: default;
  opacity: 0.6;
}

.cgc-chat__input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.cgc-chat__textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--cgc-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--cgc-text);
  background: var(--cgc-bg);
  max-height: 120px;
  min-height: 40px;
}

.cgc-chat__textarea:focus {
  outline: none;
  border-color: var(--cgc-primary);
  box-shadow: 0 0 0 2px rgba(200, 131, 90, 0.2);
}

.cgc-chat__send {
  flex-shrink: 0;
  border: 0;
  border-radius: 8px;
  background: var(--cgc-primary);
  color: var(--cgc-primary-fg);
  padding: 0 16px;
  height: 40px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.cgc-chat__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cgc-chat__send:hover:not(:disabled) {
  filter: brightness(1.06);
}

.cgc-chat__hint {
  text-align: center;
  color: var(--cgc-text-muted);
  font-size: 12px;
  margin-top: 6px;
}

.cgc-chat__hint--error {
  color: #c53030;
}

/* Status / error banner that overlays the messages briefly */

.cgc-chat__banner {
  background: #fef3c7;
  color: #92400e;
  padding: 8px 14px;
  font-size: 13px;
  text-align: center;
  border-bottom: 1px solid #fcd34d;
}

.cgc-chat__banner--error {
  background: #fee2e2;
  color: #991b1b;
  border-bottom-color: #fca5a5;
}

@media (max-width: 600px) {
  .cgc-chat {
    height: 80vh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .cgc-chat__bubble { max-width: 88%; }
}
