/* Bftero AI – styles matching existing HUD theme */
:root {
  --ai-bg: #05030c;
  --ai-panel: rgba(15, 10, 34, 0.92);
  --ai-line: rgba(160, 150, 220, 0.14);
  --ai-cyan: #29f1e6;
  --ai-magenta: #ff3fb0;
  --ai-violet: #8b5cf6;
  --ai-text: #f2eefc;
  --ai-muted: #a79cc9;
  --ai-muted-2: #6f6591;
  --ai-grad: linear-gradient(135deg, #29f1e6, #8b5cf6 50%, #ff3fb0);
  --ai-font-display: 'Orbitron', sans-serif;
  --ai-font-body: 'Space Grotesk', sans-serif;
  --ai-font-mono: 'JetBrains Mono', monospace;
  --ai-cut: 12px;
}

.ai-page {
  min-height: 100vh;
  padding: 100px 0 60px;
  position: relative;
  z-index: 1;
}

.ai-head {
  text-align: center;
  margin-bottom: 24px;
}
.ai-head h1 {
  font-family: var(--ai-font-display);
  font-weight: 900;
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ai-head h1 span {
  background: var(--ai-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ai-head p {
  color: var(--ai-muted);
  margin-top: 8px;
  font-size: 1rem;
}

.ai-shell {
  background: linear-gradient(160deg, rgba(15, 10, 34, 0.94), rgba(21, 14, 46, 0.9));
  border: 1px solid var(--ai-line);
  backdrop-filter: blur(14px);
  clip-path: polygon(var(--ai-cut) 0, 100% 0, 100% calc(100% - var(--ai-cut)), calc(100% - var(--ai-cut)) 100%, 0 100%, 0 var(--ai-cut));
  padding: 20px;
  max-width: 720px;
  margin: 0 auto 32px;
}

.ai-character-wrap {
  position: relative;
  width: 100%;
  height: min(420px, 52vh);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--ai-line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 18px;
}
#aiCharacterStage {
  width: 100%;
  height: 100%;
}
#aiCharacterStage canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.ai-fallback-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  background: radial-gradient(circle at 50% 40%, rgba(41, 241, 230, 0.15), transparent 60%);
}

#aiLoading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(5, 3, 12, 0.75);
  z-index: 5;
  font-family: var(--ai-font-mono);
  font-size: 0.85rem;
  color: var(--ai-muted);
  letter-spacing: 0.06em;
}
.ai-load-bar {
  width: 140px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.ai-load-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  background: var(--ai-grad);
  animation: aiSweep 1s ease-in-out infinite;
}
@keyframes aiSweep {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

.ai-status {
  text-align: center;
  font-family: var(--ai-font-body);
  font-size: 1.05rem;
  color: var(--ai-text);
  min-height: 1.6em;
  margin-bottom: 16px;
}

.ai-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
}

.ai-mic-btn {
  font-family: var(--ai-font-display);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.95rem;
  padding: 18px 36px;
  background: var(--ai-grad);
  color: #05030c;
  border: none;
  cursor: pointer;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  transition: transform 0.2s, filter 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 28px -6px rgba(139, 92, 246, 0.55);
  min-width: 200px;
}
.ai-mic-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  filter: brightness(1.08);
}
.ai-mic-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.ai-mic-btn.listening {
  animation: aiPulse 1.1s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(41, 241, 230, 0.5);
}
@keyframes aiPulse {
  0% { box-shadow: 0 0 0 0 rgba(41, 241, 230, 0.45); }
  70% { box-shadow: 0 0 0 16px rgba(41, 241, 230, 0); }
  100% { box-shadow: 0 0 0 0 rgba(41, 241, 230, 0); }
}

.ai-btn-ghost {
  font-family: var(--ai-font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.72rem;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--ai-line);
  color: var(--ai-text);
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: border-color 0.2s, color 0.2s;
}
.ai-btn-ghost:hover {
  border-color: var(--ai-cyan);
  color: var(--ai-cyan);
}

.ai-transcript {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}
.ai-bubble {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--ai-line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.95rem;
  line-height: 1.45;
}
.ai-bubble label {
  display: block;
  font-family: var(--ai-font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ai-muted-2);
  margin-bottom: 6px;
}
.ai-bubble.user {
  border-left: 3px solid var(--ai-cyan);
}
.ai-bubble.ai {
  border-left: 3px solid var(--ai-magenta);
}
.ai-bubble p {
  color: var(--ai-text);
  margin: 0;
  word-break: break-word;
  min-height: 1.4em;
}

.ai-hint {
  text-align: center;
  font-family: var(--ai-font-mono);
  font-size: 0.68rem;
  color: var(--ai-muted-2);
  margin-top: 16px;
  letter-spacing: 0.04em;
}

@media (max-width: 600px) {
  .ai-shell { padding: 14px; }
  .ai-character-wrap { height: min(340px, 48vh); }
  .ai-mic-btn {
    font-size: 0.85rem;
    padding: 16px 28px;
    min-width: 180px;
    width: 100%;
    max-width: 280px;
  }
  .ai-controls { gap: 8px; }
}


/* Full chat history */
.ai-chat-history {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 14px;
  padding: 10px 8px;
  border: 1px solid var(--ai-line);
  border-radius: 10px;
  background: rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-hist-empty {
  color: var(--ai-muted-2);
  font-size: 0.85rem;
  text-align: center;
  margin: 8px 0;
}
.ai-hist-row {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.ai-hist-row.user {
  background: rgba(41,241,230,0.08);
  border-left: 3px solid var(--ai-cyan);
}
.ai-hist-row.ai {
  background: rgba(255,63,176,0.08);
  border-left: 3px solid var(--ai-magenta);
}
.ai-hist-who {
  display: block;
  font-family: var(--ai-font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ai-muted-2);
  margin-bottom: 4px;
}
.ai-hist-row p { margin: 0; color: var(--ai-text); white-space: pre-wrap; word-break: break-word; }
