/* AFP Chat / Professional UI proposal v1
   Complete replacement for assets/chat.css; not a second theme to stack on top.
   Compatible selectors: AFP Agnes Chat 0.6.4. No requests or data processing.
   Optional chat-pro-ui.js improves the mobile visual viewport and focus handling. */
#afp-chat-root {
  --afp-bg:#fff; --afp-soft:#f5f8f6; --afp-text:#21382c;
  --afp-muted:#52685b; --afp-border:#dbe5de; --afp-input-border:#7b8d80;
  --afp-accent:#176447; --afp-accent-hover:#104f37; --afp-accent-text:#fff;
  --afp-user-bg:#eaf4ee; --afp-focus:#216bc4;
  --afp-shadow:0 4px 12px #1232220a,0 20px 56px #1232221a;
  font:400 16px/1.7 Vazir,"Noto Sans Arabic",Tahoma,system-ui,sans-serif;
  color:var(--afp-text); color-scheme:light; text-align:start;
  position:fixed; bottom:24px; left:24px; right:auto; z-index:999990;
  box-sizing:border-box; -webkit-text-size-adjust:100%;
}
#afp-chat-root *,#afp-chat-root *::before,#afp-chat-root *::after {box-sizing:border-box}
#afp-chat-root [hidden] {display:none!important}
#afp-chat-root :is(button,input,textarea) {font:inherit;letter-spacing:normal;text-transform:none;margin:0}
#afp-chat-root button {cursor:pointer;min-height:44px;touch-action:manipulation}
#afp-chat-root button:disabled {cursor:not-allowed;opacity:.58}
#afp-chat-root :is(button,a,input,textarea,summary):focus-visible {outline:3px solid var(--afp-focus);outline-offset:3px}
#afp-chat-root a {color:var(--afp-accent);text-decoration:underline;text-underline-offset:3px;overflow-wrap:anywhere}
#afp-chat-root button {transition:background-color .14s ease,border-color .14s ease}
#afp-chat-root .afp-launcher {
  display:flex;align-items:center;gap:10px;min-height:52px;padding:12px 20px;
  color:var(--afp-accent-text);background:var(--afp-accent);border:1px solid transparent;
  border-radius:12px;box-shadow:0 4px 12px #1232221a;font-weight:650;
}
#afp-chat-root .afp-launcher:hover {background:var(--afp-accent-hover)}
#afp-chat-root .afp-launcher::before {
  content:"";width:20px;height:17px;display:block;border:1.7px solid currentColor;
  border-radius:5px 5px 1px 5px;flex:none;
}
#afp-chat-root .afp-panel {
  display:flex;flex-direction:column;position:absolute;bottom:72px;left:0;right:auto;
  width:440px;max-width:calc(100vw - 48px);height:min(800px,calc(100dvh - 124px));
  max-height:calc(100dvh - 124px);min-height:0;overflow:hidden;isolation:isolate;
  border:1px solid var(--afp-border);border-radius:12px;background:var(--afp-bg);box-shadow:var(--afp-shadow);
}
#afp-chat-root .afp-header {
  display:flex;justify-content:space-between;align-items:center;gap:16px;
  flex:none;padding:18px 20px;background:var(--afp-bg);border-bottom:1px solid var(--afp-border);
}
#afp-chat-root .afp-header>div {min-width:0}
#afp-chat-root .afp-header strong {display:block;font-size:18px;font-weight:700;line-height:1.6;color:var(--afp-text)}
#afp-chat-root .afp-sub {display:block;font-size:14px;line-height:1.6;color:var(--afp-muted);margin-top:2px}
#afp-chat-root .afp-close {
  display:grid;place-items:center;flex:none;width:44px;height:44px;min-width:44px;
  padding:0;border:1px solid var(--afp-border);border-radius:8px;
  color:var(--afp-text);background:var(--afp-bg);font-size:26px;line-height:1;
}
#afp-chat-root .afp-close:hover {background:var(--afp-soft);border-color:var(--afp-input-border)}
#afp-chat-root .afp-log {
  flex:1 1 auto;min-height:100px;padding:24px 20px;overflow-y:auto;overflow-x:hidden;
  overscroll-behavior:contain;scroll-padding-block:16px;scrollbar-width:thin;
  scrollbar-color:var(--afp-input-border) transparent;
}
#afp-chat-root .afp-message {
  margin:0 0 18px;white-space:pre-wrap;overflow-wrap:anywhere;font-size:16px;
  line-height:1.85;font-weight:400;color:var(--afp-text);border:0;
}
#afp-chat-root .afp-assistant {padding:0 2px 4px;background:transparent;border-radius:0}
#afp-chat-root .afp-user {
  width:fit-content;max-width:92%;margin-inline-start:auto;margin-inline-end:0;
  padding:12px 16px;border-radius:12px 12px 4px 12px;background:var(--afp-user-bg);
}
#afp-chat-root[dir=ltr] .afp-user {border-radius:12px 12px 12px 4px}
#afp-chat-root .afp-controls {
  flex:0 0 auto;min-height:0;max-height:52%;padding:12px 20px 8px;
  background:var(--afp-bg);border-top:1px solid var(--afp-border);
  overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;
}
#afp-chat-root .afp-notice {
  margin:0 0 10px;padding:12px;background:var(--afp-soft);border:1px solid var(--afp-border);
  border-radius:8px;font-size:14px;line-height:1.65;color:var(--afp-muted);
}
#afp-chat-root .afp-consent {
  display:flex;align-items:flex-start;gap:10px;font-size:14px;line-height:1.65;
  min-height:44px;padding:8px 0;cursor:pointer;color:var(--afp-muted);
}
#afp-chat-root .afp-consent input {
  flex:none;width:18px;height:18px;min-width:18px;margin:3px 0 0;
  accent-color:var(--afp-accent);cursor:pointer;
}
#afp-chat-root .afp-form {
  display:flex;gap:8px;align-items:flex-end;margin:0;padding:6px;
  border:1px solid var(--afp-input-border);border-radius:12px;background:var(--afp-bg);
}
#afp-chat-root .afp-form:focus-within {outline:3px solid var(--afp-focus);outline-offset:2px}
#afp-chat-root textarea {
  display:block;width:100%;min-width:0;min-height:64px;resize:none;
  padding:10px 12px;border:1px solid var(--afp-input-border);border-radius:8px;
  background:var(--afp-bg)!important;color:var(--afp-text)!important;
  font-size:16px;line-height:1.65;box-shadow:none;
}
#afp-chat-root textarea::placeholder {color:var(--afp-muted)!important;opacity:1}
#afp-chat-root .afp-form textarea {
  flex:1;min-height:52px;max-height:120px;padding:6px 8px;border:0;border-radius:6px;
  background:transparent!important;outline:none;box-shadow:none;
}
#afp-chat-root .afp-send {
  flex:none;min-height:48px;padding:9px 14px;border:1px solid transparent;border-radius:8px;
  background:var(--afp-accent);color:var(--afp-accent-text);font-size:16px;font-weight:650;
}
#afp-chat-root .afp-send:hover:not(:disabled) {background:var(--afp-accent-hover)}
#afp-chat-root .afp-status {min-height:0;margin:8px 0 0;font-size:14px;line-height:1.6;color:var(--afp-muted);overflow-wrap:anywhere}
#afp-chat-root .afp-status:empty {display:none}
#afp-chat-root .afp-footer {display:flex;justify-content:space-between;align-items:center;gap:12px;font-size:14px;line-height:1.6}
#afp-chat-root .afp-footer a {display:flex;align-items:center;min-height:44px}
#afp-chat-root .afp-clear {min-height:44px;padding:8px 0;border:0;background:transparent;color:var(--afp-muted);font-size:14px;text-decoration:underline;text-underline-offset:3px}
#afp-chat-root .afp-graph {margin:18px 0 0;scroll-margin-block:12px}
#afp-chat-root .afp-graph-question {margin:0 0 16px;font-weight:700;font-size:16px;line-height:1.8;color:var(--afp-text)}
#afp-chat-root .afp-options {display:grid;gap:10px}
#afp-chat-root .afp-option {
  display:block;width:100%;min-height:48px;text-align:start;padding:12px 14px;
  border:1px solid var(--afp-input-border);border-radius:8px;background:var(--afp-bg);
  color:var(--afp-accent);font-size:16px;line-height:1.65;white-space:normal;overflow-wrap:anywhere;
}
#afp-chat-root .afp-option:hover:not(:disabled) {background:var(--afp-soft);border-color:var(--afp-input-border)}
#afp-chat-root .afp-get,
#afp-chat-root .afp-handoff .afp-handoff-copy,
#afp-chat-root .afp-response-actions>button:nth-child(3) {
  background:var(--afp-accent);color:var(--afp-accent-text);border-color:var(--afp-accent);font-weight:650;
}
#afp-chat-root .afp-get {margin:16px 0}
#afp-chat-root .afp-get:hover:not(:disabled),
#afp-chat-root .afp-handoff .afp-handoff-copy:hover:not(:disabled),
#afp-chat-root .afp-response-actions>button:nth-child(3):hover:not(:disabled) {
  background:var(--afp-accent-hover);border-color:var(--afp-accent-hover);color:var(--afp-accent-text);
}
#afp-chat-root .afp-graph-nav {display:flex;flex-wrap:wrap;gap:8px;margin-top:16px}
#afp-chat-root .afp-graph-nav .afp-option {width:auto;flex:1;min-width:120px;font-size:14px;padding:10px}
#afp-chat-root .afp-hint {font-size:14px;line-height:1.75;color:var(--afp-muted);margin:10px 0;overflow-wrap:anywhere}
#afp-chat-root .afp-summary {padding:14px 16px;border:1px solid var(--afp-border);border-radius:8px;background:var(--afp-soft);font-size:14px}
#afp-chat-root .afp-summary p {margin:10px 0;font-size:14px;line-height:1.8}
#afp-chat-root .afp-summary-row {padding:12px 0;border-bottom:1px solid var(--afp-border)}
#afp-chat-root .afp-summary-row:last-child {border-bottom:0}
#afp-chat-root .afp-summary-row p {margin:0 0 8px}
#afp-chat-root .afp-summary-row .afp-option {width:auto;font-size:14px;min-height:44px;padding:8px 12px}
#afp-chat-root .afp-sources {margin:16px 0 20px;padding:12px 16px;border:1px solid var(--afp-border);border-radius:8px;font-size:14px;background:var(--afp-soft)}
#afp-chat-root .afp-sources strong {font-size:14px;font-weight:650}
#afp-chat-root .afp-sources a {display:block;min-height:44px;padding:10px 0;line-height:1.7}
#afp-chat-root .afp-sources a+a {border-top:1px solid var(--afp-border)}
#afp-chat-root .afp-route {margin:12px 0}
#afp-chat-root .afp-selection-label {display:block;font-size:14px;font-weight:650;line-height:1.7;margin:8px 0;color:var(--afp-text)}
#afp-chat-root .afp-selection-input,
#afp-chat-root .afp-support-form input,
#afp-chat-root .afp-math-gate input {
  display:block;width:100%;min-width:0;min-height:50px;padding:11px 12px;border:1px solid var(--afp-input-border);
  border-radius:8px;background:var(--afp-bg)!important;color:var(--afp-text)!important;font:inherit;box-shadow:none;
}
#afp-chat-root .afp-selection-input[aria-invalid=true] {border-color:#b63830}
#afp-chat-root .afp-followup {display:grid;gap:10px;margin:20px 0}
#afp-chat-root .afp-followup .afp-graph-question {margin-bottom:2px}
#afp-chat-root .afp-request-actions {display:flex;gap:8px;margin:8px 0}
#afp-chat-root .afp-request-actions:not(:has(button:not([hidden]))) {display:none}
#afp-chat-root .afp-request-actions .afp-option {font-size:14px;min-height:44px;padding:8px 12px}
#afp-chat-root .afp-response-actions {display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:20px 0 8px}
#afp-chat-root .afp-response-actions>button {font-size:14px;min-height:48px;text-align:center}
#afp-chat-root .afp-response-actions>button:nth-child(3),
#afp-chat-root .afp-response-actions>.afp-support-form,
#afp-chat-root .afp-response-actions>.afp-hint {grid-column:1/-1}
#afp-chat-root .afp-handoff {margin:18px 0;padding:16px;border:1px solid var(--afp-border);border-radius:12px;background:var(--afp-soft);min-width:0}
#afp-chat-root .afp-handoff-title {margin:0 0 12px;font-family:inherit;font-weight:700;font-size:16px;line-height:1.7;color:var(--afp-text)}
#afp-chat-root .afp-handoff .afp-option {margin:10px 0}
#afp-chat-root .afp-handoff-text {min-height:184px;max-height:320px;resize:vertical;margin:12px 0;white-space:pre-wrap}
#afp-chat-root .afp-handoff-status:empty {display:none}
#afp-chat-root .afp-support-form {margin:0;padding:16px}
#afp-chat-root .afp-support-form .afp-selection-label {margin-top:16px}
#afp-chat-root .afp-support-form textarea {min-height:92px}
#afp-chat-root .afp-support-form .afp-handoff {padding:12px}
#afp-chat-root .afp-math-gate {scroll-margin-block:16px}
#afp-chat-root .afp-math-gate input {font-size:20px;direction:ltr;text-align:center;letter-spacing:2px;min-height:56px}
#afp-chat-root[dir=ltr] {right:24px;left:auto}
#afp-chat-root[dir=ltr] .afp-panel {right:0;left:auto}
/* Inline WordPress admin preview is not a page-covering dialog. */
#afp-chat-root.afp-chat-inline {position:relative;inset:auto;max-width:480px;margin:16px 0;z-index:1}
#afp-chat-root.afp-chat-inline .afp-panel {position:relative;inset:auto;width:100%;max-width:none;height:760px;max-height:none}
/* Mobile: a real reading surface, not a desktop panel squeezed into a card. */
@media(max-width:640px) {
  #afp-chat-root,#afp-chat-root[dir=ltr] {left:16px;right:auto;bottom:calc(16px + env(safe-area-inset-bottom,0px))}
  #afp-chat-root:not(.afp-chat-inline) .afp-panel {
    position:fixed;left:0;right:0;top:var(--afp-live-top,0px);bottom:auto;
    width:100%;max-width:none;height:var(--afp-live-vh,100dvh);max-height:var(--afp-live-vh,100dvh);
    border:0;border-radius:0;box-shadow:none;
  }
  #afp-chat-root:not(.afp-chat-inline):has(.afp-panel:not([hidden])) .afp-launcher {display:none}
  #afp-chat-root .afp-header {padding:calc(12px + env(safe-area-inset-top,0px)) 16px 12px;gap:12px}
  #afp-chat-root .afp-log {padding:20px 16px;min-height:100px}
  #afp-chat-root .afp-controls {padding:10px 16px calc(6px + env(safe-area-inset-bottom,0px));max-height:48%}
  #afp-chat-root .afp-user {max-width:94%}
  #afp-chat-root .afp-launcher {min-height:52px;padding:12px 16px}
  #afp-chat-root.afp-chat-inline,#afp-chat-root.afp-chat-inline[dir=ltr] {max-width:100%;inset:auto}
  #afp-chat-root.afp-chat-inline .afp-panel {position:relative;inset:auto;height:760px;max-height:none;border:1px solid var(--afp-border);border-radius:12px}
  html:has(#afp-chat-root:not(.afp-chat-inline) .afp-panel:not([hidden])) {overflow:hidden}
}
@media(max-height:520px) {
  #afp-chat-root .afp-header {padding-top:8px;padding-bottom:8px}
  #afp-chat-root .afp-controls {max-height:55%;padding-top:6px}
  #afp-chat-root .afp-log {min-height:64px;padding-top:12px;padding-bottom:12px}
  #afp-chat-root .afp-panel {height:calc(100dvh - 110px)}
}
@media(prefers-color-scheme:dark) {
  #afp-chat-root {
    --afp-bg:#18231d;--afp-soft:#202e25;--afp-text:#eef6f0;--afp-muted:#b6c9bd;
    --afp-border:#3d5245;--afp-input-border:#7f9a89;--afp-accent:#8cd4ad;
    --afp-accent-hover:#afe4c6;--afp-accent-text:#102b1c;--afp-user-bg:#263d2e;--afp-focus:#86baff;
    --afp-shadow:0 4px 12px #0002,0 20px 56px #0005;color-scheme:dark;
  }
  #afp-chat-root .afp-selection-input[aria-invalid=true] {border-color:#ff9a91}
}
@media(prefers-reduced-motion:reduce) {
  #afp-chat-root *,#afp-chat-root *::before {transition:none!important;animation:none!important;scroll-behavior:auto!important}
}

/* Presentation-only progressive disclosure: the full existing notice remains
   readable, and consent is still an explicit separate checkbox. */
#afp-chat-root .afp-privacy-details {margin:0;padding:0;border:0;border-radius:0;background:transparent;box-shadow:none}
#afp-chat-root .afp-privacy-details>summary {min-height:44px;line-height:1.7;padding:10px 0;cursor:pointer;font-size:14px;font-weight:400;color:var(--afp-muted);list-style-position:inside}
#afp-chat-root .afp-privacy-details>summary::marker {color:var(--afp-accent)}
#afp-chat-root .afp-privacy-details .afp-notice {margin:0 0 8px}
#afp-chat-root .afp-graph-question:focus,#afp-chat-root .afp-header strong:focus {outline:none}

/* Specialist handoff is a distinct LOCAL step. Keep its own privacy notice,
   fields, validation and copy actions, not the unrelated AI composer. */
#afp-chat-root.afp-local-form .afp-controls>:not(.afp-footer) {display:none}
#afp-chat-root.afp-local-form .afp-controls {padding-top:2px}
#afp-chat-root.afp-local-form .afp-log>:not(.afp-graph) {display:none}
#afp-chat-root.afp-local-form .afp-response-actions {margin-top:0}
