/* ==========================================================================
   FrontTerrain - Miko in-app AI Agent & Aura Harvester Styles
   ========================================================================== */

/* Fixed Floating Widget Container */
.miko-dock {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1500;
  font-family: var(--font-sans, 'Inter', sans-serif);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  user-select: none;
}

/* Idle Speech Bubble (Pops up automatically above the button) */
.miko-speech-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  background: rgba(15, 20, 28, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text, #f7f9fa);
  padding: 0.6rem 0.95rem;
  border-radius: 14px;
  font-size: 0.82rem;
  font-weight: 500;
  width: max-content;
  max-width: 280px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 15px rgba(56, 189, 248, 0.15);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  z-index: 10;
}

.miko-speech-bubble.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  cursor: pointer;
}

[data-theme="light"] .miko-speech-bubble {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* Floating Avatar Button */
.miko-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.85rem 0.45rem 0.5rem;
  border-radius: 9999px;
  background: rgba(15, 20, 28, 0.85);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 24px rgba(56, 189, 248, 0.2);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

[data-theme="light"] .miko-trigger-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #0f1419;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1), 0 0 20px rgba(37, 99, 235, 0.15);
}

.miko-trigger-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45), 0 0 32px rgba(56, 189, 248, 0.35);
  border-color: rgba(56, 189, 248, 0.4);
}

/* Miko Glowing Orb Avatar */
.miko-avatar-orb {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #93c5fd 0%, #3b82f6 50%, #1e1b4b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.6);
  flex-shrink: 0;
  animation: miko-orb-float 4s ease-in-out infinite alternate;
}

@keyframes miko-orb-float {
  0% { transform: scale(0.97) rotate(0deg); }
  50% { transform: scale(1.04) rotate(4deg); }
  100% { transform: scale(0.97) rotate(0deg); }
}

.miko-avatar-face {
  position: relative;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Expressive glowing eyes */
.miko-eye {
  width: 4px;
  height: 7px;
  background: #ffffff;
  border-radius: 3px;
  box-shadow: 0 0 6px #ffffff, 0 0 10px #38bdf8;
  transition: all 0.2s ease;
  animation: miko-blink 5s infinite;
}

.miko-eye:first-child { margin-right: 5px; }

@keyframes miko-blink {
  0%, 94%, 98%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

.miko-label-group {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.miko-name-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.miko-aura-pill {
  font-size: 0.7rem;
  font-weight: 600;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

/* Floating Aura +Points Splash Animation */
.miko-aura-splash {
  position: fixed;
  font-size: 0.95rem;
  font-weight: 800;
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
  pointer-events: none;
  z-index: 2000;
  animation: aura-splash-rise 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes aura-splash-rise {
  0% { opacity: 0; transform: translate(0, 0) scale(0.8); }
  20% { opacity: 1; transform: translate(0, -10px) scale(1.1); }
  100% { opacity: 0; transform: translate(0, -45px) scale(0.95); }
}

/* Expanded Chat Window */
.miko-window {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: rgba(13, 17, 24, 0.92);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 35px rgba(56, 189, 248, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
  z-index: 20;
}

.miko-window.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Hide speech bubble when window is open */
.miko-window.is-open ~ .miko-speech-bubble,
.miko-dock.window-active .miko-speech-bubble {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

[data-theme="light"] .miko-window {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.12);
}

/* Window Header */
.miko-window-header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .miko-window-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.miko-header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.miko-header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text, #f7f9fa);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.miko-header-rank {
  font-size: 0.7rem;
  font-weight: 600;
  color: #38bdf8;
  letter-spacing: 0.02em;
}

.miko-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.miko-action-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #9ba4b4);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.miko-action-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text, #ffffff);
}

[data-theme="light"] .miko-action-icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0f1419;
}

/* Aura Level Bar Strip */
.miko-aura-bar-strip {
  padding: 0.55rem 1.1rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

[data-theme="light"] .miko-aura-bar-strip {
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.miko-aura-meter {
  flex: 1;
  height: 6px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  position: relative;
}

[data-theme="light"] .miko-aura-meter {
  background: rgba(0, 0, 0, 0.08);
}

.miko-aura-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #38bdf8, #fbbf24);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
  transition: width 0.4s ease;
}

.miko-farm-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 9999px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(56, 189, 248, 0.15));
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.miko-farm-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

/* Messages Area */
.miko-messages-container {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

.miko-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  font-size: 0.84rem;
  line-height: 1.45;
  animation: miko-msg-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes miko-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.miko-msg.miko-msg-agent {
  align-self: flex-start;
}

.miko-msg.miko-msg-user {
  align-self: flex-end;
}

.miko-bubble {
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
}

.miko-msg-agent .miko-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text, #f7f9fa);
  border-bottom-left-radius: 4px;
}

[data-theme="light"] .miko-msg-agent .miko-bubble {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: #0f1419;
}

.miko-msg-user .miko-bubble {
  background: var(--accent-blue, #2563eb);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.miko-msg-meta {
  font-size: 0.68rem;
  color: var(--text-muted, #9ba4b4);
  margin-top: 0.25rem;
  padding: 0 0.25rem;
}

/* Prompt Chips */
.miko-chips-tray {
  padding: 0.4rem 0.9rem;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.miko-chips-tray::-webkit-scrollbar { display: none; }

.miko-chip {
  padding: 0.3rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary, #9ba4b4);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.miko-chip:hover {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-blue, #38bdf8);
  border-color: rgba(56, 189, 248, 0.3);
}

/* Chat Input Bar */
.miko-input-bar {
  padding: 0.65rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .miko-input-bar {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.miko-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text, #ffffff);
  font-size: 0.85rem;
  font-family: inherit;
}

.miko-input::placeholder {
  color: var(--text-muted, #9ba4b4);
}

.miko-send-btn {
  background: var(--accent-blue, #3b82f6);
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.miko-send-btn:hover {
  transform: scale(1.06);
  background: #2563eb;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .miko-dock {
    bottom: 16px;
    right: 16px;
  }
  .miko-window {
    width: calc(100vw - 32px);
    height: 480px;
    bottom: 0;
  }
  .miko-trigger-btn {
    padding: 0.4rem;
  }
  .miko-label-group {
    display: none;
  }
}
