/* ============================================================
   TurnUpCity AI Chatbot — Frontend Widget Styles
   ============================================================ */

#tuc-chatbot-widget {
  position: fixed;
  z-index: 99999;
  font-family: 'Segoe UI', 'Trebuchet MS', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
  color: #203247;
  --tuc-surface: rgba(255, 255, 255, 0.88);
  --tuc-border: rgba(20, 51, 85, 0.12);
  --tuc-ink: #203247;
  --tuc-muted: #607284;
  --tuc-soft: #f8f3eb;
  --tuc-mint: #0ca4a5;
  --tuc-success: #15976c;
}

/* Zero-specificity reset via :where() — neutralises WP/theme style
   bleed without fighting class rules (0,1,0 beats 0,0,0 always). */
:where(#tuc-chatbot-widget, #tuc-chatbot-widget *) {
  box-sizing: border-box;
  margin: 0;
  text-align: left;
}

#tuc-chatbot-widget.tuc-pos-bottom-right  { right: 24px; bottom: 24px; }
#tuc-chatbot-widget.tuc-pos-bottom-left   { left: 24px; bottom: 24px; }
#tuc-chatbot-widget.tuc-pos-bottom-center { left: 50%; bottom: 24px; transform: translateX(-50%); }
#tuc-chatbot-widget.tuc-pos-top-right     { right: 24px; top: 24px; }
#tuc-chatbot-widget.tuc-pos-top-left      { left: 24px; top: 24px; }

#tuc-chatbot-widget.pos-right { right: 24px; bottom: 24px; }
#tuc-chatbot-widget.pos-left  { left: 24px; bottom: 24px; }

#tucChatWindow {
  position: absolute;
  right: 0;
  bottom: 86px;
  width: min(390px, calc(100vw - 30px));
  height: min(680px, calc(100vh - 110px));
  display: none;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid var(--tuc-border);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 32px 70px rgba(22, 31, 48, 0.2);
  backdrop-filter: blur(18px);
}

#tuc-chatbot-widget.tuc-pos-top-right #tucChatWindow,
#tuc-chatbot-widget.tuc-pos-top-left #tucChatWindow {
  top: 86px;
  bottom: auto;
}

#tuc-chatbot-widget.tuc-pos-bottom-left #tucChatWindow,
#tuc-chatbot-widget.tuc-pos-top-left #tucChatWindow,
#tuc-chatbot-widget.pos-left #tucChatWindow {
  right: auto;
  left: 0;
}

@media (min-width: 641px) {
  #tuc-chatbot-widget.is-open:not(.tuc-pos-top-right):not(.tuc-pos-top-left) #tucChatWindow {
    bottom: 0;
  }
}

#tucChatWindow.open {
  display: flex;
}

#tuc-chatbot-widget.is-open #tucToggleBtn {
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
}

.tuc-window-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at top left, rgba(var(--tuc-accent-rgb), 0.14), transparent 26%),
    linear-gradient(180deg, rgba(255,255,255,0.74), rgba(233, 243, 248, 0.88));
}

#tucToggleBtn {
  min-width: 214px;
  min-height: 64px;
  padding: 10px 14px 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(9, 25, 44, 0.92);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 24px 48px rgba(17, 24, 39, 0.26);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  position: relative;
}

#tucToggleBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 28px 52px rgba(17, 24, 39, 0.28);
}

.tuc-toggle-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--tuc-accent), var(--tuc-mint));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.24);
  flex-shrink: 0;
}

.tuc-toggle-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  gap: 2px;
}

.tuc-toggle-kicker {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.65);
}

.tuc-toggle-label {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tuc-notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #d4573b;
  border: 2px solid rgba(255,255,255,0.92);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.tuc-notif-badge.is-hidden {
  display: none;
}

#tucChatHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 20px 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--tuc-accent), var(--tuc-mint));
}

.tuc-bot-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tuc-bot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.28);
}

.tuc-bot-kicker {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.74);
}

.tuc-bot-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 2px;
  color: #fff;
}

.tuc-bot-status {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.82);
}

.tuc-status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #83f0bf;
  box-shadow: 0 0 0 0 rgba(131,240,191,0.45);
  animation: tucPulse 1.8s infinite;
}

@keyframes tucPulse {
  0% { box-shadow: 0 0 0 0 rgba(131,240,191,0.45); }
  70% { box-shadow: 0 0 0 9px rgba(131,240,191,0); }
  100% { box-shadow: 0 0 0 0 rgba(131,240,191,0); }
}

