/* ============================================================
   QA-Autobot Studio — Pro UI Shell (Dark, Glass, Responsive)
   Goal: calm, centered, ChatGPT-like, premium feel
   ============================================================ */

:root{
  --bg0: #050611;
  --bg1: #070a1f;
  --ink: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.68);
  --muted2: rgba(255,255,255,.52);

  --glass: rgba(255,255,255,.06);
  --glass2: rgba(255,255,255,.09);
  --stroke: rgba(255,255,255,.10);
  --stroke2: rgba(255,255,255,.14);

  --shadow: 0 18px 70px rgba(0,0,0,.55);
  --shadow2: 0 10px 28px rgba(0,0,0,.35);

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;

  --panelW: 420px;
  --railW: clamp(320px, 32vw, 520px);
  --panelMax: 520px;
  --gap: 18px;

  --accent: rgba(160, 180, 255, .95);

  --userBubble: rgba(255,255,255,.14);
  --botBubble: rgba(255,255,255,.06);
}

/* ---------- Base ---------- */
*{ box-sizing: border-box; }
html, body { height: 100%; }

body{
  margin: 0;
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  background:
    radial-gradient(1200px 700px at 15% 85%, rgba(50,110,255,.22), transparent 60%),
    radial-gradient(900px 600px at 75% 20%, rgba(190,60,255,.18), transparent 62%),
    radial-gradient(1100px 800px at 65% 85%, rgba(40,200,255,.12), transparent 62%),
    linear-gradient(180deg, var(--bg0), var(--bg1));

  overflow: hidden;
}

.qa-bg{
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 700px at 10% 20%, rgba(255,255,255,.06), transparent 60%),
    radial-gradient(800px 600px at 85% 80%, rgba(255,255,255,.04), transparent 62%);
}

/* ---------- Shell Layout (CENTERED) ---------- */
.qa-shell{
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.qa-stage{
  width: min(1200px, 100%);
  height: min(820px, calc(100vh - 44px));
  display: grid;
  grid-template-columns: minmax(320px, var(--panelW)) 1fr;
  gap: var(--gap);
  align-items: stretch;
}

/* Assistant panel */
.assistant-panel{
  display: flex;
  flex-direction: column;

  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  backdrop-filter: blur(12px);
}

/* Right workspace */
.qa-layout{
  position: relative;
  min-width: 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
}
/* Reserve space for the docked panels rail (no overlap) */
.qa-layout.has-panels{
  padding-right: calc(var(--railW) + var(--gap) + 18px);
}


.workspace-placeholder{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(0,0,0,.10));
  box-shadow: var(--shadow);
}

.workspace-placeholder-inner{
  width: min(520px, 86%);
  padding: 22px;
  border-radius: 18px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
}

.workspace-placeholder-inner h2{
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: .2px;
}

.workspace-placeholder-inner p{
  margin: 0 0 14px;
  color: rgba(255,255,255,.78);
}

.workspace-hints{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.workspace-hints .hint{
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  color: rgba(255,255,255,.80);
  font-size: 12px;
}

.qa-layout.hidden{ display:none; }

/* ---------- Header ---------- */
.assistant-header{
  padding: 14px 16px;
  border-bottom: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.assistant-brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.assistant-icon{
  width: 34px;
  height: 34px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--stroke);
  border-radius: 12px;
}

.assistant-titles h3{
  margin: 0;
  font-size: 14px;
  letter-spacing: .2px;
}

.assistant-subtitle{
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.assistant-header-right{
  display:flex;
  align-items:center;
  gap:10px;
}

.assistant-mode{
  padding: 7px 10px;
  font-size: 12px;
  color: rgba(255,255,255,.78);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Connection badge ---------- */
.conn-badge{
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.10);
  display:flex;
  align-items:center;
  gap:8px;
  opacity: 0.95;
}

.conn-badge .dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(120,255,170,0.95);
  box-shadow: 0 0 0 3px rgba(120,255,170,0.12);
}

.conn-badge.offline .dot{
  background: rgba(255,120,140,0.95);
  box-shadow: 0 0 0 3px rgba(255,120,140,0.12);
}

.conn-badge.offline .label{
  opacity: 0.85;
}

/* ---------- Messages ---------- */
.assistant-messages{
  flex: 1;
  padding: 14px 14px 10px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.assistant-messages::-webkit-scrollbar{ width: 10px; }
.assistant-messages::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.10);
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,.2);
}

