/* ============================================================
   AINNA Live Chat Demo — Futuristic White Lofi
   ============================================================ */

:root {
  --bg-root: #FAFAF8;
  --bg-surface: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-glass-strong: rgba(255, 255, 255, 0.9);
  --bg-muted: #F4F3F0;
  --lofi-lavender: #C4B5E8;
  --lofi-sage: #A8C5B5;
  --lofi-peach: #F5D0C5;
  --lofi-dusty-blue: #9BB5CE;
  --lofi-mauve: #B8A9C9;
  --accent: #7B9FD4;
  --accent-deep: #5A7FAD;
  --text-primary: #1A1A1E;
  --text-secondary: #5C5C66;
  --text-muted: #8E8E93;
  --border: rgba(0, 0, 0, 0.06);
  --border-medium: rgba(0, 0, 0, 0.1);
  --shadow-soft: 0 4px 24px rgba(26, 26, 30, 0.05);
  --shadow-glass: 0 12px 40px rgba(155, 181, 206, 0.15);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', 'SF Mono', monospace;
  --gradient-shell: radial-gradient(ellipse 70% 50% at 20% 10%, rgba(196, 181, 232, 0.2) 0%, transparent 55%),
                    radial-gradient(ellipse 60% 45% at 80% 90%, rgba(155, 181, 206, 0.16) 0%, transparent 55%);
  --color-bg-primary: var(--bg-root);
  --color-bg-secondary: var(--bg-muted);
  --color-border: var(--border);
  --color-text-secondary: var(--text-muted);
  --pastel-blue: var(--lofi-dusty-blue);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-root);
  background-image:
    linear-gradient(rgba(155, 181, 206, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155, 181, 206, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== CHAT SHELL ===== */
.wa-fullpage {
  max-width: 920px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-glass);
}

.wa-header {
  background: linear-gradient(135deg, rgba(123, 159, 212, 0.92) 0%, rgba(196, 181, 232, 0.88) 100%);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.wa-back {
  color: #fff;
  text-decoration: none;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.15s;
}

.wa-back:hover { background: rgba(255, 255, 255, 0.28); }

.wa-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--accent-deep);
  flex-shrink: 0;
  box-shadow: var(--shadow-soft);
}

.wa-info { flex: 1; }

.wa-info h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.wa-status {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.95;
  transition: all 0.3s ease;
}

.wa-status.typing {
  color: #E8F4FF;
  font-style: italic;
}

.wa-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* ===== MESSAGES ===== */
.wa-messages {
  flex: 1;
  padding: 22px 20px;
  background: var(--gradient-shell), var(--bg-muted);
  overflow-y: auto;
  min-height: 500px;
}

.wa-message {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(14px);
  transition: all 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.wa-message.visible {
  opacity: 1;
  transform: translateY(0);
}

.wa-message-agent { align-items: flex-start; }
.wa-message-user { align-items: flex-end; }

.wa-bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 14px;
  position: relative;
  box-shadow: var(--shadow-soft);
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
}

.wa-message-agent .wa-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text-primary);
}

.wa-message-user .wa-bubble {
  background: rgba(196, 181, 232, 0.32);
  border: 1px solid rgba(196, 181, 232, 0.45);
  border-top-right-radius: 4px;
  color: var(--text-primary);
}

.wa-bubble.gradient {
  background: linear-gradient(135deg, rgba(155, 181, 206, 0.95) 0%, rgba(196, 181, 232, 0.9) 100%);
  color: #fff;
  border: none;
}

.wa-bubble.gradient-pink {
  background: linear-gradient(135deg, rgba(245, 208, 197, 0.95) 0%, rgba(184, 169, 201, 0.9) 100%);
  color: var(--text-primary);
  border: none;
}

.wa-bubble.gradient-green {
  background: linear-gradient(135deg, rgba(168, 197, 181, 0.95) 0%, rgba(155, 181, 206, 0.85) 100%);
  color: var(--text-primary);
  border: none;
}

.wa-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 5px;
  padding: 0 4px;
}

.wa-message-user .wa-time { text-align: right; }

.wa-ticks { color: var(--lofi-dusty-blue); font-size: 10px; }
.wa-ticks.read { color: var(--accent); }

/* ===== TYPING ===== */
.wa-typing {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
  align-self: flex-start;
}

.wa-typing.visible { display: flex; }

.wa-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--lofi-mauve);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.wa-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.wa-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ===== RICH CONTENT ===== */
.wa-checklist {
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 10px;
}

.wa-bubble:not(.gradient):not(.gradient-pink):not(.gradient-green) .wa-checklist {
  background: var(--bg-muted);
  border-color: var(--border);
}

