/* 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 {
  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: #8b949e;
  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 {
  opacity: 0.5;
}

: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: #10b981;
  background: rgba(16, 185, 129, 0.12);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

:where(.icp-popover) .icp-pinned-badge {
  font-size: 0.6rem;
  font-weight: 600;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  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: #8b949e;
  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;
}

:where(.icp-popover) .icp-reply-btn {
  font-size: 0.65rem;
  color: #6f42c1;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
}

:where(.icp-popover) .icp-reply-btn:hover {
  text-decoration: underline;
}

/* 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: #6f42c1;
  color: white;
}

:where(.icp-popover) .icp-btn:hover {
  opacity: 0.9;
}

/* Dark mode */
[data-theme="dark"] .icp-popover {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

[data-theme="dark"] .icp-popover .icp-header {
  border-bottom-color: #475569;
}

[data-theme="dark"] .icp-popover .icp-title {
  color: #f1f5f9;
}

[data-theme="dark"] .icp-popover .icp-close {
  color: #94a3b8;
}

[data-theme="dark"] .icp-popover .icp-close:hover {
  background: #334155;
}

[data-theme="dark"] .icp-popover .icp-empty {
  color: #94a3b8;
}

[data-theme="dark"] .icp-popover .icp-comment {
  background: #334155;
}

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

[data-theme="dark"] .icp-popover .icp-comment-meta {
  color: #cbd5e1;
}

[data-theme="dark"] .icp-popover .icp-comment-content {
  color: #f1f5f9;
}

[data-theme="dark"] .icp-popover .icp-also-tagged {
  color: #94a3b8;
  border-top-color: #475569;
}

[data-theme="dark"] .icp-popover .icp-also-tagged-patient {
  color: #cbd5e1;
}

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

[data-theme="dark"] .icp-popover .icp-reply-btn {
  color: #8b5cf6;
}

[data-theme="dark"] .icp-popover .icp-reply-form {
  background: #334155;
}

[data-theme="dark"] .icp-popover .icp-reply-textarea {
  background: #1e293b;
  border-color: #475569;
  color: #f1f5f9;
}

[data-theme="dark"] .icp-popover .icp-btn-cancel {
  background: #1e293b;
  border-color: #475569;
  color: #cbd5e1;
}

[data-theme="dark"] .icp-popover .icp-btn-submit {
  background: #8b5cf6;
}

/* Dark mode menu styles */
[data-theme="dark"] .icp-popover .icp-menu-trigger {
  color: #94a3b8;
}

[data-theme="dark"] .icp-popover .icp-menu-trigger:hover {
  background: #475569;
  color: #f1f5f9;
}

[data-theme="dark"] .icp-popover .icp-menu-dropdown {
  background: #1e293b;
  border-color: #475569;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] .icp-popover .icp-menu-item {
  color: #f1f5f9;
}

[data-theme="dark"] .icp-popover .icp-menu-item:hover {
  background: #334155;
}

[data-theme="dark"] .icp-popover .icp-menu-item svg {
  color: #94a3b8;
}
