/* item_comments_popover_html — the form's stylesheet, an asset because the
 * Anvil server strips the text out of a <style> in a template.
 *
 * Scoping. The form's root is the neutral .icp-root wrapper the template adds;
 * .icp-popover sits one level inside it, where it sat before conversion, so the
 * wrapper resets aimed at the old Anvil wrapper land on .icp-root and not on
 * the popover box (the template says why). The two rules whose subject is
 * .icp-popover stay bare, as does every [data-theme="dark"] rule, which already
 * names .icp-popover as its own ancestor. Everything else gains
 * :where(.icp-popover), which adds zero specificity and so cannot change which
 * rule wins. .icp-root itself carries no rule here.
 *
 * Nothing in this form is ever appended to document.body — the popover and its
 * menu dropdowns are positioned in place by pxClampPopupPosition and
 * pxPositionPopup, neither of which reparents — so no rule here ships
 * unscoped.
 *
 * .icp- is private to this form: grepped across all five repos' client_code
 * and theme directories, the only other occurrences are the class names this
 * form's own __init__.py writes into its innerHTML strings. No other sheet
 * declares one of these selectors, so the move from a body <style> to a head
 * <link> loses no specificity tie.
 */

/* Light mode (default) */
.icp-popover {
  --icp-submit-bg: #6f42c1;
  --icp-submit-hover: #5a32a3;
  position: fixed;
  z-index: 100000;
  min-width: 280px;
  max-width: 380px;
  max-height: 350px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 12px;
  display: none;
}

.icp-popover.visible {
  display: block;
}

:where(.icp-popover) .icp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e1e4e8;
}

:where(.icp-popover) .icp-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #24292f;
}

:where(.icp-popover) .icp-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #57606a;
  border-radius: 4px;
  font-size: 1.2rem;
  line-height: 1;
}

:where(.icp-popover) .icp-close:hover {
  background: #f7f8fa;
}

:where(.icp-popover) .icp-empty {
  text-align: center;
  color: var(--px-text-muted);
  font-size: 0.75rem;
  padding: 16px 0;
}

:where(.icp-popover) .icp-comment {
  margin-bottom: 8px;
  padding: 6px;
  background: #f7f8fa;
  border-radius: 4px;
}

:where(.icp-popover) .icp-comment.nested {
  border-left: 2px solid rgba(111, 66, 193, 0.3);
}

:where(.icp-popover) .icp-comment.resolved .icp-comment-content {
  color: var(--px-text-secondary);
}

:where(.icp-popover) .icp-comment.pinned {
  border-left: 3px solid #f59e0b;
}

:where(.icp-popover) .icp-resolved-badge {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--px-success-text);
  background: var(--px-success-bg);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

:where(.icp-popover) .icp-pinned-badge {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--px-warning-text);
  background: var(--px-warning-bg);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

:where(.icp-popover) .icp-comment-meta {
  font-size: 0.7rem;
  color: #57606a;
  margin-bottom: 2px;
}

:where(.icp-popover) .icp-comment-content {
  font-size: 0.75rem;
  color: #24292f;
  margin-bottom: 4px;
}

:where(.icp-popover) .icp-also-tagged {
  font-size: 0.65rem;
  color: var(--px-text-muted);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #e1e4e8;
}

:where(.icp-popover) .icp-also-tagged-label {
  font-weight: 500;
}

:where(.icp-popover) .icp-also-tagged-patient {
  margin-top: 4px;
  color: #57606a;
  font-style: italic;
}

:where(.icp-popover) .icp-item-tag {
  background: rgba(111, 66, 193, 0.08);
  padding: 1px 4px;
  border-radius: 2px;
  margin-right: 2px;
  display: inline-block;
}

:where(.icp-popover) .icp-comment-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* 3-dot menu styles */
:where(.icp-popover) .icp-menu {
  position: relative;
}

:where(.icp-popover) .icp-menu-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  color: #57606a;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

:where(.icp-popover) .icp-menu-trigger:hover {
  background: #f0f0f0;
  color: #24292f;
}

