/* X10 Investment Lab — Floating macOS Apple Intelligence AI Orb & Frosted Sheet */

/* Leave room above orb for alert toasts */
#x10-toast-stack {
  bottom: 94px !important;
}

/* ==========================================================================
   1. FLOATING MACOS / APPLE INTELLIGENCE ANIMATED ORB (#x10-mac-ai-fab)
   ========================================================================== */
#x10-mac-ai-fab {
  position: fixed !important;
  right: 22px;
  bottom: 22px;
  z-index: 88;
  width: 58px !important;
  height: 58px !important;
  min-height: 58px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  border: 0 !important;
  background: transparent !important;
  overflow: visible !important;
  cursor: pointer;
  touch-action: none;
  box-shadow:
    0 12px 28px rgba(15, 23, 42, 0.28),
    0 0 26px rgba(99, 102, 241, 0.34),
    0 0 18px rgba(236, 72, 153, 0.24) !important;
  transition: transform 0.28s cubic-bezier(.22, 1, .36, 1), box-shadow 0.28s ease !important;
}

#x10-mac-ai-fab:hover {
  transform: translateY(-3px) scale(1.06) !important;
  box-shadow:
    0 16px 36px rgba(15, 23, 42, 0.34),
    0 0 34px rgba(6, 182, 212, 0.48),
    0 0 24px rgba(236, 72, 153, 0.36) !important;
}

#x10-mac-ai-fab:active {
  transform: scale(0.95) !important;
}

.mac-ai-orb-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #06b6d4, #6366f1, #ec4899, #f59e0b, #10b981, #06b6d4);
  filter: blur(3.5px);
  opacity: 0.92;
  animation: mac-orb-spin 6s linear infinite;
  pointer-events: none;
}

#x10-mac-ai-fab.is-thinking .mac-ai-orb-ring {
  inset: -5px;
  animation-duration: 1.3s;
  filter: blur(4.5px);
}

.mac-ai-orb-svg {
  position: relative;
  width: 58px;
  height: 58px;
  display: block;
  border-radius: 50%;
  pointer-events: none;
}

.mac-orb-wave-1 {
  transform-box: fill-box;
  transform-origin: center;
  animation: mac-orb-morph 7s ease-in-out infinite alternate;
}

.mac-orb-wave-2 {
  transform-box: fill-box;
  transform-origin: center;
  animation: mac-orb-morph 9s ease-in-out infinite reverse;
}

.mac-orb-spark {
  transform-box: fill-box;
  transform-origin: center;
  animation: mac-spark-breathe 3.2s ease-in-out infinite;
}

.mac-ai-pill {
  position: absolute;
  right: 68px;
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(8, 22, 36, 0.16);
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(.22, 1, .36, 1);
}

#x10-mac-ai-fab:hover .mac-ai-pill,
#x10-mac-ai-fab:focus-visible .mac-ai-pill {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

#x10-mac-ai-fab.is-open .mac-ai-pill {
  opacity: 0 !important;
}

/* ==========================================================================
   2. MACOS FROSTED-GLASS SHEET (#x10-mac-ai-panel)
   ========================================================================== */
#x10-mac-ai-panel {
  position: fixed !important;
  right: 22px;
  bottom: 92px;
  z-index: 89;
  width: min(430px, calc(100vw - 28px));
  height: min(560px, calc(100dvh - 116px));
  max-height: calc(100dvh - 108px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, rgba(255, 255, 255, 0.45));
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(22px) saturate(165%);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  box-shadow:
    0 24px 60px rgba(8, 18, 32, 0.28),
    0 2px 10px rgba(8, 18, 32, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  overflow: hidden;
  transform-origin: bottom right;
  animation: mac-sheet-in 0.26s cubic-bezier(.22, 1, .36, 1);
}

#x10-mac-ai-panel[hidden] {
  display: none !important;
}