#tucCloseBtn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.86);
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
  flex-shrink: 0;
}

#tucCloseBtn:hover {
  background: rgba(255,255,255,0.26);
  transform: translateY(-1px);
}

.tuc-hero {
  padding: 24px 24px 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(236,244,248,0.96));
  border-bottom: 1px solid rgba(20, 51, 85, 0.07);
  text-align: center;
}

.tuc-hero.is-hidden {
  display: none;
}

.tuc-hero-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--tuc-ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-align: center;
}

.tuc-hero-copy {
  margin-top: 7px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--tuc-muted);
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.tuc-suggestion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.tuc-suggestion-btn {
  border: 1px solid rgba(var(--tuc-accent-rgb), 0.16);
  border-radius: 12px;
  background: rgba(var(--tuc-accent-rgb), 0.08);
  color: var(--tuc-ink);
  font: inherit;
  font-size: 11px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.tuc-suggestion-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--tuc-accent-rgb), 0.24);
  background: rgba(var(--tuc-accent-rgb), 0.12);
}

#tucMessages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(90, 111, 132, 0.25) transparent;
}

#tucMessages::-webkit-scrollbar {
  width: 5px;
}

#tucMessages::-webkit-scrollbar-track {
  background: transparent;
}

#tucMessages::-webkit-scrollbar-thumb {
  background: rgba(90, 111, 132, 0.22);
  border-radius: 999px;
}

.tuc-msg-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tuc-msg-row.user { align-items: flex-end; }
.tuc-msg-row.bot { align-items: flex-start; }

.tuc-bubble {
  max-width: 84%;
  padding: 13px 17px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.tuc-msg-row.user .tuc-bubble {
  background: linear-gradient(135deg, var(--tuc-accent), rgba(var(--tuc-accent-rgb), 0.88));
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 14px 28px rgba(var(--tuc-accent-rgb), 0.24);
}

.tuc-msg-row.bot .tuc-bubble {
  background: rgba(255,255,255,0.94);
  color: var(--tuc-ink);
  border: 1px solid rgba(20, 51, 85, 0.08);
  border-bottom-left-radius: 6px;
  box-shadow: 0 12px 24px rgba(31, 45, 61, 0.06);
}

.tuc-bubble.is-error {
  background: rgba(255, 246, 243, 0.96) !important;
  border-color: rgba(212, 87, 59, 0.16) !important;
  color: #7b3d33 !important;
}

.tuc-msg-row.bot .tuc-bubble a {
  color: var(--tuc-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tuc-ts {
  margin-top: 4px;
  padding: 0 8px;
  font-size: 10px;
  color: var(--tuc-muted);
}

.tuc-feedback-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  margin: 4px 12px 8px;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(20, 51, 85, 0.08);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(31,45,61,0.06);
}

.tuc-feedback-shell.is-hidden {
  display: none;
}

.tuc-feedback-heading {
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  color: var(--tuc-ink);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tuc-feedback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.tuc-feedback-btn {
  border: 1px solid rgba(var(--tuc-accent-rgb), 0.18);
  border-radius: 999px;
  background: rgba(var(--tuc-accent-rgb), 0.06);
  color: var(--tuc-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tuc-feedback-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(var(--tuc-accent-rgb), 0.26);
  background: rgba(var(--tuc-accent-rgb), 0.12);
  box-shadow: 0 6px 14px rgba(var(--tuc-accent-rgb), 0.14);
}

.tuc-feedback-btn.is-active {
  background: linear-gradient(135deg, var(--tuc-accent), var(--tuc-mint));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(var(--tuc-accent-rgb), 0.28);
}

.tuc-feedback-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.tuc-feedback-note {
  text-align: center;
  font-size: 11px;
  line-height: 1.55;
  color: var(--tuc-muted);
  padding: 0 4px;
  min-height: 1.55em;
}

.tuc-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  max-width: 84%;
  padding: 0 3px;
}

.tuc-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(var(--tuc-accent-rgb), 0.08);
  border: 1px solid rgba(var(--tuc-accent-rgb), 0.14);
  color: var(--tuc-ink);
  font-size: 10px;
  text-decoration: none;
}

.tuc-source-chip:hover {
  background: rgba(var(--tuc-accent-rgb), 0.12);
}

.tuc-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 15px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(20, 51, 85, 0.08);
  box-shadow: 0 12px 24px rgba(31, 45, 61, 0.06);
}

.tuc-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(96, 114, 132, 0.45);
  animation: tucBounce 1s infinite;
}

