/* MIRA — docked launcher + enterprise-style chat panel (global widget) */

.mira-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Dock: single launcher (icon anchored right; hover extends pill left) ---
 * Flush lower-right corner: keep bottom inset minimal so the FAB isn’t “floating” upward.
 */
.mira-dock {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  padding: 2px 4px 4px 6px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
  /* Keep expanded pill inside the viewport (prevents “M” / label clipped at left edge). */
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
}

.mira-dock > * {
  pointer-events: auto;
}

.mira-launcher {
  display: inline-flex;
  padding: 0;
  margin: 0;
  border: none;
  cursor: pointer;
  background: transparent;
  border-radius: 999px;
  font-family: Manrope, system-ui, sans-serif;
  vertical-align: bottom;
  max-width: 100%;
}

.mira-launcher:focus {
  outline: none;
}

.mira-launcher:focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 4px;
  border-radius: 999px;
}

/*
 * Pill shell: static shadow only. Pulsing ring lives on .mira-launcher-icon-wrap::before
 * (perfect circle around the logo; never drifts when the pill grows).
 * Hover lift on .mira-launcher. Expanded state also toggled via .mira-launcher--hover (JS)
 * so trackpads / odd pointer queries still get the pill.
 */
.mira-launcher-inner {
  position: relative;
  z-index: 1;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  box-sizing: border-box;
  min-width: 72px;
  min-height: 64px;
  padding: 8px 10px;
  max-width: min(100%, calc(100vw - 80px), 380px);
  border-radius: 999px;
  overflow: visible;
  background: linear-gradient(160deg, rgba(34, 211, 238, 0.22), rgba(6, 182, 212, 0.12));
  transition:
    min-width 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 10px 36px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(34, 211, 238, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  .mira-launcher-inner {
    box-shadow:
      0 10px 36px rgba(0, 0, 0, 0.42),
      0 0 0 1px rgba(34, 211, 238, 0.45);
  }
}

/* Label is absolutely positioned + width animates — avoids ultra-narrow flex column (vertical letter garbage). */
.mira-launcher-copy {
  box-sizing: border-box;
  position: absolute;
  right: 60px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  max-width: min(274px, calc(100vw - 160px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  text-align: right;
  padding: 0;
  margin: 0;
  opacity: 0;
  transition:
    width 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.2s ease 0.05s;
  pointer-events: none;
  z-index: 2;
}

.mira-launcher-copy strong {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.35;
  color: #e5eefb;
  white-space: nowrap;
}

.mira-launcher-desc {
  font-size: 11px;
  line-height: 1.4;
  color: #93a4c0;
  max-width: min(274px, calc(100vw - 160px));
  white-space: normal;
  word-wrap: break-word;
}

/* Hover lift on .mira-launcher-inner only — transform on the outer <button> skews centered ::before ring. */
@media (hover: hover) {
  .mira-launcher:hover .mira-launcher-inner,
  .mira-launcher.mira-launcher--hover .mira-launcher-inner {
    min-width: min(320px, calc(100vw - 80px));
    transform: translateY(-1px);
  }

  .mira-launcher:hover .mira-launcher-copy,
  .mira-launcher.mira-launcher--hover .mira-launcher-copy {
    width: min(248px, calc(100vw - 168px));
    opacity: 1;
    pointer-events: auto;
  }
}

.mira-launcher:focus-visible .mira-launcher-inner {
  min-width: min(320px, calc(100vw - 80px));
  transform: translateY(-1px);
}

.mira-launcher:focus-visible .mira-launcher-copy {
  width: min(248px, calc(100vw - 168px));
  opacity: 1;
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .mira-launcher-inner,
  .mira-launcher-copy {
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}

.mira-launcher-icon-wrap {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  align-self: center;
  box-sizing: border-box;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: visible;
}

/* Concentric pulse: fixed-size circle (no % + translate — avoids subpixel drift vs logo). */
.mira-launcher-icon-wrap::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62px;
  height: 62px;
  margin: -31px 0 0 -31px;
  box-sizing: border-box;
  border-radius: 50%;
  pointer-events: none;
  border: 2px solid rgba(34, 211, 238, 0.5);
  z-index: 0;
  animation: mira-icon-ring 2.85s ease-in-out infinite;
  will-change: opacity;
}

@keyframes mira-icon-ring {
  0%,
  100% {
    opacity: 0.9;
    border-color: rgba(34, 211, 238, 0.5);
  }

  50% {
    opacity: 0.35;
    border-color: rgba(34, 211, 238, 0.22);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mira-launcher-icon-wrap::before {
    animation: none;
    opacity: 0.55;
  }
}

/* Same drawable size as .mira-panel-brand > img (36) so FAB mark matches chat header glyph. */
.mira-launcher-icon-wrap img {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
}

.mira-launcher[hidden] {
  display: none !important;
}

/* --- Chat panel ---
 * Bottom-right, flush to the viewport when open — the FAB is hidden while the panel is open,
 * so we must NOT reserve ~90px above the bottom (that gap looked like “floating mid-page”).
 */
.mira-panel {
  position: fixed;
  top: auto;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  left: auto;
  z-index: 9999;
  width: min(420px, calc(100vw - 24px));
  box-sizing: border-box;
  height: min(560px, calc(100vh - 28px));
  max-height: min(560px, calc(100vh - 28px));
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(8, 14, 24, 0.98);
  border: 1px solid rgba(34, 211, 238, 0.28);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
  font-family: Manrope, system-ui, sans-serif;
}

.mira-panel[hidden] {
  display: none !important;
}

.mira-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  background: rgba(12, 22, 38, 0.98);
  border-bottom: 1px solid rgba(26, 41, 66, 0.95);
}

.mira-panel-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mira-panel-brand > img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

.mira-panel-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.mira-panel-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mira-panel-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.06em;
  line-height: 1.25;
  color: #e5eefb;
  padding-top: 1px;
}

.mira-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.25;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(34, 211, 238, 0.18);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.35);
  flex-shrink: 0;
  align-self: center;
}

