/* Taskbuilder AI Assistant */
.wppm-ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000; /* above floating widgets such as the notification bell */
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.wppm-ai-overlay[hidden] { display: none; }
body.wppm-ai-open { overflow: hidden; }

.wppm-ai-dialog {
  background: #fff;
  color: #1e293b;
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}
.wppm-ai-dialog *, .wppm-ai-dialog *::before, .wppm-ai-dialog *::after { box-sizing: border-box; }

.wppm-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.wppm-ai-head h3 { margin: 0; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: #1e293b; }
.wppm-ai-head .dashicons { color: #7c3aed; }
.wppm-ai-x {
  border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: #64748b;
  width: 36px; height: 36px; border-radius: 8px;
}
.wppm-ai-x:hover, .wppm-ai-x:focus-visible { background: #f1f5f9; color: #1e293b; }

.wppm-ai-body { padding: 18px 20px; overflow-y: auto; flex: 1 1 auto; }
.wppm-ai-foot {
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid #e2e8f0; background: #f8fafc; border-radius: 0 0 12px 12px;
}
.wppm-ai-foot:empty { display: none; }

.wppm-ai-form label, .wppm-ai-toolbar label { font-weight: 600; display: block; margin-bottom: 6px; color: #334155; }
.wppm-ai-form textarea, .wppm-ai-form input,
.wppm-ai-task input[type="text"], .wppm-ai-task textarea, .wppm-ai-task select, .wppm-ai-task input[type="date"],
.wppm-ai-toolbar select {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font-size: 14px;
  background: #fff; color: #1e293b; min-height: 38px; max-width: 100%;
}
.wppm-ai-form textarea:focus, .wppm-ai-form input:focus, .wppm-ai-task input:focus, .wppm-ai-task textarea:focus, .wppm-ai-task select:focus {
  outline: 2px solid #7c3aed; outline-offset: 1px; border-color: #7c3aed;
}
.wppm-ai-dates-note { margin: 12px 0 0; padding: 8px 12px; border-radius: 8px; background: #f8fafc; border: 1px solid #e2e8f0; color: #475569; font-size: 13px; }
.wppm-ai-dates-note .dashicons { font-size: 16px; width: 16px; height: 16px; vertical-align: -3px; color: #7c3aed; }
.wppm-ai-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.wppm-ai-note { color: #64748b; font-size: 13px; margin: 14px 0 0; }
.wppm-ai-error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 8px 12px; margin: 12px 0 0; }
.wppm-ai-error[hidden] { display: none; }

.wppm-ai-btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; padding: 8px 16px; min-height: 38px;
  font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
}
.wppm-ai-btn .dashicons { font-size: 18px; width: 18px; height: 18px; }
.wppm-ai-btn-primary { background: #7c3aed; color: #fff; }
.wppm-ai-btn-primary:hover, .wppm-ai-btn-primary:focus-visible { background: #6d28d9; color: #fff; }
.wppm-ai-btn-primary[disabled] { opacity: 0.7; cursor: wait; }
.wppm-ai-btn-ghost { background: #fff; color: #334155; border-color: #cbd5e1; }
.wppm-ai-btn-ghost:hover, .wppm-ai-btn-ghost:focus-visible { background: #f1f5f9; }

.wppm-ai-loading { text-align: center; padding: 40px 10px; color: #475569; }
.wppm-ai-spinner {
  display: inline-block; width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid #ede9fe; border-top-color: #7c3aed; animation: wppm-ai-spin 0.9s linear infinite;
}
@keyframes wppm-ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wppm-ai-spinner { animation-duration: 3s; } }

.wppm-ai-intro { margin: 0 0 12px; color: #475569; }
.wppm-ai-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.wppm-ai-toolbar label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
.wppm-ai-toolbar select { width: auto; min-width: 160px; }

.wppm-ai-tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.wppm-ai-task {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff;
  margin: 0;
}
.wppm-ai-task.is-off { opacity: 0.5; background: #f8fafc; }
.wppm-ai-pick { margin-top: 10px !important; width: 18px; height: 18px; flex: 0 0 auto; accent-color: #7c3aed; }
.wppm-ai-task-fields { flex: 1 1 auto; min-width: 0; display: grid; gap: 8px; }
.wppm-ai-t-title { font-weight: 600; }
.wppm-ai-t-desc { resize: vertical; min-height: 54px; }
.wppm-ai-task-meta { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; color: #94a3b8; }

/* "AI write" on task descriptions */
.wppm-ai-desc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.wppm-ai-desc-head label { margin-bottom: 0; }
.wppm-ai-desc-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; min-height: 30px; border-radius: 999px;
  border: 1px solid #ddd6fe; background: #f5f3ff; color: #6d28d9; font-size: 13px; font-weight: 600; cursor: pointer; line-height: 1.2;
}
.wppm-ai-desc-btn .dashicons { font-size: 16px; width: 16px; height: 16px; }
.wppm-ai-desc-btn:hover, .wppm-ai-desc-btn:focus-visible, .wppm-ai-desc-btn[aria-expanded="true"] { background: #ede9fe; border-color: #c4b5fd; }
.wppm-ai-desc-panel {
  margin: 8px 0; padding: 10px; border: 1px solid #ddd6fe; border-radius: 10px; background: #faf9ff; color: #1e293b; font-size: 14px; line-height: 1.5;
}
.wppm-ai-desc-panel[hidden] { display: none; }
.wppm-ai-desc-menu { display: flex; flex-wrap: wrap; gap: 6px; }
.wppm-ai-desc-mode {
  border: 1px solid #cbd5e1; background: #fff; color: #334155; border-radius: 8px; padding: 6px 12px; min-height: 34px; font-size: 13px; cursor: pointer;
}
.wppm-ai-desc-mode:hover:not([disabled]), .wppm-ai-desc-mode:focus-visible { border-color: #7c3aed; color: #6d28d9; }
.wppm-ai-desc-mode[disabled] { opacity: 0.45; cursor: not-allowed; }
.wppm-ai-desc-mode.is-active { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.wppm-ai-desc-mode.is-active:hover { color: #fff; }
.wppm-ai-desc-panel .wppm-ai-desc-menu + .wppm-ai-desc-preview-label,
.wppm-ai-desc-done + .wppm-ai-desc-menu { margin-top: 10px; }
.wppm-ai-link-muted { color: #64748b; }
.wppm-ai-desc-working { display: flex; align-items: center; gap: 10px; color: #475569; }
.wppm-ai-desc-working .wppm-ai-spinner { width: 20px; height: 20px; border-width: 2px; }
.wppm-ai-desc-preview-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: #6d28d9; margin-bottom: 6px; }
.wppm-ai-desc-preview { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; max-height: 260px; overflow-y: auto; }
.wppm-ai-desc-preview p { margin: 0 0 8px; }
.wppm-ai-desc-preview ul { margin: 0 0 8px 20px; padding: 0; list-style: disc outside !important; }
.wppm-ai-desc-preview li { display: list-item !important; list-style: disc outside !important; margin: 0 0 4px; padding: 0; }
.wppm-ai-desc-actions .wppm-ai-btn-primary,
.wppm-ai-desc-actions .wppm-ai-btn-primary:hover,
.wppm-ai-desc-actions .wppm-ai-btn-primary:focus { color: #fff !important; background: #7c3aed !important; border-color: #7c3aed !important; }
.wppm-ai-desc-actions .wppm-ai-btn-ghost { color: #334155 !important; background: #fff !important; }
.wppm-ai-desc-preview > :last-child { margin-bottom: 0; }
.wppm-ai-desc-hint { margin: 6px 0 0; font-size: 12px; color: #64748b; }
.wppm-ai-desc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.wppm-ai-desc-actions .wppm-ai-btn { min-height: 34px; padding: 6px 14px; font-size: 13px; }
.wppm-ai-desc-done { display: flex; align-items: center; gap: 6px; color: #15803d; font-weight: 600; flex-wrap: wrap; }
.wppm-ai-link { background: none; border: 0; padding: 0; color: #6d28d9; text-decoration: underline; cursor: pointer; font: inherit; }
.wppm-ai-desc-panel .wppm-ai-error { margin: 0; }

/* Quick add with AI (Add Task form) */
.wppm-ai-quick { margin: 0 0 18px; padding: 12px; border: 1px solid #ddd6fe; border-radius: 12px; background: #faf9ff; }
.wppm-ai-quick-label { display: flex; align-items: center; gap: 6px; font-weight: 600; color: #4c1d95; margin: 0 0 8px; font-size: 14px; }
.wppm-ai-quick-label .dashicons { color: #7c3aed; }
.wppm-ai-quick-row { display: flex; gap: 8px; }
.wppm-ai-quick-input {
  flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; background: #fff; color: #1e293b;
}
.wppm-ai-quick-input:focus { outline: 2px solid #7c3aed; outline-offset: 1px; border-color: #7c3aed; }
.wppm-ai-quick-btn {
  flex: 0 0 auto; min-height: 40px; padding: 8px 16px; border: 0; border-radius: 8px; background: #7c3aed; color: #fff !important; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.wppm-ai-quick-btn:hover, .wppm-ai-quick-btn:focus-visible { background: #6d28d9; }
.wppm-ai-quick-btn[disabled] { opacity: .7; cursor: wait; }
.wppm-ai-quick-status { margin: 8px 0 0; font-size: 13px; color: #64748b; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wppm-ai-quick-status .wppm-ai-spinner { width: 16px; height: 16px; border-width: 2px; }
.wppm-ai-quick-status.is-ok { color: #15803d; font-weight: 600; }
.wppm-ai-quick-status.is-error { color: #b91c1c; }
.wppm-ai-quick-warnings { flex-basis: 100%; margin: 4px 0 0; padding: 8px 10px 8px 26px; list-style: disc outside !important; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; color: #92400e; font-weight: 500; }
.wppm-ai-quick-warnings li { display: list-item !important; list-style: disc outside !important; margin: 0 0 2px; }
@media (max-width: 600px) {
  .wppm-ai-quick-row { flex-direction: column; }
  .wppm-ai-quick-btn { width: 100%; }
}

/* AI summary / status report */
.wppm-ai-summary-for { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: #6d28d9; margin-bottom: 8px; }
.wppm-ai-summary .wppm-ai-sum-overview { font-size: 15px; margin: 0 0 14px; color: #1e293b; }
.wppm-ai-summary h4.wppm-ai-sum-h { font-size: 14px; font-weight: 600; margin: 14px 0 6px; color: #334155; display: flex; align-items: center; gap: 6px; }
.wppm-ai-summary h4.wppm-ai-sum-h::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #7c3aed; flex: 0 0 auto; }
.wppm-ai-summary h4.wppm-ai-sum-next_steps::before { background: #2563eb; }
.wppm-ai-summary h4.wppm-ai-sum-risks::before { background: #dc2626; }
.wppm-ai-summary ul { margin: 0 0 0 20px; padding: 0; list-style: disc outside !important; }
.wppm-ai-summary li { display: list-item !important; list-style: disc outside !important; margin: 0 0 4px; }
.wppm-ai-summary-btn .dashicons { margin-right: 2px; }
/* Open task toolbar: outlined button like "More actions". */
.wppm-ai-ot-btn {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer;
  padding: 9px 16px; min-height: 40px; border-radius: 10px; border: 1px solid #e2e8f0; background: #fff; color: #334155;
  font-size: 14px; font-weight: 500; line-height: 1.2; box-sizing: border-box; width: auto; vertical-align: middle;
}
.wppm-ai-ot-btn .dashicons { color: #7c3aed; font-size: 18px; width: 18px; height: 18px; }
.wppm-ai-ot-btn:hover, .wppm-ai-ot-btn:focus-visible { background: #f5f3ff; border-color: #c4b5fd; color: #4c1d95; }
/* The open-task toolbar turns every button into a 36px icon square; this one keeps its label. */
.wppm-ot-shell .wppm-ot-actions > span.wppm-ai-ot-btn {
  width: auto; height: 36px; min-height: 36px; padding: 0 12px; gap: 6px; line-height: 1.2; order: 2;
  font-size: 13px; font-weight: 600; color: #475569; white-space: nowrap;
}
.wppm-ot-shell .wppm-ot-actions > span.wppm-ai-ot-btn:hover { color: #4c1d95; }

/* Toolbar button on the project page */
.wppm-ai-tasks-btn .dashicons { margin-right: 2px; }

/* Settings → AI Assistant */
#wppm_ai_settings .wppm-ai-secondary-btn { margin-left: 8px; background: #fff !important; color: #334155 !important; border: 1px solid #cbd5e1 !important; }
.wppm-ai-demo-note { background: #f5f3ff; border: 1px solid #ddd6fe; color: #4c1d95; border-radius: 8px; padding: 10px 12px; }
.wppm-ai-test-result { margin-top: 12px; font-weight: 600; }
.wppm-ai-wp-status { padding: 10px 12px; border-radius: 8px; margin: 0 0 8px; }
.wppm-ai-wp-status.is-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.wppm-ai-wp-status.is-error { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.wppm-ai-test-result.is-ok { color: #15803d; }
.wppm-ai-test-result.is-error { color: #b91c1c; }

@media (max-width: 600px) {
  .wppm-ai-overlay { padding: 0; align-items: stretch; }
  .wppm-ai-dialog { max-height: 100vh; height: 100%; border-radius: 0; }
  .wppm-ai-foot { border-radius: 0; }
  .wppm-ai-row { grid-template-columns: minmax(0, 1fr); }
  .wppm-ai-task-meta { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .wppm-ai-task-meta select { grid-column: 1 / -1; }
  .wppm-ai-task-meta span { display: none; }
  .wppm-ai-btn { flex: 1 1 auto; justify-content: center; }
}
