/* SmartFabX Assistant — colorful all-in-one studio + dock */

.sfx-ai-fab {
  position: fixed;
  right: 16px;
  top: 16px;
  bottom: auto;
  z-index: 9800;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(145deg, #4f46e5 0%, #0891b2 55%, #10b981 100%);
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sfx-ai-fab:hover { filter: brightness(1.08); transform: translateY(-1px); }
/* Sit in the title bar gap (left of user / Sign Out) so it never covers header actions */
.titlebar-desktop .sfx-ai-fab,
.sfx-ai-fab--header {
  position: relative;
  right: auto;
  top: auto;
  bottom: auto;
  z-index: 5;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.28);
  flex-shrink: 0;
  margin-left: 6px;
}
.titlebar-desktop .sfx-ai-fab svg,
.sfx-ai-fab--header svg {
  width: 14px;
  height: 14px;
}
.titlebar-desktop .sfx-ai-fab:hover,
.sfx-ai-fab--header:hover {
  transform: none;
}
body.sfx-desktop-closed .sfx-ai-fab,
body.sfx-desktop-closed .sfx-ai-dock { display: none; }

.sfx-ai-dock {
  position: fixed;
  right: 16px;
  top: 72px;
  bottom: auto;
  z-index: 9801;
  width: min(420px, calc(100vw - 24px));
  height: min(640px, calc(100vh - 88px));
  display: none;
  flex-direction: column;
  background: #f4f7ff;
  border: 1px solid #c7d2fe;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(49, 46, 129, 0.22);
  overflow: hidden;
  font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
}
.sfx-ai-dock.is-open { display: flex; }

.sfx-ai-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(120deg, #312e81, #4f46e5 42%, #0ea5e9);
  color: #fff;
}
.sfx-ai-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
}
.sfx-ai-head p {
  margin: 2px 0 0;
  font-size: 11px;
  color: rgba(255,255,255,.82);
}
.sfx-ai-head-grow { flex: 1; min-width: 0; }
.sfx-ai-mode {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  color: #fff;
  white-space: nowrap;
}
.sfxai-app .sfx-ai-mode {
  background: #e0e7ff;
  color: #3730a3;
}
.sfx-ai-iconbtn {
  border: 0;
  background: rgba(255,255,255,.16);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
}
.sfx-ai-iconbtn:hover { background: rgba(255,255,255,.28); }