.wa-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 13px;
}

.wa-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.wa-product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.wa-product-image {
  height: 110px;
  display: block;
  overflow: hidden;
  background: var(--bg-muted);
}

.wa-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wa-product-info { padding: 10px; }

.wa-product-info h5 {
  margin: 0 0 5px;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
}

.wa-product-price {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: #4A8F6E;
}

.wa-dashboard {
  background: linear-gradient(135deg, rgba(155, 181, 206, 0.25) 0%, rgba(196, 181, 232, 0.2) 100%);
  border: 1px solid rgba(155, 181, 206, 0.35);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text-primary);
  margin-top: 10px;
}

.wa-dashboard-pink {
  background: linear-gradient(135deg, rgba(245, 208, 197, 0.35) 0%, rgba(184, 169, 201, 0.25) 100%);
  border-color: rgba(184, 169, 201, 0.35);
}

.wa-bubble.gradient .wa-dashboard,
.wa-bubble.gradient-green .wa-dashboard,
.wa-bubble.gradient-pink .wa-dashboard {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
  color: inherit;
}

.wa-dashboard-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.wa-stat-mini {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.wa-bubble.gradient .wa-stat-mini,
.wa-bubble.gradient-green .wa-stat-mini,
.wa-bubble.gradient-pink .wa-stat-mini {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.25);
}

.wa-stat-icon { font-size: 18px; margin-bottom: 4px; }

.wa-stat-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
}

.wa-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.wa-flow {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 10px;
}

.wa-flow-step {
  background: rgba(123, 159, 212, 0.15);
  border: 1px solid rgba(123, 159, 212, 0.25);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 99px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  margin-bottom: 6px;
}

.wa-flow-arrow {
  text-align: center;
  color: var(--lofi-mauve);
  font-size: 14px;
  margin: -2px 0;
}

.wa-link-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 10px;
}

.wa-bubble.gradient .wa-link-preview {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.wa-link-icon { font-size: 22px; }
.wa-link-info { flex: 1; }

.wa-link-title {
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-mono);
}

.wa-link-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.wa-link-items {
  font-size: 12px;
  margin-top: 8px;
  font-family: var(--font-mono);
}

.wa-section-label {
  text-align: center;
  margin: 28px 0 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.wa-attachment {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.wa-attachment-icon {
  width: 40px;
  height: 40px;
  background: rgba(168, 197, 181, 0.45);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.wa-attachment-name {
  font-size: 13px;
  font-weight: 600;
}

.wa-attachment-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.wa-attachment-status {
  font-size: 11px;
  color: #4A8F6E;
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ===== INPUT BAR ===== */
.wa-input-bar {
  background: var(--bg-glass-strong);
  backdrop-filter: blur(16px);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
}

.wa-input {
  flex: 1;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  color: var(--text-muted);
}

.wa-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--text-primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: default;
  opacity: 0.5;
}

/* ===== SKIP BUTTON ===== */
.wa-skip {
  position: fixed;
  bottom: 24px;
  left: 20px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(16px);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 11px 18px;
  border-radius: 99px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: var(--shadow-glass);
  z-index: 1000;
  transition: border-color 0.15s, transform 0.15s;
}

.wa-skip:hover {
  border-color: var(--lofi-lavender);
  transform: translateY(-1px);
}

/* ===== PAGE FLIP (mobile) ===== */
@media (max-width: 768px) {
  body { perspective: 2000px; overflow-x: hidden; }

  .wa-fullpage { max-width: 100%; border: none; }
  .wa-bubble { max-width: 88%; }
  .wa-product-grid { grid-template-columns: 1fr; }

  .page-flip-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
  }

  .page-flip-container.active { pointer-events: all; opacity: 1; }
  .page-flip-container.flipping { transform: rotateY(180deg); }

  .page-flip-front,
  .page-flip-back {
    position: absolute;
    width: 100%; height: 100%;
    backface-visibility: hidden;
    overflow-y: auto;
  }

  .page-flip-front { background: var(--color-bg-primary); transform: rotateY(0deg); }
  .page-flip-back { background: var(--color-bg-secondary); transform: rotateY(180deg); }

  .page-flip-loading {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
  }

  .page-flip-spinner {
    width: 44px; height: 44px;
    border: 3px solid var(--color-border);
    border-top-color: var(--pastel-blue);
    border-radius: 50%;
    animation: pageFlipSpin 1s linear infinite;
    margin: 0 auto 12px;
  }

  body.page-flipping { overflow: hidden; }
}

@media (min-width: 769px) {
  .page-flip-container { display: none; }
}

@keyframes pageFlipSpin {
  to { transform: rotate(360deg); }
}