/* Sugimoto Assistant (Sarah) — front-end widget */
#sga-root, #sga-root * { box-sizing: border-box; }
#sga-root {
  --navy: #2a3642;
  --terra: #c1613a;
  --terra-d: #a94f2c;
  --bg: #ffffff;
  --line: #e7e2dc;
  --muted: #6b7280;
  --user: #2a3642;
  position: fixed;
  z-index: 2147483000;
  bottom: 20px;
  inset-inline-end: 20px;
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Launcher bubble */
#sga-launch {
  display: flex; align-items: center; gap: 10px;
  background: var(--navy); color: #fff; border: none; cursor: pointer;
  padding: 10px 16px 10px 10px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
  font-size: 15px; font-weight: 600;
}
#sga-root[dir="rtl"] #sga-launch { padding: 10px 10px 10px 16px; }
#sga-launch img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #fff; }
#sga-launch:hover { background: #222c36; }

/* Panel */
#sga-panel {
  display: none; flex-direction: column;
  width: 380px; max-width: calc(100vw - 32px);
  height: 620px; max-height: calc(100vh - 40px);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
#sga-root.open #sga-panel { display: flex; }
#sga-root.open #sga-launch { display: none; }

/* Header */
#sga-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--navy); color: #fff;
}
#sga-head img.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: #fff; }
#sga-head .meta { flex: 1; min-width: 0; }
#sga-head .meta .name { font-weight: 700; font-size: 16px; }
#sga-head .meta .sub { font-size: 12px; opacity: .8; }
#sga-head .tools { display: flex; align-items: center; gap: 6px; }
#sga-head button {
  background: rgba(255,255,255,.12); color: #fff; border: none; cursor: pointer;
  border-radius: 8px; font-size: 12px; font-weight: 600; padding: 6px 8px;
}
#sga-head button:hover { background: rgba(255,255,255,.22); }

/* Body */
#sga-body { flex: 1; overflow-y: auto; padding: 16px; background: #faf8f5; }
.sga-msg { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.sga-msg.user { flex-direction: row-reverse; }
.sga-msg img.a { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: #fff; }
.sga-bubble {
  max-width: 78%; padding: 10px 13px; border-radius: 14px; font-size: 14.5px; line-height: 1.6;
  background: #fff; border: 1px solid var(--line); color: #1f2937; white-space: pre-wrap;
}
.sga-msg.user .sga-bubble { background: var(--user); color: #fff; border-color: var(--user); }

/* Typing */
.sga-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.sga-typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa2ad; animation: sga-b 1.2s infinite; }
.sga-typing span:nth-child(2) { animation-delay: .2s; }
.sga-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes sga-b { 0%,60%,100% { transform: translateY(0); opacity:.5 } 30% { transform: translateY(-5px); opacity:1 } }

/* Options / pages / chips */
.sga-actions { margin: 4px 0 12px; display: flex; flex-direction: column; gap: 8px; }
.sga-cta {
  display: block; text-align: start; text-decoration: none; cursor: pointer;
  background: var(--terra); color: #fff; border: none; border-radius: 12px;
  padding: 12px 14px; font-size: 14px; font-weight: 700; line-height: 1.4;
}
.sga-cta:hover { background: var(--terra-d); }
.sga-cta.ghost { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.sga-cta.ghost:hover { background: #f2f4f6; }
.sga-pages { margin: 2px 0 12px; }
.sga-pages .lbl { font-size: 12px; color: var(--muted); margin: 0 2px 6px; font-weight: 600; }
.sga-page {
  display: block; text-decoration: none; color: var(--navy);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 6px; font-size: 13.5px; font-weight: 600;
}
.sga-page:hover { border-color: var(--terra); }
.sga-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sga-chip {
  cursor: pointer; background: #fff; border: 1px solid var(--line);
  color: var(--navy); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
}
.sga-chip:hover { border-color: var(--terra); color: var(--terra); }

/* Footer input */
#sga-foot { border-top: 1px solid var(--line); background: #fff; padding: 10px; }
#sga-inrow { display: flex; gap: 8px; }
#sga-in {
  flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
  font-size: 14.5px; font-family: inherit; resize: none; max-height: 96px; outline: none;
}
#sga-in:focus { border-color: var(--navy); }
#sga-send {
  border: none; cursor: pointer; background: var(--navy); color: #fff;
  border-radius: 12px; padding: 0 16px; font-size: 14px; font-weight: 700;
}
#sga-send:hover { background: #222c36; }
#sga-send:disabled { opacity: .5; cursor: default; }
#sga-note { text-align: center; font-size: 11px; color: var(--muted); margin-top: 7px; }

/* Gate + lead views share body area */
.sga-view { padding: 20px; }
.sga-view h3 { margin: 0 0 10px; color: var(--navy); font-size: 17px; }
.sga-view p { font-size: 13.5px; line-height: 1.7; color: #374151; margin: 0 0 14px; }
.sga-view a { color: var(--terra); }
.sga-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: #374151; margin-bottom: 14px; }
.sga-check input { margin-top: 3px; }
.sga-field { margin-bottom: 12px; }
.sga-field label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 0 2px 5px; }
.sga-field input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-family: inherit; outline: none;
}
.sga-field input:focus { border-color: var(--navy); }
.sga-primary {
  width: 100%; border: none; cursor: pointer; background: var(--terra); color: #fff;
  border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 700;
}
.sga-primary:hover { background: var(--terra-d); }
.sga-primary:disabled { opacity: .5; cursor: default; }
.sga-link { background: none; border: none; color: var(--navy); cursor: pointer; font-size: 13px; font-weight: 600; padding: 8px 0; font-family: inherit; }

@media (max-width: 460px) {
  #sga-panel { width: calc(100vw - 24px); height: calc(100vh - 90px); }
  #sga-root { bottom: 12px; inset-inline-end: 12px; }
}