#x10-mac-ai-panel.is-loading::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 2px;
  background: conic-gradient(from var(--mac-glow-angle, 0deg), #06b6d4, #6366f1, #ec4899, #f59e0b, #10b981, #06b6d4);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 5;
  animation: mac-glow-rotate 2.2s linear infinite;
}

#x10-mac-ai-panel.is-collapsed {
  height: auto !important;
}

#x10-mac-ai-panel.is-collapsed .mac-ai-body,
#x10-mac-ai-panel.is-collapsed .mac-ai-foot {
  display: none !important;
}

/* Titlebar with Authentic macOS Traffic Lights + Mode Switcher */
.mac-ai-titlebar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 13px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--panel2) 78%, transparent);
  user-select: none;
}

.mac-traffic-lights {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
}

.mac-dot {
  width: 12px !important;
  height: 12px !important;
  min-width: 12px !important;
  min-height: 12px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  border: 1px solid rgba(0, 0, 0, 0.14) !important;
  box-shadow: none !important;
  display: grid !important;
  place-items: center;
  font-size: 8px !important;
  line-height: 1 !important;
  color: transparent !important;
  transition: transform 0.14s ease, color 0.14s ease !important;
}

.mac-traffic-lights:hover .mac-dot {
  color: rgba(0, 0, 0, 0.65) !important;
}

