/* ============================================================
   URBot Live Preview Widget — CSS
   Dark-first, matches bot subdomain design language.
   ============================================================ */

/* Container */
.ulp-widget {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 14px;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  max-width: 680px;
  margin: 0 auto;
  box-shadow: 0 4px 32px rgba(0,0,0,0.4);
}

/* Header */
.ulp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  background: #0a0f1e;
  border-bottom: 1px solid #1e293b;
}

.ulp-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1e293b;
  flex-shrink: 0;
}

.ulp-header-info {
  flex: 1;
  min-width: 0;
}

.ulp-bot-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ulp-subtitle {
  display: block;
  font-size: 0.72rem;
  color: #4ade80;
  letter-spacing: 0.03em;
}

/* Message counter */
.ulp-counter {
  font-size: 0.72rem;
  color: #94a3b8;
  background: #1e293b;
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.3s, color 0.3s;
}

.ulp-counter-low {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

#ulp-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Messages area */
.ulp-messages {
  min-height: 200px;
  max-height: 340px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.ulp-messages::-webkit-scrollbar { width: 4px; }
.ulp-messages::-webkit-scrollbar-track { background: transparent; }
.ulp-messages::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* Message bubbles */
.ulp-msg {
  max-width: 86%;
  animation: ulpFadeIn 0.18s ease;
}

@keyframes ulpFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ulp-user {
  align-self: flex-end;
}

.ulp-bot {
  align-self: flex-start;
}

.ulp-msg-label {
  font-size: 0.68rem;
  color: #64748b;
  margin-bottom: 4px;
  padding: 0 4px;
}

.ulp-user .ulp-msg-label { text-align: right; }

.ulp-msg-text {
  background: #1e293b;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #e2e8f0;
  word-break: break-word;
  white-space: pre-wrap;
}

.ulp-user .ulp-msg-text {
  background: #4f46e5;
  color: #fff;
  border-radius: 12px 12px 2px 12px;
}

.ulp-bot .ulp-msg-text {
  border-radius: 2px 12px 12px 12px;
}

/* Typing cursor */
.ulp-cursor {
  display: inline-block;
  color: #7c3aed;
  animation: ulpBlink 0.8s step-end infinite;
  font-weight: 300;
  margin-left: 1px;
}

@keyframes ulpBlink {
  50% { opacity: 0; }
}

/* Thinking dots */
.ulp-thinking .ulp-msg-text {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ulp-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #475569;
  animation: ulpBounce 1.2s ease-in-out infinite;
}
.ulp-dot:nth-child(2) { animation-delay: 0.2s; }
.ulp-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ulpBounce {
  0%, 80%, 100% { transform: translateY(0); background: #475569; }
  40%           { transform: translateY(-7px); background: #7c3aed; }
}

/* Input row */
.ulp-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: #0a0f1e;
  border-top: 1px solid #1e293b;
}

.ulp-input {
  flex: 1;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 9px 14px;
  color: #e2e8f0;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.ulp-input:focus { border-color: #7c3aed; }
.ulp-input::placeholder { color: #475569; }
.ulp-input:disabled { opacity: 0.5; cursor: not-allowed; }

.ulp-send {
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.ulp-send:hover:not(:disabled) { background: #6d28d9; }
.ulp-send:active:not(:disabled) { transform: scale(0.97); }
.ulp-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* Hint line */
.ulp-hint {
  margin: 0;
  padding: 8px 16px 12px;
  font-size: 0.72rem;
  color: #475569;
  text-align: center;
  background: #0a0f1e;
}
.ulp-hint a { color: #7c3aed; text-decoration: none; }
.ulp-hint a:hover { text-decoration: underline; }

/* Suggestion chips */
.ulp-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 4px;
  align-self: flex-start;
  max-width: 100%;
  animation: ulpFadeIn 0.2s ease;
}

.ulp-chip {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  color: #94a3b8;
  font-size: 0.76rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.ulp-chip:hover {
  border-color: #7c3aed;
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.08);
}

/* Upgrade CTA */
.ulp-upgrade {
  align-self: stretch;
  background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(79,70,229,0.08));
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  animation: ulpFadeIn 0.25s ease;
}

.ulp-upgrade p {
  margin: 0 0 10px;
  color: #cbd5e1;
  font-size: 0.88rem;
}

.ulp-upgrade-btn {
  display: inline-block;
  background: #7c3aed;
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s;
  cursor: pointer;
}
.ulp-upgrade-btn:hover { background: #6d28d9; }

.ulp-upgrade-sub {
  margin: 8px 0 0 !important;
  font-size: 0.72rem !important;
  color: #64748b !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ulp-cursor, .ulp-dot { animation: none; }
  .ulp-msg { animation: none; }
  .ulp-upgrade { animation: none; }
}

/* Mobile */
@media (max-width: 480px) {
  .ulp-messages { max-height: 260px; padding: 12px; }
  .ulp-send { padding: 9px 12px; }
  .ulp-msg { max-width: 94%; }
}