/* ✅ Message rows that match app.js (msg-row / msg-bubble) */
.msg-row{
  display: flex;
  width: 100%;
}

.msg-row.user{ justify-content: flex-end; }
.msg-row.bot{ justify-content: flex-start; }

.msg-bubble{
  max-width: 92%;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 22px rgba(0,0,0,.20);

  overflow-wrap: anywhere;   /* long strings never break layout */
  word-break: break-word;
}

.msg-row.user .msg-bubble{
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.10));
  border-color: rgba(255,255,255,.16);
}

.msg-row.bot .msg-bubble{
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.05));
}

.msg-meta{
  font-size: 11px;
  color: rgba(255,255,255,.55);
  margin-bottom: 6px;
}

.msg-body{
  color: rgba(255,255,255,.88);
}

/* Artifacts inside bot bubble */
.qa-artifact{ margin: 0; }
.qa-artifact h3{
  margin: 0 0 8px;
  font-size: 13.5px;
  letter-spacing: .2px;
  color: rgba(255,255,255,.92);
}
.qa-artifact p{
  margin: 0 0 8px;
  color: rgba(255,255,255,.84);
}
.qa-artifact ul{
  margin: 6px 0 8px 18px;
  padding: 0;
  color: rgba(255,255,255,.82);
}
.qa-artifact li{ margin: 4px 0; }

/* ---------- Actions ---------- */
.assistant-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.assistant-action-btn{
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--stroke);
  color: rgba(255,255,255,.88);
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.assistant-action-btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.18);
}

/* ---------- Footer / Input ---------- */
.assistant-footer{
  padding: 12px;
  border-top: 1px solid var(--stroke);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(0,0,0,.12);
}

.assistant-input{
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 14px;
  outline: none;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.10);
}

.assistant-input::placeholder{ color: rgba(255,255,255,.45); }

.assistant-input:focus{
  border-color: rgba(160,180,255,.35);
  box-shadow: 0 0 0 3px rgba(160,180,255,.10);
}

.assistant-send-btn{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.92);
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.assistant-send-btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.10);
}

/* ---------- Thinking / Processing ---------- */
.assistant-thinking{
  font-size: 0.8rem;
  opacity: 0.75;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  align-self: center;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--stroke);
}

.assistant-thinking::after{
  content: " .";
  animation: dots 1.4s steps(3, end) infinite;
}

@keyframes dots {
  0%   { content: " ."; }
  33%  { content: " .."; }
  66%  { content: " ..."; }
  100% { content: " ."; }
}

/* ---------- Blocked state ---------- */
.assistant-input:disabled{
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none !important;
}
.assistant-send-btn:disabled{
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Dim while thinking */
.assistant-messages:has(.assistant-thinking){ opacity: 0.95; }

/* ---------- Views ---------- */
.card{
  background: rgba(255,255,255,.04);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hidden{ display:none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 980px){
  body{ overflow: auto; }
  .qa-shell{ height: auto; min-height: 100vh; }
  .qa-stage{
    height: auto;
    min-height: calc(100vh - 44px);
    grid-template-columns: 1fr;
  }
  /* keep workspace visible on mobile */
}


/* ---------- Toast ---------- */
.ui-toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.90);
  font-size: 12px;
  letter-spacing: .2px;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
  z-index: 9999;
}

/* ---------- Workspace panel ---------- */
.ws-shell{ padding: 18px; }
.ws-header{
  display:flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.ws-title{
  margin: 0;
  font-size: 15px;
  letter-spacing: .2px;
}
.ws-meta{
  font-size: 11px;
  color: rgba(255,255,255,.55);
  white-space: nowrap;
}
.ws-body .qa-artifact{ margin-bottom: 10px; }

/* ============================================================
   Onboarding Accessory Bar (chips)
   Used by frontend/modeEngine.js (v0.3.0)
   ============================================================ */

.assistant-accessory{
  padding: 10px 12px 12px;
  border-top: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.10));
}

.accessory-shell{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.accessory-title{
  font-size: 12px;
  color: rgba(255,255,255,.70);
  letter-spacing: .2px;
}

.accessory-row{
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
}

.accessory-label{
  font-size: 12px;
  color: rgba(255,255,255,.62);
}

.accessory-chips{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Inline inputs used inside the onboarding/project panel (compact) */
.qa-inline-input{
  width: 100%;
  max-width: 520px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: inherit;
  outline: none;
  font-size: 12px;
  line-height: 1.2;
}

.qa-inline-input::placeholder{
  color: rgba(255,255,255,.45);
}

.qa-inline-input:focus{
  border-color: rgba(255,255,255,.28);
  box-shadow: 0 0 0 3px rgba(160,180,255,.10);
}

.qa-chip{
  appearance: none;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.86);
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  transition: transform .12s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
}

.qa-chip:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.22);
}