.tuc-typing-dot:nth-child(2) { animation-delay: 0.14s; }
.tuc-typing-dot:nth-child(3) { animation-delay: 0.28s; }

@keyframes tucBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-4px); }
}

.tuc-composer-shell {
  padding: 14px 16px 12px;
  background: rgba(255,255,255,0.88);
  border-top: 1px solid rgba(20, 51, 85, 0.07);
}

#tucInputArea {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  border-radius: 20px;
  background: rgba(252, 249, 244, 0.95);
  border: 1px solid rgba(20, 51, 85, 0.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

#tucUserInput {
  flex: 1;
  min-height: 26px;
  max-height: 88px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--tuc-ink);
  font: inherit;
  font-size: 12.5px;
  line-height: 2.55 !important;
  padding: 4px 6px 4px !important;
}

#tucUserInput::placeholder {
  color: #8796a4;
}

#tucSendBtn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--tuc-accent), var(--tuc-mint));
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 12px 22px rgba(var(--tuc-accent-rgb), 0.24);
  transition: transform 0.14s ease, opacity 0.14s ease;
}

#tucSendBtn:hover {
  opacity: 0.92;
}

#tucSendBtn:active {
  transform: scale(0.96);
}

#tucSendBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tuc-powered {
  margin-top: 10px;
  padding: 0 8px 2px;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  color: var(--tuc-muted);
  letter-spacing: 0.01em;
}

.tuc-powered a {
  color: var(--tuc-accent);
  font-weight: 700;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.tuc-powered a:hover {
  opacity: 0.75;
  text-decoration: underline;
}

@media (max-width: 640px) {
  /* Right-anchored positions — stay corner-anchored, not full-width */
  #tuc-chatbot-widget,
  #tuc-chatbot-widget.tuc-pos-bottom-right,
  #tuc-chatbot-widget.tuc-pos-bottom-center,
  #tuc-chatbot-widget.pos-right {
    right: 12px;
    left: auto;
    bottom: 12px;
    top: auto;
    transform: none;
  }

  /* Left-anchored positions stay left-anchored */
  #tuc-chatbot-widget.tuc-pos-bottom-left,
  #tuc-chatbot-widget.pos-left {
    right: auto;
    left: 12px;
    bottom: 12px;
    top: auto;
    transform: none;
  }

  /* Toggle button: icon-only on mobile — avoids overlapping accessibility plugin */
  #tucToggleBtn {
    width: 64px;
    height: 64px;
    min-width: 0;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
  }

  /* Hide text labels on mobile */
  .tuc-toggle-copy {
    display: none;
  }

  /* Chat window: near-full-width, anchored from widget corner */
  #tucChatWindow {
    width: calc(100vw - 24px);
    height: min(700px, calc(100dvh - 52px));
    max-height: calc(100dvh - 52px);
    right: 0;
    left: auto;
    bottom: 12px;
  }

  .tuc-hero {
    padding: 20px 20px 16px;
  }

  .tuc-suggestion-grid {
    gap: 6px;
    margin-top: 14px;
  }

  .tuc-suggestion-btn:nth-child(n + 3) {
    display: none;
  }

  #tucMessages {
    padding: 18px 16px 12px;
    gap: 12px;
  }

  .tuc-composer-shell {
    padding: 12px 14px 10px;
  }

  /* Left-anchored chat window */
  #tuc-chatbot-widget.tuc-pos-bottom-left #tucChatWindow,
  #tuc-chatbot-widget.pos-left #tucChatWindow {
    right: auto;
    left: 0;
  }

  .tuc-bubble,
  .tuc-sources {
    max-width: 92%;
  }

  /* Reduce rating section size on mobile to preserve chat reading space */
  .tuc-feedback-shell {
    padding: 12px 14px 10px;
    gap: 8px;
    margin: 4px 8px 6px;
  }

  .tuc-feedback-btn {
    padding: 6px 12px;
    font-size: 11px;
  }
}

@media (max-width: 460px) {
  .tuc-hero,
  #tucMessages,
  .tuc-composer-shell,
  .tuc-feedback-shell {
    padding-left: 14px;
    padding-right: 14px;
  }
}
