/* ============================================================
   CLEARLI AI NUTRITIONIST — Chat Page Styles
   Clean white theme with borders · Snow Lottie background
   ============================================================ */

:root {
  --ain-bg:             #ffffff;
  --ain-surface:        #f0f4f9;
  --ain-border:         #e8eaed;
  --ain-text:           #1b1b1f;
  --ain-text-muted:     #80868b;
  --ain-green-fill:     #e8f5e9;
  --ain-green-border:   #c8e6c9;
  --ain-green-accent:   #1b8a4a;
  --ain-ai-bg:          transparent;
  --ain-ai-border:      transparent;
  --ain-topbar-h:       56px;
  --ain-avatar-h:       140px;
  --ain-input-bar-h:    72px;
  --ain-radius:         22px;
  --ain-radius-sm:      14px;
  --ain-offline-glow:   rgba(59, 130, 246, 0.12);
  --ain-offline-blue:   #3b82f6;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }html { background-color: var(--ain-bg); }
/* ── Snow Background Layer ────────────────────────────────── */
.ain-snow-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.3;
}
@media (max-width: 600px) {
  /* Lower compositing hit on mobile */
  .ain-snow-bg { opacity: 0.15; }
}

/* ── Page Shell ──────────────────────────────────────────── */
.ain-body {
  position: fixed;
  background: linear-gradient(to bottom, rgba(171, 107, 255, 0.95) 0%, rgba(8, 0, 90, 0.85) 100%);
  inset: 0;
  display: flex;
  flex-direction: column;
  background-color: transparent;
  color: var(--ain-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: transform 0.65s ease, background-color 0.65s ease;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  z-index: 1;
}

/* Offline variant */
.ain-body.ain--offline {
  background: linear-gradient( rgb(110, 110, 110), rgb(0, 0, 101));
}
.ain-body.ain--offline .ain-topbar {
  border-bottom-color: rgb(0, 53, 138);
}
.ain-body.ain--offline .ain-lottie {
  filter: hue-rotate(115deg) saturate(1);
}
.ain-body.ain--offline .ain-bubble--ai{
    background-color: #80868b;
    color: white;
    box-shadow: 10px 10px 0 greenyellow;
  }


/* ── Top Bar ─────────────────────────────────────────────── */
.ain-topbar {
  background:transparent;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--ain-topbar-h) + env(safe-area-inset-top, 0px));
  backdrop-filter: blur(2.5px);
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 8px;
  padding-right: 12px;
}

.ain-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.ain-back:active { color: var(--ain-text); background-color: rgba(0,0,0,0.04); }

.ain-topbar-center {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  justify-content: center;
  margin: 0 8px;
}
.ain-title-lottie {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  pointer-events: none;
}
.ain-title {
  pointer-events: none;
  font-family: 'quick-gaseous', BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 2.5rem;
  letter-spacing: 1px;
  color: var(--ain-text);
  font-weight: 100;
  white-space: nowrap;
}

