/* Native Chatflow editor (Members Hub Sequences tab) -- dark-glass restyle of the classes email-manager's
   wp-admin builder markup uses (.chat-form-question, .options-manager, .conditional-rules, the email-rules
   table + modal, the Display & Widget config, the Bot Agent picker). Scoped under .aipa-cf-editor so none
   of this touches the real wp-admin screen, which keeps loading its own assets/forms/admin.css. */
#aipa-am-modal-chatflow-edit .aipa-modal__panel { max-width: 1120px; height: 88vh; margin: 4vh auto; display: flex; flex-direction: column; padding: 0; overflow: hidden; width: 100%; }
#aipa-am-modal-chatflow-edit .aipa-modal__head { padding: 14px 20px; margin: 0; flex: none; border-bottom: 1px solid var(--glass-border); }
#aipa-am-modal-chatflow-edit .aipa-modal__head h2 { font-size: 1rem; }
#aipa-cf-editor-root { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
#aipa-cf-editor-root .aipa-cf-loading { padding: 48px 0; text-align: center; color: var(--muted); }
.aipa-cf-footer { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--glass-border); background: rgba(255, 255, 255, .03); }
.aipa-cf-footer #aipa-cf-status { margin-right: auto; font-size: .78rem; color: #34d399; }
.aipa-cf-footer #aipa-cf-status.is-error { color: #fca5a5; }

