/*
  Change Request Widget — styles
  EMR Studios internal tool. Kept neutral/minimal so it drops into any client theme
  (light or dark) without clashing. Only real "branding" hook is --crw-accent, which
  a client snippet can override via a CSS custom property or the data-accent attribute.
*/

.crw-root {
  /* Defaults — overridable per client via inline style or a page-level custom property. */
  --crw-accent: #8a8a8a;
  --crw-bg: #111214;
  --crw-fg: #f2f2f2;
  --crw-muted: #9a9a9a;
  --crw-border: rgba(255, 255, 255, 0.14);
  --crw-danger: #e5484d;
  --crw-radius: 10px;
  --crw-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  display: inline-flex;
  align-items: center;
  font-family: var(--crw-font);
  line-height: 1.4;
}

/* Fallback fixed placement, used only if the host page has no <footer> to dock into. */
.crw-root--fixed {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 2147483000;
}

/* The icon trigger — deliberately unlabeled, low-contrast until interacted with. */
.crw-trigger {
  appearance: none;
  border: none;
  background: transparent;
  padding: 6px;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: currentColor;
  opacity: 0.32;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.crw-trigger:hover,
.crw-trigger:focus-visible {
  opacity: 0.9;
  transform: scale(1.08);
}

.crw-trigger:focus-visible {
  outline: 2px solid var(--crw-accent);
  outline-offset: 2px;
}

.crw-trigger svg {
  width: 10px;
  height: 10px;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .crw-trigger {
    transition: none;
  }
  .crw-trigger:hover,
  .crw-trigger:focus-visible {
    transform: none;
  }
}

/* Overlay + dialog */
.crw-overlay {
  /* Same default token set as .crw-root — the overlay is appended straight to
     <body> (so it can escape any host-page overflow/stacking context), not
     nested inside .crw-root, so it needs its own copy of these custom
     properties rather than inheriting them. Kept in sync with .crw-root. */
  --crw-accent: #8a8a8a;
  --crw-bg: #111214;
  --crw-fg: #f2f2f2;
  --crw-muted: #9a9a9a;
  --crw-border: rgba(255, 255, 255, 0.14);
  --crw-danger: #e5484d;
  --crw-radius: 10px;
  --crw-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2147483001;
}

.crw-overlay[hidden] {
  display: none;
}

.crw-dialog {
  width: 100%;
  max-width: 360px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--crw-bg);
  color: var(--crw-fg);
  border: 1px solid var(--crw-border);
  border-radius: var(--crw-radius);
  padding: 20px;
  font-family: var(--crw-font);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

@media (prefers-reduced-motion: no-preference) {
  .crw-dialog {
    animation: crw-pop 0.16s ease-out;
  }
}

@keyframes crw-pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.crw-dialog h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--crw-fg);
}

.crw-dialog p.crw-hint {
  font-size: 12.5px;
  color: var(--crw-muted);
  margin: 0 0 14px;
}

.crw-field {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.crw-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--crw-fg);
}

.crw-field .crw-optional {
  font-weight: 400;
  color: var(--crw-muted);
}

.crw-field input[type="text"],
.crw-field input[type="password"],
.crw-field input[type="file"],
.crw-field select,
.crw-field textarea {
  font: inherit;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--crw-fg);
  border: 1px solid var(--crw-border);
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
}

.crw-field textarea {
  min-height: 72px;
  resize: vertical;
}

.crw-field input:focus-visible,
.crw-field select:focus-visible,
.crw-field textarea:focus-visible,
.crw-btn:focus-visible {
  outline: 2px solid var(--crw-accent);
  outline-offset: 2px;
}

.crw-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.crw-btn {
  appearance: none;
  border: 1px solid var(--crw-border);
  background: transparent;
  color: var(--crw-fg);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 7px;
  cursor: pointer;
  flex: 1;
}

.crw-btn--primary {
  background: var(--crw-accent);
  border-color: var(--crw-accent);
  color: #0b0b0c;
}

.crw-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.crw-error,
.crw-status {
  font-size: 12.5px;
  margin-top: 8px;
  min-height: 1em;
}

.crw-error {
  color: var(--crw-danger);
}

.crw-status--success {
  color: #4ade80;
}

.crw-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--crw-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.crw-close:focus-visible {
  outline: 2px solid var(--crw-accent);
  outline-offset: 2px;
}

.crw-dialog-inner {
  position: relative;
}

.crw-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