.mac-dot-close { background: #ff5f57 !important; }
.mac-dot-min   { background: #febc2e !important; }
.mac-dot-full  { background: #28c840 !important; }

.mac-ai-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
}

.mac-ai-mode-seg {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  gap: 2px;
}

.mac-ai-mode-seg button {
  min-height: 24px !important;
  height: 24px !important;
  padding: 0 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--muted) !important;
  box-shadow: none !important;
}

.mac-ai-mode-seg button.is-active {
  background: linear-gradient(135deg, #4f46e5, #0891b2) !important;
  color: #ffffff !important;
}

.mac-ai-controls {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

.mac-ai-ticker-box input {
  width: 62px !important;
  min-height: 26px !important;
  height: 26px !important;
  padding: 2px 6px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  text-align: center;
  border-radius: 7px !important;
  border: 1px solid var(--line) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
}

.mac-ai-new-btn {
  min-height: 26px !important;
  height: 26px !important;
  padding: 0 8px !important;
  font-size: 11px !important;
  border-radius: 7px !important;
  border: 1px solid var(--line) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
}

/* Conversation Body — Prevent Flex Child Shrinking! */
.mac-ai-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mac-ai-body > * {
  flex: 0 0 auto;
}

.mac-ai-welcome {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg,
    color-mix(in srgb, #6366f1 8%, var(--panel2)),
    color-mix(in srgb, #ec4899 6%, var(--panel2)));
  display: grid;
  gap: 7px;
}

.mac-ai-welcome strong {
  font-size: 13px;
  color: var(--text);
}

.mac-ai-welcome p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.mac-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mac-ai-chips button {
  min-height: 28px !important;
  padding: 5px 10px !important;
  font-size: 11.5px !important;
  border-radius: 999px !important;
  border: 1px solid var(--line) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
  text-align: left;
  line-height: 1.3;
}

.mac-ai-chips button:hover {
  border-color: #6366f1 !important;
  background: color-mix(in srgb, #6366f1 10%, var(--panel)) !important;
}

.mac-ai-msg {
  max-width: 94%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.55;
  word-break: break-word;
}

.mac-ai-msg.is-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4f46e5, #0891b2);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.mac-ai-msg.is-bot {
  align-self: flex-start;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.mac-ai-msg.is-bot h4 {
  margin: 7px 0 3px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
}

.mac-ai-msg.is-bot p {
  margin: 4px 0;
  white-space: pre-line;
}

.mac-ai-msg-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

/* Animated Thinking Bubble (...) */
.mac-ai-thinking {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid color-mix(in srgb, #6366f1 35%, var(--line));
  background: linear-gradient(135deg,
    color-mix(in srgb, #6366f1 10%, var(--panel2)),
    color-mix(in srgb, #06b6d4 8%, var(--panel2)));
  font-size: 12px;
  color: var(--text);
}

.mac-thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.mac-thinking-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: block;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  animation: mac-dot-bounce 1.2s ease-in-out infinite;
}

.mac-thinking-dots i:nth-child(2) { animation-delay: 0.16s; background: linear-gradient(135deg, #06b6d4, #6366f1); }
.mac-thinking-dots i:nth-child(3) { animation-delay: 0.32s; background: linear-gradient(135deg, #10b981, #06b6d4); }

.mac-thinking-label {
  display: grid;
  gap: 1px;
}

.mac-thinking-label strong {
  font-size: 12px;
  font-weight: 650;
}

.mac-thinking-label small {
  font-size: 11px;
  color: var(--muted);
}

.mac-ai-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.mac-ai-sources a {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mac-ai-gate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, #f59e0b 38%, var(--line));
  background: rgba(245, 158, 11, 0.10);
  font-size: 12px;
  color: var(--text);
}

.mac-ai-gate button {
  flex: none;
  min-height: 28px !important;
  padding: 4px 10px !important;
  font-size: 11.5px !important;
  border-radius: 7px !important;
  background: var(--accent) !important;
  color: var(--accent-ink) !important;
  border: 0 !important;
}

/* Composer Footer — Never Shrunk or Clipped */
.mac-ai-foot {
  flex: none;
  padding: 10px 12px;
  border-top: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--panel2) 72%, transparent);
  display: grid;
  gap: 6px;
}

.mac-ai-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.mac-ai-form textarea {
  flex: 1 1 auto;
  min-height: 38px !important;
  max-height: 84px;
  padding: 9px 12px !important;
  border-radius: 12px !important;
  border: 1px solid var(--line) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
  font-size: 12.5px !important;
  line-height: 1.45;
  overflow-y: auto;
  resize: none;
}

.mac-ai-send {
  flex: none;
  width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 0 !important;
  background: linear-gradient(135deg, #6366f1, #ec4899) !important;
  color: #ffffff !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  display: grid !important;
  place-items: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.34) !important;
}

.mac-ai-disclaimer {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

/* Animations */
@keyframes mac-orb-spin {
  to { transform: rotate(360deg); }
}

@keyframes mac-orb-morph {
  0%   { transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { transform: translate(2px, -2px) scale(1.12) rotate(24deg); }
}

@keyframes mac-spark-breathe {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.96; }
  50%      { transform: scale(1.14) rotate(8deg); opacity: 1; }
}

@keyframes mac-sheet-in {
  from { opacity: 0; transform: translateY(14px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mac-glow-rotate {
  to { --mac-glow-angle: 360deg; }
}

@keyframes mac-dot-bounce {
  0%, 80%, 100% { transform: translateY(0) scale(0.82); opacity: 0.48; }
  40%           { transform: translateY(-5px) scale(1.12); opacity: 1; }
}

@property --mac-glow-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

body.x10-motion-off .mac-ai-orb-ring,
body.x10-motion-off .mac-orb-wave-1,
body.x10-motion-off .mac-orb-wave-2,
body.x10-motion-off .mac-orb-spark,
body.x10-motion-off .mac-thinking-dots i,
body.x10-motion-off #x10-mac-ai-panel {
  animation: none !important;
}

@media (max-width: 760px) {
  #x10-mac-ai-fab {
    right: 14px;
    bottom: 14px;
    width: 52px !important;
    height: 52px !important;
    min-height: 52px !important;
  }
  .mac-ai-orb-svg {
    width: 52px;
    height: 52px;
  }
  #x10-mac-ai-fab .mac-ai-pill {
    display: none !important;
  }
  #x10-mac-ai-panel {
    right: 10px !important;
    left: 10px !important;
    width: auto !important;
    bottom: 76px !important;
    height: min(500px, calc(100dvh - 96px)) !important;
    max-height: calc(100dvh - 92px) !important;
  }
  .mac-ai-title {
    display: none;
  }
}
