/* botZone Webchat — test page + floating widget */
@import url('/css/theme.css');

/* Full page layout */
.webchat-page {
  min-height: 100vh;
  background: var(--cb-bg);
  color: var(--cb-text);
  font-family: var(--cb-font);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.webchat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--cb-border);
  background: var(--cb-primary-light);
  animation: wc-slide-down 0.45s ease;
}

.webchat-header a {
  color: var(--cb-muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: color 0.2s, transform 0.2s;
}

.webchat-header a:hover {
  color: var(--cb-text);
  transform: translateX(-2px);
}

.webchat-header h1 {
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.webchat-header .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cb-success);
  box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.5);
  animation: wc-pulse-dot 2s ease infinite;
}

.webchat-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.webchat-intro {
  animation: wc-fade-up 0.5s ease 0.1s both;
}

.webchat-panel {
  width: 100%;
  max-width: 480px;
  height: min(640px, calc(100vh - 120px));
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--cb-shadow-glow);
}

.webchat-panel-body-anim {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: wc-panel-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.webchat-panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--cb-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--cb-primary-light);
  backdrop-filter: blur(8px);
  animation: none !important;
}

/* Cabecera del chat: estática, sin animaciones ni micro-interacciones */
.webchat-panel-header,
.webchat-panel-header * {
  animation: none !important;
}

.webchat-panel-header strong { font-size: 0.95rem; }

.webchat-panel-header small {
  color: var(--cb-muted);
  font-size: 0.78rem;
  display: block;
  transition: none;
}

.webchat-panel-header small.cb-status-online {
  color: #2a9d4a;
}

.webchat-panel-header .cb-lang-pills {
  transition: none;
}

.webchat-panel-header .cb-lang-pill {
  transition: none;
}

.webchat-panel-header .cb-lang-pill.active {
  box-shadow: none;
}

.webchat-panel-header .webchat-toolbar button {
  transition: none;
}

.webchat-panel-header .webchat-toolbar button:hover {
  transform: none;
}

.webchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

.webchat-messages::-webkit-scrollbar { width: 6px; }
.webchat-messages::-webkit-scrollbar-thumb {
  background: rgba(30, 58, 95, 0.25);
  border-radius: 999px;
}

.cb-msg {
  display: flex;
  gap: 0.65rem;
  max-width: 94%;
  opacity: 0;
  animation: wc-msg-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--wc-delay, 0ms);
}

.cb-msg-bot { align-self: flex-start; }
.cb-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.cb-msg-body { min-width: 0; flex: 1; }

.cb-msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
  transition: transform 0.25s, box-shadow 0.25s;
}

.cb-avatar-bot {
  background: var(--cb-primary-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2);
}

.cb-avatar-user {
  background: var(--cb-primary-light);
  border: 1px solid var(--cb-border);
  color: var(--cb-primary-dark);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.cb-msg-bubble {
  padding: 0.75rem 0.95rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.cb-msg-bot .cb-msg-bubble {
  background: var(--cb-primary-light);
  border: 1px solid var(--cb-border);
  border-left: 3px solid var(--cb-primary-dark);
  border-bottom-left-radius: var(--cb-radius-sm);
  box-shadow: var(--cb-shadow);
  color: var(--cb-text);
}

.cb-msg-bot .cb-msg-bubble::before {
  display: none;
}

.cb-msg-user .cb-msg-bubble {
  background: var(--cb-primary-dark);
  color: #fff;
  border-bottom-right-radius: var(--cb-radius-sm);
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2);
}

.cb-msg-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--cb-primary-dark);
  letter-spacing: 0.02em;
  text-transform: none;
}

.cb-msg-para {
  margin: 0.2rem 0 0;
  color: var(--cb-text);
  line-height: 1.55;
}