:where(.icp-popover) .icp-menu-dropdown {
  display: none;
  position: fixed;
  background: #ffffff;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 100px;
  z-index: 100001;
  padding: 4px 0;
}

:where(.icp-popover) .icp-menu-dropdown.open {
  display: block;
}

:where(.icp-popover) .icp-menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  font-size: 0.7rem;
  color: #24292f;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

:where(.icp-popover) .icp-menu-item:hover {
  background: #f7f8fa;
}

:where(.icp-popover) .icp-menu-item svg {
  width: 12px;
  height: 12px;
  color: #57606a;
}

:where(.icp-popover) .icp-reply-form {
  display: none;
  margin-top: 8px;
  padding: 8px;
  background: #f7f8fa;
  border-radius: 4px;
}

:where(.icp-popover) .icp-reply-form.visible {
  display: block;
}

:where(.icp-popover) .icp-reply-textarea {
  width: 100%;
  min-height: 50px;
  font-size: 0.75rem;
  padding: 6px;
  border: 1px solid #e1e4e8;
  border-radius: 4px;
  background: #ffffff;
  color: #24292f;
  resize: vertical;
  font-family: inherit;
}

:where(.icp-popover) .icp-reply-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  justify-content: flex-end;
}

:where(.icp-popover) .icp-btn {
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  border: none;
}

:where(.icp-popover) .icp-btn-cancel {
  background: #ffffff;
  border: 1px solid #e1e4e8;
  color: #57606a;
}

:where(.icp-popover) .icp-btn-submit {
  background: var(--icp-submit-bg);
  color: #ffffff;
}

:where(.icp-popover) .icp-btn-cancel:hover {
  background: var(--px-bg-elevated);
}

:where(.icp-popover) .icp-btn-submit:hover {
  background: var(--icp-submit-hover);
}

:where(.icp-popover) :is(.icp-menu-trigger, .icp-btn, .icp-reply-textarea):focus-visible {
  outline: 2px solid var(--px-focus-ring);
  outline-offset: 2px;
}

:where(.icp-popover) .icp-menu-item:focus-visible {
  outline: 2px solid var(--px-focus-ring);
  outline-offset: -2px;
}

/* Dark mode */
[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover {
  --icp-submit-bg: #7c3aed;
  --icp-submit-hover: #6d28d9;
  background: var(--px-bg-card);
  border-color: var(--px-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-header {
  border-bottom-color: var(--px-border);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-title {
  color: var(--px-text-primary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-close {
  color: var(--px-text-muted);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-close:hover {
  background: var(--px-bg-elevated);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-empty {
  color: var(--px-text-muted);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-comment {
  background: var(--px-bg-elevated);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-comment.nested {
  border-left-color: rgba(139, 92, 246, 0.4);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-comment-meta {
  color: var(--px-text-secondary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-comment-content {
  color: var(--px-text-primary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-comment.resolved .icp-comment-content {
  color: var(--px-text-secondary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-also-tagged {
  color: var(--px-text-muted);
  border-top-color: var(--px-border);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-also-tagged-patient {
  color: var(--px-text-secondary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-item-tag {
  background: rgba(139, 92, 246, 0.15);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-reply-form {
  background: var(--px-bg-elevated);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-reply-textarea {
  background: var(--px-bg-input);
  border-color: var(--px-border-strong);
  color: var(--px-text-primary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-btn-cancel {
  background: var(--px-bg-card);
  border-color: var(--px-border);
  color: var(--px-text-secondary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-btn-cancel:hover {
  background: var(--px-border);
  color: var(--px-text-primary);
}

/* Dark mode menu styles */
[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-menu-trigger {
  color: var(--px-text-muted);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-menu-trigger:hover {
  background: var(--px-border);
  color: var(--px-text-primary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-menu-dropdown {
  background: var(--px-bg-card);
  border-color: var(--px-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-menu-item {
  color: var(--px-text-primary);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-menu-item:hover {
  background: var(--px-bg-elevated);
}

[data-theme="dark"]:not(:where(.px-print-ink)) .icp-popover .icp-menu-item svg {
  color: var(--px-text-muted);
}
