/* ============================================================
   OKY — Assistant (AI chat) page (redesign)
   Pixel mapping of the approved Figma "Assistant" frame onto the
   panel_ui SPA. Reuses the dashboard redesign palette (--d-*
   tokens + Montserrat/Inter from dashboard.css / vars.css); adds
   only the screen-specific classes below, all `pg-asst-` prefixed
   so nothing here leaks into other views.

   The chat shell is a single white card: a scrollable message log
   on top and a docked input bar at the bottom. Assistant turns use
   an "OK" avatar + light bubble; user turns are right-aligned blue
   pills. The model/vendor behind the assistant is never named
   (hide-security-internals rule).
   ============================================================ */

.pg-asst { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 22px; }

/* ---- page header -------------------------------------------------- */
.pg-asst-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
}
.pg-asst-head-text { display: flex; flex-direction: column; gap: 6px; }
.pg-asst-title {
  font-family: var(--font-mont);
  font-weight: 700; font-size: 30px; line-height: 33px;
  letter-spacing: -0.025em;
  color: var(--d-ink); margin: 0;
}
.pg-asst-sub {
  font-family: var(--font-body);
  font-weight: 400; font-size: 14px; line-height: 20px;
  color: var(--d-muted); margin: 0;
}
.pg-asst-clear {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body);
  font-weight: 600; font-size: 13px; line-height: 1;
  color: var(--d-ink);
  background: var(--d-card);
  border: 1px solid var(--d-line-2);
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.pg-asst-clear:hover { background: #fafafa; border-color: #d4d4d4; }
.pg-asst-clear:disabled { opacity: .5; cursor: default; }

/* ---- chat shell card --------------------------------------------- */
.pg-asst-shell {
  display: grid; grid-template-rows: 1fr auto;
  height: calc(100vh - 250px); min-height: 420px;
  background: var(--d-card);
  border: 1px solid var(--d-line);
  border-radius: 16px;
  box-shadow: var(--d-shadow-card);
  overflow: hidden;
}

/* ---- scrollable message log -------------------------------------- */
.pg-asst-log {
  overflow-y: auto;
  padding: 22px 20px;
  display: flex; flex-direction: column; gap: 22px;
}

/* assistant turn: avatar + light bubble */
.pg-asst-row { display: flex; gap: 12px; align-items: flex-start; }
.pg-asst-avatar {
  flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--d-blue-600); color: #fff;
  font-family: var(--font-mont);
  font-weight: 700; font-size: 9px; letter-spacing: .02em;
}
.pg-asst-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 12px;
  background: #f3f4f6;
  color: var(--d-ink);
  font-family: var(--font-body);
  font-weight: 400; font-size: 13.5px; line-height: 19px;
  word-wrap: break-word; overflow-wrap: anywhere;
}

/* user turn: right-aligned blue pill */
.pg-asst-row-user { justify-content: flex-end; }
.pg-asst-bubble-user {
  max-width: 70%;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--d-blue-600);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 500; font-size: 13.5px; line-height: 19px;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}

/* empty-state greeting (rendered as a normal assistant bubble row,
   so no extra styling needed here) */

/* typing indicator */
.pg-asst-dots { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.pg-asst-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--d-faint);
  animation: pg-asst-blink 1.2s infinite;
}
.pg-asst-dots span:nth-child(2) { animation-delay: .2s; }
.pg-asst-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pg-asst-blink { 0%,80%,100% { opacity: .3 } 40% { opacity: 1 } }

/* ---- markdown rendered inside assistant bubbles ------------------- */
.pg-asst-bubble p { margin: 6px 0; }
.pg-asst-bubble p:first-child { margin-top: 0; }
.pg-asst-bubble p:last-child { margin-bottom: 0; }
.pg-asst-bubble h2,
.pg-asst-bubble h3,
.pg-asst-bubble h4 {
  font-family: var(--font-mont); color: var(--d-ink); margin: 12px 0 6px;
}
.pg-asst-bubble h2 { font-weight: 700; font-size: 17px; }
.pg-asst-bubble h3 { font-weight: 700; font-size: 15.5px; }
.pg-asst-bubble h4 { font-weight: 600; font-size: 14px; }
.pg-asst-bubble ul,
.pg-asst-bubble ol { margin: 6px 0 6px 18px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.pg-asst-bubble code {
  background: #fff; border: 1px solid var(--d-line-2); border-radius: 4px;
  padding: 1px 5px; font-family: var(--font-mono); font-size: 12.5px;
}
.pg-asst-bubble pre {
  background: #fff; border: 1px solid var(--d-line-2); border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; margin: 8px 0;
  font-family: var(--font-mono); font-size: 12.5px;
}
.pg-asst-bubble pre code { background: none; border: none; padding: 0; }
.pg-asst-bubble hr { border: none; border-top: 1px solid var(--d-line-2); margin: 10px 0; }
.pg-asst-bubble table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.pg-asst-bubble th {
  text-align: left; padding: 6px 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--d-muted); border-bottom: 1px solid var(--d-line-2);
  font-weight: 600;
}
.pg-asst-bubble td {
  padding: 6px 10px; font-size: 13px; border-bottom: 1px solid var(--d-line); vertical-align: top;
}
.pg-asst-bubble a { color: var(--d-blue); text-decoration: none; }
.pg-asst-bubble a:hover { text-decoration: underline; }

/* ---- docked input bar -------------------------------------------- */
.pg-asst-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--d-line);
}
.pg-asst-input {
  flex: 1;
  min-height: 24px; max-height: 160px;
  padding: 0;
  resize: none; border: none; outline: none; background: none;
  font-family: var(--font-body);
  font-weight: 400; font-size: 14px; line-height: 22px;
  color: var(--d-ink);
}
.pg-asst-input::placeholder { color: var(--d-faint); }
.pg-asst-bar-wrap {
  flex: 1;
  display: flex; align-items: center;
  border: 1px solid var(--d-line-2);
  border-radius: 12px;
  padding: 11px 16px;
  background: var(--d-card);
  transition: border-color .12s;
}
.pg-asst-bar-wrap:focus-within { border-color: var(--d-blue); }
.pg-asst-send {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body);
  font-weight: 600; font-size: 13px; line-height: 1;
  color: #fff;
  background: var(--d-blue-600);
  border: none; border-radius: 10px;
  padding: 0 18px; height: 36px;
  cursor: pointer;
  transition: background .12s;
}
.pg-asst-send:hover { background: #1d4ed8; }
.pg-asst-send:disabled { opacity: .55; cursor: default; }