.cb-msg-list {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cb-msg-list li {
  position: relative;
  padding-left: 1rem;
  color: var(--cb-text);
  font-size: 0.86rem;
  line-height: 1.45;
  animation: wc-list-item 0.35s ease both;
  animation-delay: calc(var(--wc-li, 0) * 40ms + 80ms);
}

.cb-msg-list li::before {
  content: '—';
  position: absolute;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--cb-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.cb-msg-time {
  font-size: 0.68rem;
  color: var(--cb-muted);
  margin-top: 0.35rem;
  padding: 0 0.25rem;
  opacity: 0;
  animation: wc-fade-in 0.3s ease 0.2s forwards;
}

.cb-msg-user .cb-msg-time { text-align: right; }

/* Typing / loading indicator */
.cb-typing-wrap {
  display: flex;
  gap: 0.65rem;
  align-self: flex-start;
  max-width: 94%;
  animation: wc-msg-in 0.3s ease both;
}

.cb-typing-wrap .cb-msg-avatar.cb-avatar-thinking {
  animation: wc-avatar-pulse 1.2s ease infinite;
}

.cb-typing-bubble {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  border-radius: var(--cb-radius);
  border-bottom-left-radius: var(--cb-radius-sm);
  background: var(--cb-primary-light);
  border: 1px solid var(--cb-border);
  border-left: 3px solid var(--cb-primary-dark);
  box-shadow: var(--cb-shadow);
}

.cb-typing-label {
  font-size: 0.78rem;
  color: var(--cb-muted);
}

.cb-typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.cb-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-primary);
  animation: wc-dot-bounce 1.2s ease infinite;
}

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

.cb-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wc-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.webchat-input-bar {
  display: flex;
  gap: 0.55rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-surface-2);
}

.webchat-input-bar input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius-sm);
  background: var(--cb-surface);
  color: var(--cb-text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.webchat-input-bar input:focus {
  outline: none;
  border-color: var(--cb-primary-dark);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
  transform: none;
}

.webchat-input-bar input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.webchat-input-bar button {
  min-width: 88px;
  padding: 0.7rem 1.15rem;
  background: var(--cb-btn-bg);
  color: var(--cb-btn-text);
  border: none;
  border-radius: var(--cb-radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: none;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.webchat-input-bar button:hover:not(:disabled) {
  background: var(--cb-primary-dark);
  color: #fff;
  transform: none;
  box-shadow: none;
}

.webchat-input-bar button:active:not(:disabled) {
  background: var(--cb-primary-dark);
  color: #fff;
  transform: scale(0.98);
}

.webchat-input-bar button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.webchat-input-bar button.cb-sending .cb-btn-label { opacity: 0.6; }

.webchat-hints {
  padding: 0 1rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  animation: wc-fade-up 0.4s ease 0.3s both;
}

.hint-chip {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--cb-bg);
  border: 1px solid var(--cb-border);
  color: var(--cb-muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s, transform 0.2s, background 0.2s;
}

.hint-chip:hover {
  border-color: var(--cb-primary-dark);
  color: var(--cb-primary-dark);
  background: var(--cb-primary-light);
  transform: translateY(-2px);
}

.hint-chip:active { transform: scale(0.96); }

.hidden { display: none !important; }

/* Choice buttons */
.cb-msg-choice .cb-msg-bubble { margin-bottom: 0.55rem; }

.cb-choice-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.15rem;
  max-width: 280px;
}

.cb-choice-btn {
  padding: 0.65rem 0.95rem;
  border-radius: var(--cb-radius-sm);
  border: 1px solid var(--cb-border);
  background: var(--cb-btn-bg);
  color: var(--cb-btn-text);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  opacity: 0;
  animation: wc-choice-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--wc-choice-i, 0) * 55ms + 120ms);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  box-shadow: var(--cb-shadow);
}

.cb-choice-btn:hover:not(:disabled) {
  background: var(--cb-primary-dark);
  border-color: var(--cb-primary-dark);
  color: #fff;
  transform: translateX(4px);
  box-shadow: var(--cb-shadow-glow);
}

.cb-choice-btn:active:not(:disabled) {
  transform: translateX(2px) scale(0.98);
}

.cb-choice-used .cb-choice-btn {
  opacity: 0.4;
  cursor: default;
  animation: none;
}

.webchat-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.webchat-toolbar button {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--cb-border);
  color: var(--cb-muted);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.webchat-toolbar button:hover {
  color: var(--cb-primary-dark);
  border-color: var(--cb-primary-dark);
  background: var(--cb-primary-light);
}

.webchat-error {
  text-align: center;
  padding: 2rem;
  color: #f56565;
  animation: wc-shake 0.45s ease;
}