.aipa-cf-editor { color: var(--ink); font-size: .86rem; }
.aipa-cf-editor .aipa-cf-title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.aipa-cf-editor .aipa-cf-title-row label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); flex: none; }
.aipa-cf-editor .aipa-cf-title-row input { flex: 1; font-size: 1.05rem; font-weight: 700; }
.aipa-cf-editor .aipa-cf-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .aipa-cf-editor .aipa-cf-grid { grid-template-columns: minmax(0, 1fr); } }
.aipa-cf-editor .aipa-cf-section { border-radius: 16px; padding: 16px 18px; margin-bottom: 16px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1); }
.aipa-cf-editor .aipa-cf-section__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.aipa-cf-editor .aipa-cf-section__head h3 { margin: 0; font-size: .92rem; color: #fff; }
.aipa-cf-editor .aipa-cf-section .description, .aipa-cf-editor .aipa-cf-hint, .aipa-cf-editor small { color: var(--muted); font-size: .74rem; line-height: 1.5; }
.aipa-cf-editor .aipa-cf-subhead { margin: 0 0 6px; font-size: .78rem; }
.aipa-cf-editor .aipa-cf-hr { margin: 14px 0 10px; border: 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.aipa-cf-editor .aipa-cf-right { text-align: right; }
.aipa-cf-editor .aipa-cf-ok { color: #34d399; font-weight: 600; }
.aipa-cf-editor .aipa-cf-warn { color: #fbbf24; }
.aipa-cf-editor label { color: var(--ink); }
.aipa-cf-editor label strong { color: #fff; }
.aipa-cf-editor .widefat, .aipa-cf-editor input[type=text], .aipa-cf-editor input[type=url], .aipa-cf-editor input[type=email], .aipa-cf-editor input[type=number], .aipa-cf-editor select, .aipa-cf-editor textarea { width: 100%; box-sizing: border-box; }
.aipa-cf-editor input[type=color] { width: 100%; height: 40px; border-radius: 8px; border: 1px solid var(--glass-border); background: var(--field-bg); cursor: pointer; }
.aipa-cf-editor .aipa-cf-check { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.aipa-cf-editor .aipa-cf-check input { width: auto; }
.aipa-cf-editor .aipa-cf-row2 { display: flex; gap: 10px; margin: 8px 0; }
.aipa-cf-editor .aipa-cf-row2 label { flex: 1; }
.aipa-cf-editor .aipa-cf-tokens { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.aipa-cf-editor .button-small { padding: 4px 10px !important; font-size: .7rem !important; }

/* Question cards */
.aipa-cf-editor .chat-form-question { position: relative; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .1); transition: border-color .2s ease, box-shadow .2s ease; }
.aipa-cf-editor .chat-form-question:hover { border-color: rgba(129, 140, 248, .45); box-shadow: 0 10px 28px rgba(2, 6, 23, .4); }
.aipa-cf-editor .chat-form-question h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: .86rem; color: #fff; }
.aipa-cf-editor .chat-form-question h4 .drag-handle { color: var(--muted); }
.aipa-cf-editor .chat-form-question h4 .question-actions { margin-left: auto; display: flex; gap: 6px; }
.aipa-cf-editor .chat-form-question p { margin: 0 0 10px; }
.aipa-cf-editor .chat-form-question p > label { display: block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.aipa-cf-editor .em-cf-sec-kind, .aipa-cf-editor .em-cf-sec-qtype { width: auto; min-width: 180px; margin-right: 8px; }
.aipa-cf-editor .info-block-editor, .aipa-cf-editor .prompt-response-editor, .aipa-cf-editor .support-ticket-editor, .aipa-cf-editor .validation-settings, .aipa-cf-editor .conditional-rules, .aipa-cf-editor .options-manager { margin: 10px 0; padding: 12px; border-radius: 12px; background: rgba(2, 6, 23, .35); border: 1px solid rgba(255, 255, 255, .08); }
.aipa-cf-editor .info-block-editor { border-left: 3px solid #f0b429; }
.aipa-cf-editor .prompt-response-editor { border-left: 3px solid #6366f1; }
.aipa-cf-editor .support-ticket-editor { border-left: 3px solid #22d3ee; }
.aipa-cf-editor .prompt-response-editor select, .aipa-cf-editor .prompt-response-editor input { margin-top: 4px; }
.aipa-cf-editor .prompt-run-device { margin-top: 8px; }
.aipa-cf-editor .prompt-run-gendme-model { margin-top: 8px; }
.aipa-cf-editor .prompt-response-pays-member, .aipa-cf-editor .prompt-response-pays-admin, .aipa-cf-editor .prompt-response-pays-chat-user { margin-top: 8px; }
.aipa-cf-editor .prompt-response-pays-admin { padding: 10px; border-radius: 8px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(129, 140, 248, .3); }
.aipa-cf-editor .option-item { border-radius: 10px; padding: 10px; margin-bottom: 8px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1); }
.aipa-cf-editor .option-item__row, .aipa-cf-editor .option-item > div:first-child { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.aipa-cf-editor .option-item .option-label, .aipa-cf-editor .option-item .option-value { flex: 1 1 160px; width: auto; }
.aipa-cf-editor .option-image-preview { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.aipa-cf-editor .option-response-wrap { margin-top: 8px; padding: 10px; border-radius: 8px; background: rgba(129, 140, 248, .08); }
.aipa-cf-editor .conditional-rule-item { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.aipa-cf-editor .conditional-rule-item > * { flex: 1; min-width: 0; }
.aipa-cf-editor .conditional-rule-item .button { flex: none; }
.aipa-cf-editor .ui-state-highlight { height: 56px; border-radius: 14px; border: 2px dashed rgba(129, 140, 248, .55); background: rgba(129, 140, 248, .08); margin-bottom: 12px; }
.aipa-cf-editor #em-cf-addsec { margin-top: 12px; }

/* Email rules table + modal */
.aipa-cf-editor #chat-forms-email-rules-list { width: 100%; border-collapse: collapse; background: transparent; border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; overflow: hidden; }
.aipa-cf-editor #chat-forms-email-rules-list th, .aipa-cf-editor #chat-forms-email-rules-list td { padding: 9px 12px; text-align: left; color: var(--ink); border-bottom: 1px solid rgba(255, 255, 255, .08); font-size: .8rem; }
.aipa-cf-editor #chat-forms-email-rules-list th { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: rgba(255, 255, 255, .04); }
.aipa-cf-editor #chat-forms-email-modal { position: fixed; inset: 0; z-index: 100010; display: none; }
.aipa-cf-editor .chat-forms-modal-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 17, .7); backdrop-filter: blur(3px); }
.aipa-cf-editor .chat-forms-modal-content { position: relative; margin: 5vh auto; max-width: 760px; max-height: 90vh; overflow-y: auto; padding: 22px; border-radius: 18px; background: linear-gradient(160deg, rgba(19, 27, 51, .97), rgba(28, 20, 64, .97)); border: 1px solid var(--glass-border); box-shadow: 0 40px 100px rgba(0, 0, 0, .55); }
.aipa-cf-editor .chat-forms-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.aipa-cf-editor .chat-forms-modal-header h3 { margin: 0; color: #fff; font-size: 1rem; }
.aipa-cf-editor .chat-forms-modal-close { background: var(--glass-bg-strong); border: 1px solid var(--glass-border); color: var(--ink); border-radius: 9px; width: 32px; height: 32px; cursor: pointer; font-size: 18px; line-height: 1; }
.aipa-cf-editor .chat-forms-modal-body p { margin: 0 0 10px; }
.aipa-cf-editor .chat-forms-modal-body p > label { display: block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.aipa-cf-editor .chat-forms-modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.aipa-cf-editor #email-dynamic-vars { margin-bottom: 10px; padding: 10px; border-radius: 10px; background: rgba(2, 6, 23, .55); border: 1px solid rgba(125, 211, 252, .18); }
.aipa-cf-editor #email-dynamic-vars .vars-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

/* Display & Widget + analytics (reused wp-admin renderers) */
.aipa-cf-editor .chat-form-widget-config { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .1); }
.aipa-cf-editor .chat-form-widget-config hr, .aipa-cf-editor .chat-forms-display-config hr { border: 0; border-top: 1px solid rgba(255, 255, 255, .1); margin: 14px 0; }
.aipa-cf-editor .aipa-cf-widget-img { display: block; width: 60px; height: 60px; object-fit: cover; border-radius: 50%; margin-top: 8px; }
.aipa-cf-editor .chat-forms-display-config select[multiple] { height: 100px; }
.aipa-cf-editor .chat-forms-display-config input[readonly] { font-family: Consolas, Monaco, monospace; font-size: .76rem; }

/* "After completion" redirect choice */
.aipa-cf-editor .aipa-cf-redirect { margin: 4px 0 6px; }
.aipa-cf-editor .aipa-cf-redirect > label { display: block; margin-bottom: 8px; }
.aipa-cf-editor .aipa-cf-redirect [hidden] { display: none !important; }
.aipa-cf-editor .aipa-cf-redirect__opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; margin-bottom: 10px; }
.aipa-cf-editor .aipa-cf-redirect__opt { position: relative; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--glass-border); background: rgba(255, 255, 255, .04); cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.aipa-cf-editor .aipa-cf-redirect__opt:hover { background: rgba(129, 140, 248, .1); }
.aipa-cf-editor .aipa-cf-redirect__opt.is-active { background: rgba(129, 140, 248, .16); border-color: rgba(129, 140, 248, .6); box-shadow: 0 0 0 1px rgba(129, 140, 248, .35) inset; }
.aipa-cf-editor .aipa-cf-redirect__opt input { position: absolute; opacity: 0; pointer-events: none; }
.aipa-cf-editor .aipa-cf-redirect__ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; background: rgba(129, 140, 248, .18); }
.aipa-cf-editor .aipa-cf-redirect__txt { display: flex; flex-direction: column; min-width: 0; }
.aipa-cf-editor .aipa-cf-redirect__txt strong { color: #f8fafc; font-size: .82rem; }
.aipa-cf-editor .aipa-cf-redirect__txt small { color: var(--muted); font-size: .7rem; line-height: 1.35; }
.aipa-cf-editor .aipa-cf-redirect__panel { margin-top: 2px; }

/* Bot Agent picker (the metabox's own inline skin is stripped server-side; this owns it) */
.aipa-cf-editor #em-cf-agentpick { position: relative; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-search { width: 100%; }
.aipa-cf-editor #em-cf-agentpick [hidden] { display: none !important; }
/* In normal flow (not absolute): the scrolling side column's later content kept painting over a floated list. */
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-search { -webkit-appearance: none; appearance: none; box-sizing: border-box; padding: 13px 16px !important; border-radius: 10px; background: var(--field-bg, rgba(2, 6, 23, .65)) !important; color: #f1f5f9 !important; border: 1px solid rgba(129, 140, 248, .35) !important; font: inherit; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-search:focus { outline: none; border-color: rgba(129, 140, 248, .7) !important; box-shadow: 0 0 0 3px rgba(129, 140, 248, .18); }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-search::placeholder { color: var(--muted); }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-search::-webkit-search-cancel-button { -webkit-appearance: none; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-results { position: relative !important; inset: auto !important; display: block; margin-top: 8px; z-index: 1; max-height: 300px; overflow-y: auto; padding: 6px; border-radius: 14px; background: #0b1226 !important; background-image: linear-gradient(170deg, rgba(129, 140, 248, .10), rgba(129, 140, 248, 0) 45%) !important; border: 1px solid rgba(129, 140, 248, .38); box-shadow: 0 26px 60px rgba(0, 0, 0, .65), 0 0 0 1px rgba(0, 0, 0, .5); }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-head { padding: 6px 10px 5px; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-muted { padding: 12px 10px; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-row { display: flex; align-items: center; gap: 11px; width: 100%; margin: 0; padding: 7px 9px; text-align: left; border-radius: 10px; background: transparent !important; border: 1px solid transparent; box-shadow: none; color: #e2e8f0; font: inherit; line-height: 1.25; cursor: pointer; transition: background .12s ease, border-color .12s ease; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-row + .em-cf-agentpick-row { margin-top: 2px; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-row:hover, .aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-row:focus-visible { background: rgba(129, 140, 248, .18) !important; border-color: rgba(129, 140, 248, .45); outline: none; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-row img, .aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-selected img { flex: none; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-row__text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-row strong, .aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-selected strong { color: #f8fafc; font-size: .84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-row small { color: var(--muted); font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-selected { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 12px; background: rgba(129, 140, 248, .13) !important; border: 1px solid rgba(129, 140, 248, .4); }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-x { flex: none; margin-left: auto; width: 28px; height: 28px; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); border: 1px solid var(--glass-border); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.aipa-cf-editor #em-cf-agentpick .em-cf-agentpick-x:hover { background: rgba(248, 113, 113, .22); border-color: rgba(248, 113, 113, .5); }

/* TinyMCE on the dark theme -- keep the editing surface light for readability, darken the chrome */
.aipa-cf-editor .wp-editor-wrap { border-radius: 10px; overflow: hidden; border: 1px solid var(--glass-border); }
.aipa-cf-editor .wp-editor-tools, .aipa-cf-editor .wp-editor-tabs { background: rgba(255, 255, 255, .04); }
.aipa-cf-editor .wp-switch-editor { color: var(--ink); background: transparent; border-color: var(--glass-border); }
.aipa-cf-editor .mce-toolbar-grp, .aipa-cf-editor .mce-statusbar { background: #1e293b !important; border-color: rgba(255, 255, 255, .1) !important; }
.aipa-cf-editor .mce-btn button, .aipa-cf-editor .mce-ico { color: #e2e8f0 !important; }
.aipa-cf-editor .quicktags-toolbar { background: #1e293b; border-color: rgba(255, 255, 255, .1); }
.aipa-cf-editor .quicktags-toolbar .ed_button { background: rgba(255, 255, 255, .08); border-color: var(--glass-border); color: var(--ink); }
.aipa-cf-editor .wp-editor-area { background: #fff; color: #111827; }

@media (prefers-reduced-motion: reduce) { .aipa-cf-editor .chat-form-question { transition: none; } }
