/* Security module styles. Prefix: security-. */

.security-form-required {
  color: var(--app-color-danger, #b42318);
}

/* --- Check workspace: summary + progress --- */
.security-check-summary {
  /* Horizontal padding comes from `.app-details-container > section > *`;
     only set vertical padding so the summary stays aligned with the rest. */
  padding-block: 1rem 0.75rem;
}

.security-check-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0;
}

.security-check-meta dt {
  font-size: 0.8rem;
  color: var(--app-text-muted, #667085);
  margin-bottom: 0.15rem;
}

.security-check-meta dd {
  margin: 0;
  font-weight: 500;
}

.security-check-progress {
  /* Full-width progress bar directly under the info section. */
  padding-block: 0 1.25rem;
}

.security-check-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--app-muted-border-color, #eaecf0);
  overflow: hidden;
}

.security-check-progress-fill {
  height: 100%;
  background: var(--app-notice-success-border-color, #079455);
  transition: width 0.2s ease;
}

.security-check-progress-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--app-muted-color, #667085);
}

/* --- Steps: each step is its own separated card --- */
.security-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.security-step {
  /* Reset Pico's <article> card chrome (extra margin + shadow); we draw our own border. */
  margin: 0;
  box-shadow: none;
  border: 1px solid var(--app-card-border-color, #e4e7ec);
  border-radius: var(--app-border-radius, 8px);
  padding: 0.9rem 1rem;
  background: var(--app-card-background-color, #fff);
}

.security-step.is-done {
  border-color: var(--app-notice-success-border-color, #079455);
  background: var(--app-notice-success-background-color, #f6fef9);
}

.security-step-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  /* Reset Pico's <article> > <header> chrome so it isn't a boxed-off sub-section. */
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.security-step-number {
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--app-muted-border-color, #eaecf0);
  color: var(--app-muted-color, #475467);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.security-step.is-done .security-step-number {
  background: var(--app-notice-success-border-color, #079455);
  color: #fff;
}

.security-check-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  margin: 0;
}

.security-step-toggle {
  flex: 1 1 auto;
}

.security-step-toggle span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

/* Match step 5's <h3> headline size so all step card titles are consistent. */
.security-step-toggle strong {
  font-size: var(--text-lg);
  line-height: var(--leading-tight);
}

.security-check-toggle input[type="checkbox"] {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  margin: 0.1rem 0 0;
}

.security-completion-meta {
  font-size: 0.78rem;
  color: var(--app-notice-success-color, #079455);
  white-space: nowrap;
  margin-left: auto;
}

.security-item-note {
  width: 100%;
  margin: 0.6rem 0 0;
}

/* Align the per-step note with the indented step fields
   (start past the number badge + gap, matching `.security-step-fields`). */
.security-step > .security-item-note {
  margin-left: 2.5rem;
  width: calc(100% - 2.5rem);
}

.security-step-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 1rem;
  margin: 0.75rem 0 0;
  padding-left: 2.5rem;
}

/* Long-form text fields take a full row; compact fields (datetimes) sit side by side. */
.security-step-field {
  grid-column: 1 / -1;
}

.security-step-field-datetime {
  grid-column: auto;
}

.security-step-field label {
  display: block;
  font-size: 0.82rem;
  color: var(--app-muted-color, #475467);
  margin-bottom: 0.2rem;
}

.security-step-field textarea,
.security-step-field input[type="datetime-local"] {
  margin: 0;
  width: 100%;
}

@media (max-width: 640px) {
  .security-step-fields {
    grid-template-columns: 1fr;
  }

  .security-step-field-datetime {
    grid-column: 1 / -1;
  }
}

/* Hint shown (by the workspace JS) while required info fields are still empty. */
.security-step-gate-hint:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.6rem 0 0;
  padding-left: 2.5rem;
  font-size: 0.8rem;
  color: var(--app-notice-warning-color, #ad7122);
}

/* "Generate PDF customer report" action in the final (report) step. Indented to
   2.5rem to line up under the step header text, like the fields/notes above. */
.security-report-action {
  margin-top: 0.75rem;
  padding-left: 2.5rem;
}

.security-report-action > .secondary {
  margin-bottom: 0;
}

.security-report-hint {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
}

/* --- Technical checklist --- */
.security-step-tech .security-tech-list {
  list-style: none;
  margin: 0.75rem 0 0;
  /* Indent to 2.5rem so checklist items line up under the step header text
     (past the number badge + gap), matching the other steps' fields/notes. */
  padding: 0 0 0 2.5rem;
}

.security-step-empty {
  margin: 0.75rem 0 0;
  padding-left: 2.5rem;
}

.security-tech-section {
  font-weight: 600;
  margin: 0.9rem 0 0.4rem;
  color: var(--app-text, #1d2939);
}

.security-tech-item {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--app-border-subtle, #f2f4f7);
}

.security-tech-label {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.security-tech-hint {
  font-size: 0.78rem;
}

/* Rendered Markdown guidance authored on the template — collapsed by default in
   a <details> callout (left accent + info tint) so it clearly reads as the info
   for this checkpoint without crowding the form. */
.security-tech-markdown {
  flex-basis: 100%;
  margin: 0.4rem 0 0.1rem 1.85rem;
  padding: 0.4rem 0.75rem;
  border-left: 3px solid var(--app-notice-info-border-color, #6b7e99);
  border-radius: 0 6px 6px 0;
  background: var(--app-notice-info-background-color, #eef1f6);
  font-size: 0.85rem;
  color: var(--app-color, #1d2939);
}

.security-tech-markdown > summary {
  font-weight: 500;
  color: var(--app-notice-info-color, #4a5a73);
}

.security-tech-markdown-body > :first-child {
  margin-top: 0;
}

.security-tech-markdown-body > :last-child {
  margin-bottom: 0;
}

.security-tech-markdown-body :where(ul, ol) {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
}

.security-tech-markdown-body pre {
  padding: 0.5rem 0.75rem;
  background: var(--app-card-background-color, #fff);
  border-radius: 6px;
  overflow-x: auto;
}

.security-tech-item .security-item-note {
  flex-basis: 100%;
  margin-top: 0.25rem;
}

/* --- Danger zone --- */
.security-danger-zone {
  margin-top: 1.5rem;
}

/* Inner wrapper carries the border so it inherits the same 2rem inset
   (via `.app-details-container > section > *`) as the steps container. */
.security-danger-zone-inner {
  padding: 1rem;
  border: 1px solid var(--app-notice-error-border-color, #fda29b);
  border-radius: var(--app-border-radius, 8px);
  background: var(--app-notice-error-background-color, #fffbfa);
}

.security-danger-zone-inner h3 {
  margin: 0 0 0.6rem;
}

.security-danger-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.security-danger-actions form {
  margin: 0;
}

.security-danger-actions button {
  margin: 0;
}

/* --- Template edit + fields --- */
.security-field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.security-field {
  margin-bottom: 0.9rem;
}

.security-field label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.security-field input,
.security-field select {
  margin: 0;
}

/* The core `input + small` helper rule (app-shell, @layer layout) applies a
   negative margin-top that assumes the input keeps its default bottom margin.
   We reset that margin to 0 above, so without this the negative pull drags the
   hint up into the input. Restore the app's intended helper-text gap. */
.security-field input + small,
.security-field select + small {
  margin-top: calc(var(--app-spacing) * 0.25);
}

.security-active-toggle {
  margin-top: 0.5rem;
}

/* --- Schema editor --- */
.security-schema-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.security-schema-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--app-card-border-color, #e4e7ec);
  border-radius: 6px;
  background: var(--app-card-background-color, #fff);
}

.security-schema-item-section {
  background: var(--app-card-sectioning-background-color, #f9fafb);
}

.security-schema-item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.security-schema-markdown {
  margin: 0;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.security-schema-type {
  flex: 0 0 auto;
}

.security-schema-label {
  flex: 1 1 40%;
  margin: 0;
}

.security-schema-hint {
  flex: 1 1 30%;
  margin: 0;
}

.security-schema-controls {
  display: flex;
  gap: 0.2rem;
  flex: 0 0 auto;
}

.security-schema-controls button {
  margin: 0;
}

.security-schema-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.security-schema-toolbar button {
  margin: 0;
}

@media (max-width: 640px) {
  .security-schema-item-row {
    flex-wrap: wrap;
  }

  .security-schema-label,
  .security-schema-hint {
    flex-basis: 100%;
  }
}

/* --- Creation wizard (check + template create views) ---
   The .app-wizard-* primitive is shared in spirit with other modules but its
   styles are not in core — they live in each module's own stylesheet. This
   module is standalone (requires: []) and never loads another module's CSS, so
   without these rules the header collapses to block flow (back arrow stacked
   above the title). Kept in sync with the helpdesk wizard. Single-step here, so
   the step-indicator rules are intentionally omitted. */
.app-wizard-content {
  max-width: 32rem;
}

.app-wizard-header {
  display: flex;
  align-items: center;
  gap: calc(var(--app-spacing) * 0.75);
  margin-bottom: calc(var(--app-spacing) * 1.25);
}

.app-wizard-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--app-border-radius);
  color: var(--app-muted-color);
  text-decoration: none;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.app-wizard-back:hover {
  background: var(--app-background-muted, #f8f9fa);
  color: var(--app-color);
}

.app-wizard-title {
  font-size: var(--text-xl, 1.25rem);
  font-weight: var(--font-semibold, 600);
  margin: 0;
}

.app-wizard-card {
  background: var(--app-card-background-color, #fff);
  border: 1px solid var(--app-card-border-color, #e5e7eb);
  border-radius: calc(var(--app-border-radius) * 2);
  padding: calc(var(--app-spacing) * 1.5);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.04);
}

.app-wizard-card-heading {
  font-size: var(--text-lg, 1.125rem);
  font-weight: var(--font-semibold, 600);
  margin: 0 0 0.25rem;
}

.app-wizard-card-description {
  font-size: var(--text-sm, 0.875rem);
  color: var(--app-muted-color);
  margin: 0 0 calc(var(--app-spacing) * 1.25);
}

.app-wizard-field-group {
  margin-bottom: calc(var(--app-spacing) * 1.25);
}

.app-wizard-field-group > label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: var(--text-sm, 0.875rem);
  font-weight: var(--font-medium, 500);
}

.app-wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: calc(var(--app-spacing) * 1.5);
  padding-top: calc(var(--app-spacing) * 1.25);
  border-top: 1px solid var(--app-card-border-color, #e5e7eb);
}

@media (max-width: 576px) {
  .app-wizard-card {
    padding: var(--app-spacing);
  }
}

/* --- Customer report design (logo + HTML/CSS template editor) --- */
.security-template-editor textarea {
  width: 100%;
  margin: 0;
  font-family: var(--font-mono, ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace);
  font-size: 0.8125rem;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre;
  resize: vertical;
}

.security-variable-reference {
  margin-top: calc(var(--app-spacing) * 1.25);
}

.security-variable-reference h4 {
  margin: 0 0 0.25rem;
  font-size: var(--text-sm, 0.875rem);
  font-weight: var(--font-medium, 600);
}

.security-variable-list {
  display: grid;
  grid-template-columns: minmax(12rem, max-content) 1fr;
  gap: 0.25rem 1rem;
  margin: 0.5rem 0 0;
}

.security-variable-list dt {
  margin: 0;
}

.security-variable-list dt code {
  font-size: 0.8125rem;
  white-space: nowrap;
}

.security-variable-list dd {
  margin: 0;
  color: var(--app-muted-color, #6a6a6a);
  font-size: var(--text-sm, 0.875rem);
}

@media (max-width: 576px) {
  .security-variable-list {
    grid-template-columns: 1fr;
    gap: 0.1rem 0;
  }

  .security-variable-list dd {
    margin-bottom: 0.4rem;
  }
}