.webchat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 3rem 1rem;
  color: var(--cb-muted);
  animation: wc-fade-in 0.4s ease;
}

.webchat-loading .cb-spinner {
  width: 32px;
  height: 32px;
  border-width: 3px;
  border-color: rgba(30, 58, 95, 0.15);
  border-top-color: var(--cb-primary-dark);
}

/* Floating widget */
.cb-widget-launcher {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  min-width: 56px;
  height: 44px;
  padding: 0 1rem;
  border-radius: 999px;
  background: var(--cb-primary-dark);
  border: none;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--cb-shadow-glow);
  z-index: 9000;
  transition: transform 0.25s, box-shadow 0.25s;
  animation: wc-launcher-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}

.cb-widget-launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(30, 58, 95, 0.25);
}

.cb-widget-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 520px;
  max-height: calc(100vh - 7rem);
  z-index: 9001;
  display: none;
  flex-direction: column;
}

.cb-widget-panel.open {
  display: flex;
  animation: wc-widget-open 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.cb-widget-panel .webchat-panel {
  height: 100%;
  max-width: none;
  animation: none;
}

/* Keyframes */
@keyframes wc-panel-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes wc-msg-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes wc-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes wc-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes wc-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes wc-pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(76, 217, 100, 0.45); }
  50% { opacity: 0.85; box-shadow: 0 0 0 6px rgba(76, 217, 100, 0); }
}

@keyframes wc-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-6px); opacity: 1; }
}

@keyframes wc-avatar-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2); }
  50% { transform: scale(1.06); box-shadow: 0 4px 16px rgba(30, 58, 95, 0.3); }
}

@keyframes wc-choice-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes wc-list-item {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes wc-spin {
  to { transform: rotate(360deg); }
}

@keyframes wc-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes wc-launcher-in {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes wc-widget-open {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 480px) {
  .cb-widget-panel {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: 5rem;
  }

  .cb-msg { max-width: 98%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Pre-chat registration */
.webchat-register-panel {
  animation: none;
  justify-content: flex-start;
}

.webchat-register-head {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--cb-border);
  background: var(--cb-primary-light);
}

.webchat-register-head strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.35rem;
  color: var(--cb-primary-dark);
}

.webchat-register-head p {
  font-size: 0.84rem;
  color: var(--cb-muted);
  line-height: 1.45;
  margin: 0;
}

.webchat-demo-flow-section {
  padding: 0 1.25rem 0.5rem;
}

.webchat-demo-flow-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cb-muted);
  margin: 0 0 0.55rem;
}

.webchat-demo-flow-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.webchat-demo-flow-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--cb-radius-sm);
  border: 1px solid var(--cb-border);
  background: var(--cb-surface);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.webchat-demo-flow-card input {
  margin-top: 0.2rem;
  accent-color: var(--cb-primary-dark);
}

.webchat-demo-flow-card.is-selected,
.webchat-demo-flow-card:has(input:checked) {
  border-color: var(--cb-primary-dark);
  background: var(--cb-primary-light);
}

.webchat-demo-flow-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.webchat-demo-flow-card-body strong {
  font-size: 0.88rem;
  color: var(--cb-primary-dark);
}

.webchat-demo-flow-card-body small {
  font-size: 0.78rem;
  color: var(--cb-muted);
  line-height: 1.35;
}

.webchat-register-form {
  padding: 1.15rem 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.webchat-register-form label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cb-muted);
  margin-top: 0.55rem;
}

.webchat-register-form input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: var(--cb-radius-sm);
  border: 1px solid var(--cb-border);
  background: var(--cb-surface);
  color: var(--cb-text);
  font-family: inherit;
  font-size: 0.9rem;
}

.webchat-register-form input:focus {
  outline: none;
  border-color: var(--cb-primary-dark);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}

.webchat-register-error {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  color: #fca5a5;
  line-height: 1.4;
}

.webchat-register-submit {
  margin-top: 1rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--cb-radius-sm);
  background: var(--cb-btn-bg);
  color: var(--cb-btn-text);
  font-weight: 600;
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.webchat-register-submit:hover:not(:disabled) {
  background: var(--cb-primary-dark);
  color: #fff;
}

.webchat-register-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.webchat-register-submit .cb-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}
