/* AUREA AI App (/ai-app) — full-viewport chat app frame.
 * Message bubbles, markdown, feedback and composer internals are
 * reused from chat.css / ai.css; this file only turns the /chat
 * frame into a standalone app shell (100dvh, no portal chrome)
 * and styles the app-only parts: splash, conversation search,
 * rename, per-reply actions (copy / regenerate), voice input
 * and the stop button. */

html, body.aiapp-body { height: 100%; }
body.aiapp-body {
  margin: 0;
  overflow: hidden;
  background: #0A0F1E;
}

.aiapp-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- boot splash (shown until the app settles) ---------- */
.aiapp-splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(120% 90% at 50% 0%, #16224d 0%, #0A0F1E 60%);
  transition: opacity 0.35s ease;
}
.aiapp-splash.is-gone { opacity: 0; pointer-events: none; }
.aiapp-splash img {
  border-radius: 24px;
  box-shadow: 0 0 34px rgba(255, 215, 0, 0.35),
    0 0 60px rgba(147, 51, 234, 0.30);
}
.aiapp-splash-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #f5c451;
}
.aiapp-splash-dots { display: flex; gap: 7px; }
.aiapp-splash-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #A7ACC2;
  animation: chatapp-wait-pulse 1.2s ease-in-out infinite;
}
.aiapp-splash-dots span:nth-child(2) { animation-delay: 0.18s; }
.aiapp-splash-dots span:nth-child(3) { animation-delay: 0.36s; }
@media (prefers-reduced-motion: reduce) {
  .aiapp-splash-dots span { animation: none; }
  .aiapp-splash { transition: none; }
}

/* ---------- soon / sign-in states ---------- */
.aiapp-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.aiapp-signin-card { text-align: center; max-width: 420px; }
.aiapp-signin-dragon { border-radius: 50%; margin-bottom: 8px; }
.aiapp-state-home { margin: 12px 0 0; }
.aiapp-state-home a { color: var(--gold, #f5c451); }

/* ---------- app frame (overrides the /chat card frame) ---------- */
.aiapp-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background:
    radial-gradient(90% 60% at 50% -10%, rgba(147, 51, 234, 0.14) 0%, rgba(10, 15, 30, 0) 60%),
    rgba(255, 255, 255, 0.01);
}
.aiapp-bar {
  border-bottom: 1px solid rgba(255, 215, 0, 0.28);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
  padding-top: calc(10px + env(safe-area-inset-top));
}
.aiapp-lang { max-width: 132px; }
.aiapp-home {
  color: var(--muted, #A7ACC2);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.aiapp-home:hover { color: var(--gold, #f5c451); }
.aiapp-install { white-space: nowrap; }
.aiapp-pwanote {
  font-size: 0.82rem;
  color: var(--muted, #A7ACC2);
  margin: 8px 0 0;
}

.aiapp-body-grid {
  flex: 1;
  height: auto;
  min-height: 0;
  grid-template-columns: 300px 1fr;
}
.aiapp-side { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.aiapp-search {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid #39415F;
  background: #12182e;
  color: inherit;
  padding: 8px 11px;
  font-size: 0.9rem;
  font-family: inherit;
}
.aiapp-search::placeholder { color: #9BA3BC; }
.aiapp-noresults {
  font-size: 0.85rem;
  color: var(--muted, #A7ACC2);
  padding: 8px 4px;
}
.aiapp-side-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}
.aiapp-side-links a {
  color: var(--muted, #A7ACC2);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}
.aiapp-side-links a:hover { color: var(--gold, #f5c451); }

/* conversation item: rename affordance + inline editor */
.chatapp-item { grid-template-columns: 1fr auto auto auto; }
.aiapp-rename-btn {
  background: none;
  border: none;
  color: var(--muted, #A7ACC2);
  cursor: pointer;
  padding: 2px 4px;
  display: inline-flex;
}
.aiapp-rename-btn svg { width: 14px; height: 14px; }
.aiapp-rename-btn:hover { color: var(--gold, #f5c451); }
.aiapp-rename-row {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px;
}
.aiapp-rename-input {
  flex: 1;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.55);
  background: #12182e;
  color: inherit;
  padding: 7px 9px;
  font-size: 0.9rem;
  font-family: inherit;
}
.aiapp-rename-save, .aiapp-rename-cancel {
  border-radius: 8px;
  border: 1px solid #39415F;
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.aiapp-rename-save {
  background: linear-gradient(135deg, #FFD700, #f5c451);
  color: #14100a;
  border: none;
}

/* per-reply actions: copy / regenerate */
.aiapp-actions {
  align-self: flex-start;
  display: flex;
  gap: 6px;
  margin: -2px 0 8px;
}
.aiapp-act-btn {
  background: var(--surface, #12182e);
  color: var(--muted, #A7ACC2);
  border: 1px solid #39415F;
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.aiapp-act-btn svg { width: 13px; height: 13px; }
.aiapp-act-btn:hover { color: var(--gold, #f5c451); border-color: rgba(255, 215, 0, 0.5); }
.aiapp-act-btn:disabled { opacity: 0.5; cursor: default; }

/* composer: mic + stop */
.aiapp-mic {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 14px;
  border: 1px solid #57638C;
  background: #1B2338;
  color: var(--muted, #A7ACC2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.aiapp-mic svg { width: 20px; height: 20px; }
.aiapp-mic:hover { color: var(--gold, #f5c451); }
.aiapp-mic.is-listening {
  color: #ff8f8f;
  border-color: rgba(255, 120, 120, 0.65);
  animation: chatapp-wait-pulse 1.2s ease-in-out infinite;
}
.aiapp-stop { min-height: 46px; padding: 0 18px; }

.chatapp-composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

@media (max-width: 760px) {
  .aiapp-body-grid {
    grid-template-columns: 1fr;
    position: relative;
  }
  .aiapp-side {
    position: absolute;
    z-index: 5;
    top: 0; bottom: 0; left: 0;
    width: min(300px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    background: #0d1330;
  }
  .aiapp-side.open { transform: none; }
  .aiapp-lang { max-width: 104px; }
  .aiapp-home { display: none; }
}