.sfx-ai-toolbar {
  flex: 0 0 auto;
  background: #eef2ff;
  border-bottom: 1px solid #dbe4ff;
}
.sfx-ai-modes {
  display: flex;
  gap: 6px;
  padding: 8px 10px 0;
  background: #eef2ff;
}
.sfx-ai-modebtn {
  flex: 1;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  color: #4338ca;
}
.sfx-ai-modebtn.is-on[data-mode="all"] {
  background: linear-gradient(90deg, #4f46e5, #0891b2);
  color: #fff;
}
.sfx-ai-modebtn.is-on[data-mode="factory"] {
  background: #f59e0b;
  color: #1f2937;
}
.sfx-ai-modebtn.is-on[data-mode="encyclopedia"] {
  background: linear-gradient(90deg, #db2777, #7c3aed);
  color: #fff;
}

.sfx-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 4px;
  background: transparent;
}
.sfx-ai-toolbar .sfx-ai-optbar {
  padding: 0 10px 8px;
}
.sfx-ai-chip {
  border: 0;
  color: #1e3a5f;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.sfx-ai-chip:nth-child(1) { background: #c7d2fe; }
.sfx-ai-chip:nth-child(2) { background: #a5f3fc; }
.sfx-ai-chip:nth-child(3) { background: #fde68a; }
.sfx-ai-chip:nth-child(4) { background: #bbf7d0; }
.sfx-ai-chip:nth-child(5) { background: #fbcfe8; }
.sfx-ai-chip:nth-child(6) { background: #ddd6fe; }
.sfx-ai-chip:hover { filter: brightness(.96); }

.sfx-ai-empty {
  margin: auto;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}
.sfx-ai-log {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(1200px 280px at 10% -20%, rgba(99,102,241,.12), transparent 50%),
    radial-gradient(800px 240px at 110% 10%, rgba(14,165,233,.12), transparent 46%),
    #f8fafc;
}
.sfx-ai-msg {
  max-width: 94%;
  padding: 9px 11px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.sfx-ai-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4338ca, #2563eb);
  color: #fff;
  border: 0;
}
.sfx-ai-msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #dbe4ff;
  border-left: 4px solid #06b6d4;
  color: #1f2933;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}
.sfx-ai-msg.sys {
  align-self: center;
  background: #ede9fe;
  color: #5b21b6;
  font-size: 12px;
}
.sfx-ai-msg .sfx-ai-meta {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  opacity: .7;
}
.sfx-ai-msg .sfx-ai-h {
  font-weight: 800;
  color: #3730a3;
  margin: 6px 0 2px;
}
.sfx-ai-msg.user .sfx-ai-h { color: #e0e7ff; }
.sfx-ai-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.sfx-ai-mini {
  border: 0;
  background: rgba(15,23,42,.08);
  color: inherit;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.sfx-ai-msg.user .sfx-ai-mini { background: rgba(255,255,255,.2); color: #fff; }
.sfx-ai-editbox {
  width: 100%;
  min-height: 54px;
  border-radius: 8px;
  border: 1px solid #a5b4fc;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.sfx-ai-composer {
  flex: 0 0 auto;
  border-top: 1px solid #dbe4ff;
  background: #fff;
  padding: 8px;
}
.sfx-ai-composer-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.sfx-ai-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 110px;
  resize: vertical;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  background: #f8fafc;
}
.sfx-ai-send {
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #0891b2);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.sfx-ai-picklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.sfx-ai-pick {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #312e81;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.sfx-ai-pick:hover { background: #e0e7ff; }
.sfx-ai-pick-go {
  background: linear-gradient(135deg, #4f46e5, #0891b2);
  color: #fff;
  border: 0;
  margin-top: 8px;
}
.sfx-ai-opts label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.sfx-ai-optbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 0 0;
}
.sfx-ai-optlab {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #6366f1;
  margin-right: 4px;
}
.sfx-ai-optpill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #312e81;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.sfx-ai-optpill:has(input:checked) {
  background: linear-gradient(90deg, #4f46e5, #0891b2);
  color: #fff;
  border-color: transparent;
}
.sfx-ai-optfile input[type=file] { max-width: 118px; font-size: 10px; }
.sfx-ai-select {
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #312e81;
  background: #fff;
}

.sfxai-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    radial-gradient(900px 320px at 0% 0%, rgba(99,102,241,.18), transparent 50%),
    radial-gradient(700px 280px at 100% 0%, rgba(14,165,233,.16), transparent 48%),
    #eef2ff;
}
.sfxai-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(120deg, #312e81, #4f46e5 40%, #0ea5e9);
  color: #fff;
}
.sfxai-top .sfxai-note { color: rgba(255,255,255,.85); }
.sfxai-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  min-height: 0;
}
.sfxai-col {
  overflow: auto;
  padding: 12px;
  border-right: 1px solid #dbe4ff;
}
.sfxai-col:last-child { border-right: 0; }
.sfxai-card {
  background: #fff;
  border: 1px solid #dbe4ff;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.06);
}
.sfxai-card h4 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #4f46e5;
}
.sfxai-stat {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px dashed #e0e7ff;
}
.sfxai-stat strong { color: #0f766e; }
.sfxai-chatwrap { display: flex; flex-direction: column; min-height: 0; height: 100%; background: transparent; }
.sfxai-input {
  width: 100%;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  font-size: 13px;
}
.sfxai-btn {
  border: 0;
  border-radius: 8px;
  padding: 7px 11px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.sfxai-btn.ghost { background: #eef2ff; color: #3730a3; }
.sfxai-btn.amber { background: #f59e0b; color: #1f2937; }
.sfxai-toolgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sfxai-toolgrid button {
  text-align: left;
  border: 1px solid #c7d2fe;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-size: 12px;
  color: #1e3a8a;
}
.sfxai-toolgrid button:hover { background: #eef2ff; }
.sfxai-note { font-size: 12px; color: #4b5563; line-height: 1.45; }

@media (max-width: 980px) {
  .sfxai-grid { grid-template-columns: 1fr; }
}
