/* SteppinAI Public Assistant — widget styles (Phase 8 polish pass) */

:root {
  --psai-blue:       #2563eb;
  --psai-blue-2:     #1d4ed8;
  --psai-indigo:     #4f46e5;
  --psai-indigo-2:   #4338ca;
  --psai-accent:     #FFD24A;
  --psai-accent-2:   #FFB330;
  --psai-bg:         #ffffff;
  --psai-bg-2:       #f5f7fb;
  --psai-bg-3:       #eef2ff;
  --psai-text:       #0f172a;
  --psai-text-2:     #6b7280;
  --psai-border:     #e5e7eb;
  --psai-border-2:   #c7d2fe;
  --psai-glow:       0 0 0 6px rgba(37, 99, 235, .14);
  --psai-glow-gold:  0 0 0 6px rgba(255, 210, 74, .26);
  --psai-grad:       linear-gradient(135deg, var(--psai-blue) 0%, var(--psai-indigo) 100%);
  --psai-grad-gold:  linear-gradient(135deg, var(--psai-accent) 0%, var(--psai-accent-2) 100%);
  --psai-radius:     14px;
  --psai-radius-lg:  18px;
}

/* ───────────────── FAB ───────────────── */

.psai-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  width: auto;
  min-width: 56px;
  height: 62px;
  border-radius: 999px;
  padding: 0 22px 0 20px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--psai-grad);
  border: none;
  cursor: pointer;
  box-shadow:
    0 8px 28px rgba(37, 99, 235, .34),
    inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  color: #fff;
  font: 700 14px/1.1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  isolation: isolate;
}
.psai-fab::before {
  /* breathing halo */
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  background: var(--psai-grad);
  filter: blur(14px);
  opacity: .55;
  z-index: -1;
  animation: psai-pulse 2.8s ease-in-out infinite;
}
.psai-fab::after {
  /* gold accent dot near top-right of pill, like a brand stamp */
  content: "";
  position: absolute;
  top: 9px;
  right: 14px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--psai-grad-gold);
  box-shadow: 0 0 10px rgba(255, 210, 74, .9);
  animation: psai-spark 2.4s ease-in-out infinite;
}
.psai-fab:hover {
  transform: translateY(-2px);
  box-shadow:
    0 14px 36px rgba(37, 99, 235, .46),
    inset 0 1px 0 rgba(255, 255, 255, .3);
  filter: brightness(1.06);
}
.psai-fab:focus-visible {
  outline: none;
  box-shadow: 0 8px 28px rgba(37, 99, 235, .34), var(--psai-glow-gold);
}

@keyframes psai-pulse {
  0%, 100% { opacity: .45; transform: scale(1); }
  50%      { opacity: .75; transform: scale(1.04); }
}
@keyframes psai-spark {
  0%, 100% { opacity: .85; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.35); }
}

.psai-fab-label {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  letter-spacing: -.005em;
  text-align: left;
  white-space: nowrap;
}
.psai-fab-label small {
  display: block;
  font: 600 10.5px/1.1 inherit;
  color: rgba(255, 255, 255, .9);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.psai-accent { color: var(--psai-accent); }

@media (max-width: 640px) {
  .psai-fab {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
  }
  .psai-fab::after { top: 6px; right: 6px; }
  .psai-fab-label small { display: none; }
  .psai-fab-label { font-size: 0; }
  .psai-fab::before { inset: -3px; }
  .psai-fab .psai-fab-icon {
    width: 24px;
    height: 24px;
    display: inline-block;
  }
}

/* ───────────────── Panel ───────────────── */

.psai-panel {
  position: fixed;
  right: 22px;
  bottom: 100px;
  z-index: 10000;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 130px);
  background: var(--psai-bg);
  border: 1px solid var(--psai-border);
  border-radius: var(--psai-radius-lg);
  box-shadow:
    0 24px 64px rgba(15, 23, 42, .24),
    0 4px 20px rgba(37, 99, 235, .12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--psai-text);
  transform-origin: bottom right;
  animation: psai-pop-in .26s cubic-bezier(.22,1.06,.36,1) both;
}
@keyframes psai-pop-in {
  0%   { opacity: 0; transform: translateY(12px) scale(.96); }
  100% { opacity: 1; transform: translateY(0)    scale(1);   }
}

.psai-hidden { display: none !important; }

.psai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--psai-grad);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.psai-header::after {
  /* subtle gold glint across header */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 60% at 100% 0%, rgba(255, 210, 74, .18), transparent 60%);
  pointer-events: none;
}
.psai-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.psai-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .28);
  display: inline-grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 4px 14px rgba(0, 0, 0, .14);
}
.psai-brand-mark svg { width: 18px; height: 18px; }
.psai-title-wrap { display: inline-flex; flex-direction: column; line-height: 1.05; }
.psai-title { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.psai-subtitle {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .8);
  margin-top: 2px;
}
.psai-clear {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  margin-right: 6px;
  transition: background .15s ease;
}
.psai-clear:hover { background: rgba(255, 255, 255, .18); }
.psai-close {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  transition: background .15s ease, transform .15s ease;
}
.psai-close:hover { background: rgba(255, 255, 255, .18); transform: rotate(90deg); }

/* ───────────────── Messages ───────────────── */

.psai-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 6px 14px;
  background:
    radial-gradient(140% 80% at 100% 0%, rgba(79, 70, 229, .05), transparent 60%),
    linear-gradient(180deg, var(--psai-bg-2) 0%, #fbfcff 100%);
}
.psai-messages::-webkit-scrollbar { width: 8px; }
.psai-messages::-webkit-scrollbar-track { background: transparent; }
.psai-messages::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, .22);
  border-radius: 8px;
}
.psai-messages::-webkit-scrollbar-thumb:hover { background: rgba(37, 99, 235, .4); }