.mira-panel-sub {
  font-size: 11px;
  line-height: 1.42;
  color: #93a4c0;
}

.mira-panel-close {
  flex-shrink: 0;
  background: rgba(26, 41, 66, 0.5);
  border: 1px solid rgba(26, 41, 66, 0.9);
  border-radius: 10px;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.mira-panel-close:hover {
  background: rgba(34, 211, 238, 0.12);
  color: #e5eefb;
}

.mira-disclaimer {
  margin: 0;
  padding: 8px 14px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: #7c8ca8;
  background: rgba(6, 11, 20, 0.65);
  border-bottom: 1px solid rgba(26, 41, 66, 0.65);
}

.mira-disclaimer--warn {
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.08);
  border-bottom-color: rgba(251, 191, 36, 0.25);
}

/* Suggested prompts — IBM-style chips */
.mira-suggestions {
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(26, 41, 66, 0.55);
  background: rgba(10, 18, 30, 0.65);
}

.mira-suggestions[hidden] {
  display: none !important;
}

.mira-suggestions-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 8px;
}

.mira-chip-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mira-chip {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  background: rgba(15, 26, 44, 0.65);
  color: #cbd5e1;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.mira-chip:hover:not(:disabled) {
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.08);
  color: #e5eefb;
}

.mira-chip:disabled,
.mira-chip.mira-chip--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mira-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.mira-msg {
  max-width: 94%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.mira-msg-user {
  align-self: flex-end;
  background: rgba(34, 211, 238, 0.14);
  border: 1px solid rgba(34, 211, 238, 0.28);
  color: #e5eefb;
}

.mira-msg-assistant {
  align-self: flex-start;
  background: rgba(15, 26, 44, 0.88);
  border: 1px solid rgba(26, 41, 66, 0.9);
  color: #cbd5e1;
}

.mira-msg-error {
  align-self: flex-start;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.mira-typing {
  font-size: 12px;
  color: #64748b;
  padding: 0 14px 4px;
  font-style: italic;
}

/* Composer — bordered input + icon send */
.mira-composer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 12px;
  border-top: 1px solid rgba(26, 41, 66, 0.9);
  background: rgba(6, 11, 20, 0.95);
}

.mira-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.mira-composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 2px solid rgba(34, 211, 238, 0.25);
  background: rgba(8, 14, 24, 0.95);
  color: #e5eefb;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.mira-composer textarea::placeholder {
  color: #64748b;
}

.mira-composer textarea:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.mira-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #22d3ee, #06b6d4);
  color: #041018;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.mira-send:hover:not(:disabled) {
  transform: scale(1.04);
  filter: brightness(1.05);
}

.mira-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* First-login tour */
.mira-tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(2, 6, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.mira-tour-overlay[hidden] {
  display: none !important;
}

.mira-tour-card {
  max-width: 420px;
  width: 100%;
  padding: 28px 26px;
  border-radius: 16px;
  background: rgba(10, 19, 32, 0.98);
  border: 1px solid rgba(34, 211, 238, 0.3);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.mira-tour-card h3 {
  margin: 0 0 10px;
  font-size: 20px;
  color: #e5eefb;
}

.mira-tour-card p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.6;
  color: #93a4c0;
}

.mira-tour-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mira-tour-actions button {
  flex: 1;
  min-width: 120px;
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.mira-tour-primary {
  border: none;
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #041018;
}

.mira-tour-secondary {
  border: 1px solid rgba(26, 41, 66, 0.95);
  background: transparent;
  color: #e5eefb;
}

@media (max-width: 540px) {
  .mira-panel {
    left: 0;
    right: 0;
    top: auto;
    bottom: max(0px, env(safe-area-inset-bottom, 0px));
    width: 100%;
    max-width: none;
    height: min(82vh, 560px);
    max-height: min(82vh, calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 8px));
    border-radius: 16px 16px 0 0;
  }

  .mira-dock {
    left: auto;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    align-items: flex-end;
    justify-content: flex-end;
    max-width: calc(100vw - 20px);
  }

  @media (hover: hover) {
    .mira-launcher:hover .mira-launcher-copy,
    .mira-launcher.mira-launcher--hover .mira-launcher-copy {
      width: min(228px, calc(100vw - 176px));
    }

    .mira-launcher:hover .mira-launcher-inner,
    .mira-launcher.mira-launcher--hover .mira-launcher-inner {
      min-width: min(300px, calc(100vw - 72px));
    }
  }

  .mira-launcher:focus-visible .mira-launcher-copy {
    width: min(228px, calc(100vw - 176px));
  }

  .mira-launcher:focus-visible .mira-launcher-inner {
    min-width: min(300px, calc(100vw - 72px));
  }

  .mira-launcher-desc {
    max-width: min(228px, calc(100vw - 176px));
  }
}
