/* =============================================================================
   YCON Chatbot Widget — chatbot.css
   Inherits CSS custom properties from yconinfra-theme/style.css
   ============================================================================= */

/* ── Root overrides (safe fallbacks when loaded outside theme context) ───────── */
#ycon-chatbot-root {
  --cb-primary:    var(--color-primary, rgb(12, 135, 52));
  --cb-accent:     var(--color-accent-light, #48f26f);
  --cb-font-body:  var(--font-body, 'Noto Sans', Arial, sans-serif);
  --cb-font-head:  var(--font-heading, 'Arvo', Georgia, serif);
  --cb-shadow:     var(--shadow-lg, 0 10px 40px rgba(0,0,0,.2));
  --cb-radius:     16px;
  --cb-toggle-sz:  56px;
}

/* ── Toggle button ───────────────────────────────────────────────────────────── */
#ycon-chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;

  width: var(--cb-toggle-sz);
  height: var(--cb-toggle-sz);
  border-radius: 50%;
  border: none;
  background: var(--cb-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transition: transform .2s ease, box-shadow .2s ease;
  outline-offset: 3px;
}

#ycon-chatbot-toggle:hover,
#ycon-chatbot-toggle:focus-visible {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
}

#ycon-chatbot-toggle svg {
  pointer-events: none;
  flex-shrink: 0;
}

/* Pulse ring when closed */
#ycon-chatbot-toggle::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--cb-primary);
  opacity: 0;
  animation: cb-pulse 2.4s ease-out infinite;
}

@keyframes cb-pulse {
  0%   { transform: scale(1);   opacity: .6; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ── Chat window ─────────────────────────────────────────────────────────────── */
#ycon-chatbot-window {
  position: fixed;
  bottom: 94px;
  right: 24px;
  z-index: 10001;

  width: 360px;
  max-height: 540px;
  border-radius: var(--cb-radius);
  background: #fff;
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--cb-font-body);
  font-size: 14px;
  line-height: 1.5;

  /* entrance animation */
  transform-origin: bottom right;
  animation: cb-open .22s ease-out;
}

#ycon-chatbot-window[hidden] {
  display: none !important;
}

@keyframes cb-open {
  from { opacity: 0; transform: scale(.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
#ycon-chatbot-header {
  background: var(--cb-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#ycon-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#ycon-chatbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cb-accent);
  color: #0c8734;
  font-weight: 700;
  font-family: var(--cb-font-head);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

#ycon-chatbot-header strong {
  display: block;
  font-family: var(--cb-font-head);
  font-size: 14px;
  line-height: 1.2;
}

.ycon-chatbot-status {
  font-size: 11px;
  opacity: .85;
  color: var(--cb-accent);
}

#ycon-chatbot-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  opacity: .85;
  transition: opacity .15s;
}

#ycon-chatbot-close:hover { opacity: 1; }

/* ── Messages area ───────────────────────────────────────────────────────────── */
#ycon-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: #f7f8fa;
}

/* Scrollbar */
#ycon-chatbot-messages::-webkit-scrollbar { width: 4px; }
#ycon-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#ycon-chatbot-messages::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }

/* ── Message bubbles ─────────────────────────────────────────────────────────── */
.cb-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.cb-bubble.cb-bot {
  background: #fff;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.cb-bubble.cb-user {
  background: var(--cb-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* ── Typing indicator ────────────────────────────────────────────────────────── */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  width: fit-content;
}

.cb-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #bbb;
  animation: cb-dot 1.2s ease-in-out infinite;
}

.cb-typing span:nth-child(2) { animation-delay: .2s; }
.cb-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes cb-dot {
  0%, 60%, 100% { transform: translateY(0);   opacity: .5; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── CTA button (step 1) ─────────────────────────────────────────────────────── */
.cb-cta-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 22px;
  background: var(--cb-primary);
  color: #fff !important;
  border: none;
  border-radius: 24px;
  font-family: var(--cb-font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .15s;
  text-decoration: none;
}

.cb-cta-btn:hover,
.cb-cta-btn:focus-visible {
  background: #0a7a2f;
  transform: translateY(-1px);
  outline: 2px solid var(--cb-accent);
  outline-offset: 2px;
}

/* ── Brochure download link (step 5) ─────────────────────────────────────────── */
.cb-brochure-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 9px 18px;
  background: var(--cb-accent);
  color: #0a5c22 !important;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: background .2s, transform .15s;
}

.cb-brochure-link:hover {
  background: #35e05a;
  transform: translateY(-1px);
}

/* Fallback note when no brochure URL is configured */
.cb-brochure-note {
  display: block;
  margin-top: 8px;
  font-size: 12.5px;
  color: #555;
  font-style: italic;
  line-height: 1.5;
}

/* ── Input area ──────────────────────────────────────────────────────────────── */
#ycon-chatbot-input-area {
  padding: 12px 14px;
  border-top: 1px solid #ececec;
  background: #fff;
  flex-shrink: 0;
}

.cb-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.cb-input-row input {
  flex: 1;
  padding: 9px 13px;
  border: 1.5px solid #d0d0d0;
  border-radius: 22px;
  font-family: var(--cb-font-body);
  font-size: 13.5px;
  outline: none;
  transition: border-color .2s;
  background: #f7f8fa;
  color: #1a1a1a;
}

.cb-input-row input:focus {
  border-color: var(--cb-primary);
  background: #fff;
}

.cb-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--cb-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}

.cb-send-btn:hover,
.cb-send-btn:focus-visible {
  background: #0a7a2f;
  transform: scale(1.08);
}

.cb-send-btn svg { pointer-events: none; }

/* Inline validation error */
.cb-input-error {
  font-size: 12px;
  color: #d32f2f;
  margin-top: 5px;
  padding-left: 4px;
  display: block;
}

/* ── Submitting state ────────────────────────────────────────────────────────── */
.cb-submitting-msg {
  text-align: center;
  color: #666;
  font-size: 13px;
  padding: 12px 0;
}

/* ── Mobile — full-width below 480 px ───────────────────────────────────────── */
@media (max-width: 480px) {
  #ycon-chatbot-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 90vh;
    border-radius: var(--cb-radius) var(--cb-radius) 0 0;
  }

  #ycon-chatbot-toggle {
    bottom: 16px;
    right: 16px;
  }
}

/* ── Reduced-motion ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #ycon-chatbot-toggle::after,
  .cb-typing span { animation: none; }
  #ycon-chatbot-window { animation: none; }
}
