/* See also staff/share/batch-item-attr.component.css */

#volcopy-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  column-gap: 0.75rem;
}

#volcopy-grid h4 {
  font-weight: normal;
  padding: 0.25rem;
}

.card {
  margin-block: 0.5rem;
}

.batch-header {
  background-color: var(--batch-item-attr-header-bg);
}

.template-row {
  background-color: #007a54;
}

.card-header {
  display: flex;
}

.card-header h5 {
  margin: 0;
}

.card-header .readonly,
.card-header .edit-toggle,
.card-header h5:not(.readonly):not(:has(.edit-toggle)) {
  background-color: transparent;
  border: 0;
  font-weight: bold;
  padding-block: 0.25rem;
  padding-inline: 0 0.5rem;
  text-align: start;
  text-decoration: none;
}

.card-header .edit-toggle:is(:hover, :focus, :focus-visible) {
  background-color: transparent;
  text-decoration: underline;
}

.card .dl-grid {
  grid-template-columns: 1fr max-content;
  column-gap: 1rem;
}

.card-body fieldset {
  margin-bottom: 0.5rem;
}

/* OPTIONAL COMPACT VIEW */
#volcopy-grid {
  container-name: volcopy;
  container-type: inline-size;
}

#volcopy-grid,
#volcopy-grid #col-text-fields {
  align-items: flex-start;
  display: flex;
  flex-grow: 1;
  flex-wrap: wrap;
  gap: 2rem;
}

#volcopy-grid #col-text-fields-header {
  display: none;
}

#volcopy-grid .col {
  flex: 1 0 calc(300px - 2rem);
}

#volcopy-grid .col h4,
#volcopy-grid #col-text-fields-header {
  border-block-end: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 600;
  margin-block-end: 0.25rem;
  padding: 0.25rem;
}

::ng-deep #volcopy-grid li .card {
  background: var(--bs-card-bg);
  border-radius: 0;
  border-width: 0 0 1px;
  display: grid;
  grid-template-columns: minmax(30%, auto) auto;
  justify-content: space-between;
  margin: 0;
  padding: 0.25rem;
}

::ng-deep #volcopy-grid li .card:has(.edit-buttons) {
  display: block;
  padding: 0.5rem 1rem;
}

::ng-deep #volcopy-grid li .card-header {
  grid-column: 1;
  background: none;
  border: 0;
  padding: 0;
}

::ng-deep #volcopy-grid li .card-body {
  grid-column: 2;
  background: none;
  border: 0;
  padding: 0;
}

::ng-deep #volcopy-grid li .card-body .dl-grid {
  column-gap: 0;
  text-align: end;
}

::ng-deep #volcopy-grid li .card-body .dl-grid:has(.def.numeric)  {
  grid-template-columns: max-content max-content;
  column-gap: 0.75rem;
}

/* Base required styling */
::ng-deep #volcopy-grid li .card.required .card-header h5:not(:has(.edit-toggle)):after,
::ng-deep #volcopy-grid li .card.required .card-header .edit-toggle:after {
  content: "*";
  font-weight: bold;
}

/* Base has-changes styling */
::ng-deep #volcopy-grid li .card.has-changes { 
  --bs-card-cap-color: var(--bs-success-text-emphasis);
  border-inline-start: 3px solid var(--bs-success);
}

::ng-deep #volcopy-grid li .card.has-changes:not(:has(.edit-buttons)) {
  --bs-card-bg: var(--bs-success-bg-subtle);
  --bs-card-color: var(--bs-success-text-emphasis);
  border-block-end: 1px solid var(--bs-success-border-subtle);
}

/* Required-not-met takes precedence over has-changes */
::ng-deep #volcopy-grid li .card.required-not-met,
::ng-deep #volcopy-grid li .card.has-changes.required-not-met {
  --bs-card-cap-color: var(--bs-danger-text-emphasis);
  border-inline-start: 3px dotted var(--bs-danger);
}

::ng-deep #volcopy-grid li .card.required-not-met:not(:has(.edit-buttons)),
::ng-deep #volcopy-grid li .card.has-changes.required-not-met:not(:has(.edit-buttons)) {
  --bs-card-bg: var(--bs-danger-bg-subtle);
  --bs-card-color: var(--bs-danger-text-emphasis);
  border-block-end: 1px solid var(--bs-danger-border-subtle);
}

::ng-deep #volcopy-grid li .card.has-changes.required-not-met .term .value:before {
  content: "warning";
  font-family: "Material Icons";
  font-weight: normal;
  margin-inline-end: .3ch;
  vertical-align: bottom;
}

::ng-deep #volcopy-grid li .card.required:not(.has-changes) .card-header .edit-toggle::after {
  color: var(--bs-body-color);
}

::ng-deep #volcopy-grid li .card:is(.has-changes, .required-not-met) .card-header .field-header,
::ng-deep #volcopy-grid li .card:is(.has-changes, .required-not-met) .card-header .edit-toggle,
::ng-deep #volcopy-grid li .card:is(.has-changes, .required-not-met) .card-header .edit-toggle:is(:hover, :focus, :focus-visible) {
  color: var(--bs-card-cap-color);
}

::ng-deep #volcopy-grid li .card:is(.has-changes, .required-not-met) .card-header .edit-toggle:is(:focus, :focus-visible) {
  outline: 0.25rem solid rgba(var(--bs-yellow-400-rgba), 0.5);
}

@container volcopy (max-width: 1499px) {
  ::ng-deep #volcopy-grid li .card:is(.copy_alerts, .copy_notes, .copy_tags, .copy_stats) {
    border-block-end: 0;
    display: block;
    padding: 0.5rem 0.25rem;
  }

  #volcopy-grid #col-text-fields .card-header {
    display: none;
  }

  #volcopy-grid #col-text-fields > .col .list-unstyled {
    margin-block-end: 1rem;
  }
}

@container volcopy (min-width: 1500px) {
  #volcopy-grid #col-text-fields {
    flex: 1 0 calc(300px - 2rem);
    gap: 0;
    margin-block-end: 1rem;
  }

  #volcopy-grid #col-text-fields > .col .list-unstyled {
    margin: 0;
  }

  #volcopy-grid #col-text-fields-header {
    display: block;
    width: 100%;
  }

  #volcopy-grid #col-text-fields .col h4,
  #volcopy-grid #col-text-fields .card-body .btn-outline-dark {
    display: none;
  }

  ::ng-deep #volcopy-grid li .card.copy_stats {
    border-block-end: 0;
    display: block;
    padding: 0.5rem 0.25rem;
  }
}