/* Status indicator dot */
.ain-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ain-text-muted);
  transition: background-color 0.3s;
}
.ain-status--idle    { background-color: var(--ain-text-muted); }
.ain-status--loading { background-color: #f59e0b; animation: ain-pulse-dot 1.1s ease-in-out infinite; will-change: opacity; }
.ain-status--ready   { background-color: var(--ain-green-accent); }
.ain-status--error   { background-color: #ef4444; }

@keyframes ain-pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

.ain-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.ain-clear-btn:active { color: var(--ain-text); background-color: rgba(0,0,0,0.04); }

/* ── AI Avatar (central pulse) ───────────────────────────── */
.ain-avatar-section {
  position: fixed;
  left: 0; right: 0;
  height: var(--ain-avatar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 100;
  pointer-events: none;
  background: transparent;
}
.ain-body.ain--offline .ain-avatar-section {
  background: transparent;
}


/* .ain-lottie {
  width: 100%;
  height: 100%;
  display: block;
  transition: filter 0.8s ease;
} */

.ain-avatar-label-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
margin-top: 5%;
margin-bottom: 0%;}


.ain-avatar-lottie {
  width: 100px;
  height: 100px;
  display: block;
  pointer-events: none;
}

/* ── Toasts ──────────────────────────────────────────────── */
.ain-toast {
  font-family: 'quick-gaseous' ;
  position: fixed;
  top: calc(var(--ain-topbar-h) + 10px);
  right: 12px;
  -webkit-transform: translateX(12px) translateZ(0);
  transform: translateX(12px) translateZ(0);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 300;
  will-change: transform, opacity;
}
.ain-toast--offline {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #93c5fd;
  color: #1e40af;
}
.ain-toast--ready {
  background: rgba(255, 245, 245, 0.97);
  border: 1px solid #86efac;
  color: #166534;
}
.ain-toast--visible {
  opacity: 1;
  -webkit-transform: translateX(0) translateZ(0);
  transform: translateX(0) translateZ(0);
}

/* ── Chat Scroll Area ───────────────────────────────────────*/
.ain-chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* Push content below fixed top elements and above input bar */
  padding: calc(var(--ain-topbar-h) + var(--ain-avatar-h) + env(safe-area-inset-top, 0px) + 8px)
           4px
           calc(var(--ain-input-bar-h) + env(safe-area-inset-bottom, 0px) + 16px)
           4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.ain-chat-area::-webkit-scrollbar { display: none; }

/* ── Chat Bubbles ────────────────────────────────────────── */
.ain-bubble {
  background-color: pink;
  max-width: 88%;
  padding: 12px 16px;
  border-radius: var(--ain-radius);
  line-height: 1.7;
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  animation: ain-bubble-pop 0.22s ease both;
  will-change: transform, opacity;
}
@keyframes ain-bubble-pop {
  from { opacity: 0; transform: translateY(10px) translateZ(0); }
  to   { opacity: 1; transform: translateY(0) translateZ(0); }
}
  
/* User bubble */
.ain-bubble--user {
  font-family: 'quick-gaseous', -apple-system, BlinkMacSystemFont, sans-serif;
  align-self: flex-end;
  background-color: var(--ain-surface);
  color: var(--ain-text);
  border: none;
  border-radius: var(--ain-radius) 6px var(--ain-radius) var(--ain-radius);
}

/* AI bubble */
.ain-bubble--ai {
  font-family: monospace, -apple-system, BlinkMacSystemFont, 'Segoe UI Mono', Consolas, 'Courier New', monospace;
  align-self: flex-start;
  background-color: rgb(0, 215, 0);
  color: var(--ain-text);
  border: solid 2px rgb(0, 0, 0);
  border-radius: 6px var(--ain-radius) var(--ain-radius) var(--ain-radius);
  padding: 10px;
  box-shadow: 10px 10px 0 rgb(255, 157, 0);
}

/* Blinking cursor while the model is streaming text */
.ain-bubble--streaming::after {
  content: '▋';
  display: inline;
  margin-left: 1px;
  color: var(--ain-green-accent);
  animation: ain-cursor-blink 0.65s steps(1) infinite;
  will-change: opacity;
}
@keyframes ain-cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Error bubble */
.ain-bubble--error {
  align-self: flex-start;
  background-color: #fef2f2;
  border: none;
  color: #991b1b;
  font-size: 0.9rem;
  border-radius: 6px var(--ain-radius) var(--ain-radius) var(--ain-radius);
}

/* ── Skeleton Loading State ──────────────────────────────── */
.ain-bubble--skeleton {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 170px;
  pointer-events: none;
  background-color: var(--ain-surface);
  border: none;
  border-radius: 6px var(--ain-radius) var(--ain-radius) var(--ain-radius);
}

.ain-skeleton-line {
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    #f3f4f6 0%,
    #e5e7eb 50%,
    #f3f4f6 100%
  );
  background-size: 200% 100%;
  animation: ain-shimmer 1.6s ease-in-out infinite;
  will-change: background-position;
}
@keyframes ain-shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* ── Input Bar ───────────────────────────────────────────── */
.ain-input-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  margin: 5px 10px 15px;
  padding: 10px 16px 16px;
  background:transparent;
  border-top: 1px solid rgb(255, 255, 255);
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
  transition: background-color 0.65s ease;
}
.ain-body.ain--offline .ain-input-bar {
  background-color: rgba(241, 245, 249, 0.85);
}

.ain-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background-color: var(--ain-surface);
  border-radius: 26px;
  padding: 8px 8px 8px 18px;
  border: 1px solid transparent;
  transition: border-color 0.2s, background-color 0.2s;
}
.ain-input-wrap:focus-within {
  border-color: var(--ain-green-accent);
  background-color: #fff;
}
.ain-body.ain--offline .ain-input-wrap:focus-within {
  border-color: rgba(59, 130, 246, 0.4);
}

.ain-textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--ain-text);
  font-size: 1rem;
  line-height: 1.5;
  max-height: 110px;
  overflow-y: auto;
  scrollbar-width: none;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  caret-color: var(--ain-green-accent);
}
.ain-textarea::-webkit-scrollbar { display: none; }

.ain-send-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background-color: var(--ain-green-accent);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.18s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
.ain-send-btn:not(:disabled):active {
  transform: scale(0.9) translateZ(0);
  background-color: var(--ain-green-border);
}
.ain-send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.ain-privacy-note {
  font-size: 0.67rem;
  color: var(--ain-text-muted);
  text-align: center;
  margin-top: 5px;
  letter-spacing: 0.025em;
}

/* ── Quick Question Bubbles ───────────────────────────────── */
.ain-quick-questions {
  position: fixed;
  bottom: calc(var(--ain-input-bar-h) + env(safe-area-inset-bottom, 0px) + 20px);
  left: 0; right: 0;
  z-index: 199;
  display: flex;
  gap: 8px;
  padding: 0 16px;
  justify-content: center;
  flex-wrap: wrap;
  pointer-events: auto;
}
.ain-quick-q {
  font-family: 'quick-gaseous', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(6px);
  transition: background 0.18s, transform 0.1s;
}
.ain-quick-q:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.22);
}

/* ── Responsiveness ──────────────────────────────────────── */
@media (min-width: 480px) {
  .ain-chat-area { padding-left: calc((100% - 480px) / 2 + 16px); padding-right: calc((100% - 480px) / 2 + 16px); }
  .ain-input-bar { max-width: 520px; left: 50%; right: auto; transform: translateX(-50%) translateZ(0); bottom: 10px; border: 1px solid var(--ain-border); border-radius: 26px; }
  .ain-quick-questions { max-width: 520px; left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--ain-input-bar-h) + 24px); }
}