.psai-msg {
  margin: 0 0 12px 0;
  padding: 11px 13px;
  border-radius: var(--psai-radius);
  max-width: 86%;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.5;
  animation: psai-fade-in .25s ease both;
  position: relative;
}
@keyframes psai-fade-in {
  0%   { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0);   }
}

.psai-msg.assistant {
  background: #ffffff;
  border: 1px solid var(--psai-border);
  border-bottom-left-radius: 6px;
  color: var(--psai-text);
  margin-left: 38px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.psai-msg.assistant::before {
  /* avatar — blue gradient disc with gold spark inside */
  content: "";
  position: absolute;
  left: -38px;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--psai-grad);
  box-shadow:
    0 0 0 2px rgba(255, 210, 74, .35),
    0 4px 10px rgba(37, 99, 235, .35);
}
.psai-msg.assistant::after {
  content: "";
  position: absolute;
  left: -28px;
  top: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--psai-accent) 0%, var(--psai-accent-2) 60%, transparent 75%);
  filter: drop-shadow(0 0 4px rgba(255, 210, 74, .9));
  pointer-events: none;
}
.psai-msg.assistant.streaming::after {
  animation: psai-spark 1.6s ease-in-out infinite;
}

.psai-msg.user {
  background: var(--psai-grad);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .22);
}
.psai-msg.error {
  background: #fff4f4;
  border: 1px solid #fca5a5;
  color: #991b1b;
}
.psai-msg.error::before, .psai-msg.error::after { display: none; }

/* CTA card (partner lane) */
.psai-msg.psai-cta {
  background: linear-gradient(135deg, #fffbe6 0%, #fff5cc 100%);
  border: 1px solid var(--psai-accent);
  color: var(--psai-text);
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 6px 18px rgba(255, 210, 74, .25);
}
.psai-msg.psai-cta:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(255, 210, 74, .35); }

/* Typing dots — same avatar as assistant */
.psai-typing {
  display: inline-block;
  padding: 10px 14px;
  border-radius: var(--psai-radius);
  background: #fff;
  border: 1px solid var(--psai-border);
  margin-left: 38px;
  position: relative;
  animation: psai-fade-in .25s ease both;
}
.psai-typing::before {
  content: "";
  position: absolute;
  left: -38px;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--psai-grad);
  box-shadow: 0 0 0 2px rgba(255, 210, 74, .35), 0 4px 10px rgba(37, 99, 235, .35);
}
.psai-typing::after {
  content: "";
  position: absolute;
  left: -28px;
  top: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--psai-accent) 0%, var(--psai-accent-2) 60%, transparent 75%);
  filter: drop-shadow(0 0 4px rgba(255, 210, 74, .9));
  animation: psai-spark 1.6s ease-in-out infinite;
}
.psai-typing .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--psai-blue);
  margin-right: 4px;
  opacity: .35;
  animation: psai-bounce 1.2s infinite ease-in-out;
}
.psai-typing .dot:nth-child(2) { animation-delay: .15s; }
.psai-typing .dot:nth-child(3) { animation-delay: .3s; margin-right: 0; }
@keyframes psai-bounce {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40%          { opacity: 1;   transform: translateY(-4px); }
}

/* ───────────────── Gate form ───────────────── */

.psai-gate {
  padding: 14px;
  background: linear-gradient(180deg, #fbfcff 0%, #f1f5ff 100%);
  border-top: 1px solid var(--psai-border-2);
  position: relative;
}
.psai-gate::before {
  /* gold accent bar at top */
  content: "";
  position: absolute;
  top: -1px;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--psai-grad-gold);
  border-radius: 0 0 4px 4px;
}
.psai-gate-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.psai-gate input {
  flex: 1 1 0;
  padding: 10px 12px;
  border: 1px solid var(--psai-border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--psai-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.psai-gate input:focus {
  outline: none;
  border-color: var(--psai-accent);
  box-shadow: 0 0 0 3px rgba(255, 210, 74, .25);
}
.psai-gate button {
  width: 100%;
  padding: 11px;
  background: var(--psai-grad);
  color: #fff;
  border: none;
  border-radius: 10px;
  font: 600 14px/1 inherit;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .25);
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
}
.psai-gate button:hover {
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .35);
}
.psai-gate-err {
  margin-top: 8px;
  color: #b91c1c;
  font-size: 13px;
}

/* ───────────────── Input ───────────────── */

.psai-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--psai-border);
}
.psai-input-wrap textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 13px;
  border: 1px solid var(--psai-border);
  border-radius: 12px;
  font: inherit;
  color: var(--psai-text);
  background: var(--psai-bg-2);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.psai-input-wrap textarea:focus {
  outline: none;
  border-color: var(--psai-blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.psai-input-wrap textarea::placeholder { color: var(--psai-text-2); }
.psai-input-wrap button {
  padding: 0 18px;
  background: var(--psai-grad);
  color: #fff;
  border: none;
  border-radius: 12px;
  font: 600 14px/1 inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
  transition: transform .15s ease, filter .15s ease;
}
.psai-input-wrap button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.psai-input-wrap button:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }

.psai-footer {
  padding: 9px 14px;
  font-size: 11px;
  color: var(--psai-text-2);
  background: linear-gradient(180deg, var(--psai-bg-2) 0%, #eef2ff 100%);
  border-top: 1px solid var(--psai-border);
  text-align: center;
}

@media (max-width: 640px) {
  .psai-panel {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
    border-radius: 16px;
  }
}