.qa-chip:active{
  transform: translateY(0px);
}

.qa-chip.active{
  background: rgba(160, 180, 255, .18);
  border-color: rgba(160, 180, 255, .40);
  box-shadow: 0 0 0 3px rgba(160,180,255,.10);
}

.qa-chip.secondary{
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.12);
  color: rgba(255,255,255,.78);
}

.qa-chip.secondary:hover{
  background: rgba(255,255,255,.08);
}

.qa-chip:disabled{
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.accessory-actions{
  grid-template-columns: 1fr;
}

.accessory-actions .qa-chip{
  justify-self: start;
}

.accessory-preview{
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: start;
  padding-top: 4px;
}

.accessory-preview-label{
  font-size: 12px;
  color: rgba(255,255,255,.55);
}

.accessory-preview-text{
  font-size: 12px;
  color: rgba(255,255,255,.82);
}

.accessory-preview-text code{
  display: inline-block;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.10);
  color: rgba(255,255,255,.88);
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Mobile: keep it compact */
@media (max-width: 980px){
  .assistant-accessory{
    padding: 10px 12px;
  }
  .accessory-row,
  .accessory-preview{
    grid-template-columns: 1fr;
  }
  .accessory-label,
  .accessory-preview-label{
    opacity: 0.85;
  }
}

/* QA-Autobot Right Panels */
.qa-panels{
  /* Dock inside workspace so it never drifts at zoom */
  position: absolute;
  top: 18px;
  right: 18px;

  width: var(--railW);
  max-width: var(--panelMax);
  max-height: calc(100% - 36px);

  background: rgba(10,12,30,.62);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);

  overflow: hidden;
  z-index: 20;
}

.qa-panels__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.qa-tabs {
  display: flex;
  gap: 8px;
}

.qa-tab {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.88);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
}

.qa-tab[aria-selected="true"] {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.18);
}

.qa-panels__tools {
  display: flex;
  gap: 8px;
}

.qa-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.90);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
}

.qa-btn:hover { background: rgba(0,0,0,0.28); }

.qa-panels__body {
  height: calc(100% - 54px);
  overflow: auto;
  padding: 12px;
}

.qa-panel-card {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 12px;
}

.qa-panel-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px 0;
  color: rgba(255,255,255,0.92);
}

.qa-kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.82);
  margin-bottom: 10px;
}

.qa-code {
  white-space: pre-wrap;
  max-height: 48vh;
  overflow: auto;
  font-size: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.88);
}

.qa-muted2 { color: rgba(255,255,255,0.62); font-size: 12px; }

@media (max-width: 1100px) {
  .qa-panels { width: calc(100vw - 24px); left: 12px; right: 12px; }
}

/* Auth overlay */
.qa-auth-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.55);
  display:flex; align-items:center; justify-content:center;
  z-index:9999;
}
.qa-auth-card{
  width:min(420px, 92vw);
  background:#0f1115;
  border:1px solid rgba(255,255,255,.08);
  border-radius:16px;
  padding:18px;
  box-shadow:0 10px 30px rgba(0,0,0,.45);
}
.qa-auth-title{ font-size:20px; font-weight:700; margin-bottom:6px; }
.qa-auth-subtitle{ opacity:.8; font-size:13px; margin-bottom:12px; }
.qa-auth-modes{ display:flex; gap:8px; margin-bottom:12px; }
.qa-auth-mode{
  flex:1; padding:10px 12px; border-radius:10px;
  border:1px solid rgba(255,255,255,.10);
  background:transparent; color:inherit; cursor:pointer;
}
.qa-auth-mode.active{ background:rgba(255,255,255,.08); }
.qa-auth-form{ display:flex; flex-direction:column; gap:10px; }
.qa-auth-input{
  padding:10px 12px; border-radius:10px;
  border:1px solid rgba(255,255,255,.10);
  background:#0b0d11; color:inherit;
}
.qa-auth-submit{
  padding:10px 12px; border-radius:10px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.10);
  cursor:pointer;
}
.qa-auth-error{ color:#ff8a8a; font-size:12px; }
.hidden{ display:none !important; }
