@use "ct-card";
@use "page";

@import "@patternfly/patternfly/utilities/Spacing/spacing.css";

/* Style the list cards as ct-cards */
.pf-v5-c-page__main-section .pf-v5-c-card {
  @extend .ct-card;
}

.pf-v5-c-table tr:nth-child(1) {
  > td, th {
    --pf-v5-c-table--cell--PaddingTop: var(--pf-v5-global--spacer--sm);
    --pf-v5-c-table--cell--PaddingBottom: var(--pf-v5-global--spacer--sm);

    padding-block: var(--pf-v5-c-table--cell--PaddingTop) var(--pf-v5-c-table--cell--PaddingBottom);

    padding-inline: var(--pf-v5-c-table--cell--PaddingLeft) var(--pf-v5-c-table--cell--PaddingRight);
  }
}

.kpatches-labelgroup ul.pf-v5-c-label-group__list,
.kpatches-labelgroup li.pf-v5-c-label-group__list-item:last-child, {
  margin-block-end: 0;
}

.pk-updates--header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding-block: 1.5rem 1rem;
  padding-inline: 0;

  &--actions {
    > .pf-v5-c-button,
    > .btn-group {
      margin-block: 5px 0;
      margin-inline: 0 5px;

      &:last-child {
        margin-inline-end: 0;
      }
    }
  }
}

@media screen and (min-width: 640px) {
  .pk-updates--header--auto {
    justify-content: flex-start;
  }
}

// Make header's content bold
.pf-v5-c-table tr:nth-child(1) td:nth-child(2) {
  font-weight: var(--pf-v5-global--FontWeight--bold);
}

.ct-table tr {
  .severity-icon {
    margin-inline-end: var(--pf-v5-global--spacer--xs);
  }

  td.changelog {
    vertical-align: top;

    * {
      display: inline;
      font: inherit;
      background: inherit;
      color: inherit;
    }

    &, p {
      max-inline-size: 60vw;
      margin-block-end: 0;  // counter-act <Markdown>
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  th:last-child,
  td.changelog:last-child {
    text-align: start;
  }
}

.severity-critical {
  color: #a30000;
}

.severity-important {
  color: #ec7a08;
}

.severity-low {
  color: var(--ct-color-subtle-copy);
}

div.changelog {
  max-block-size: 20em;
  overflow: auto;
  white-space: pre-wrap;
}

/* Hide changelog summaries in narrow widths */
@media screen and (max-width: 80ch) {
  table.ct-table {
    /* Hide changelog header (there's no class) & data */
    thead th:last-child,
    td.changelog {
      display: none;
    }
  }
}

/* don't let the install progress bar get too wide */
.progress-main-view {
  max-inline-size: 60rem;
  margin-block: 10ex 0;
  margin-inline: auto;

  .pf-v5-l-grid {
    align-items: end;
  }
}

/* workaround font not supporting tabular numbers yet https://github.com/cockpit-project/cockpit/issues/15090 */
.pf-v5-c-progress__status {
  min-inline-size: 3ch;
}

/* Add some space between the spinner and the text */
.progress-description > svg {
  margin-inline-end: var(--pf-v5-global--spacer--sm);
}

.flow-list-blank-slate {
  margin-block: 0;
  margin-inline: auto;
  max-inline-size: 69rem;
  text-align: center;
}

.flow-list {
  padding: 0;
  text-align: start;
  box-sizing: border-box;

  li {
    text-align: start;
    box-sizing: border-box;
    inline-size: 22rem;
    padding-block: 0;
    padding-inline: 0 1ex;
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

// prevent overflowo on small screens
.error-log {
  max-inline-size: 100%;
}

.update-log {
  text-align: center;

  th {
    text-align: start;
    padding-inline-end: 3ex;
  }

  td {
    text-align: start;
  }
}

.update-log-content {
  margin-block: 0;
  margin-inline: 10ex;
  block-size: 13em;
  overflow-y: auto;
}

table.header-buttons {
  margin-block-end: 20px; /* replacement for h2's margin-bottom */
  td {
    vertical-align: middle;
  }

  h2 {
    /* vertical default ones break vertical alignment */
    margin-block: 0;
    margin-inline: 0 4rem;
  }
}

#auto-update-day {
  max-inline-size: 10rem;
}

#auto-update-time {
  max-inline-size: 7rem;
}

.auto-update-group {
  // Add spacing between rows for when the flex items wrap
  row-gap: var(--pf-v5-global--spacer--sm);
}

.pk-updates .pf-v5-c-description-list + div {
  padding-block-start: var(--pf-v5-global--spacer--md);
}

.restart-services-modal-body {
  padding-block: 1em;
  padding-inline: 0;
}

.pf-v5-c-content ul {
  list-style-type: none;
}

.updates-history {
  // Constrain  time's width
  .history-time {
    inline-size: 0;
    white-space: nowrap;
  }

  // Fix alignment of the package count's icon
  .list-view-pf-additional-info-item {
    align-items: baseline;

    > svg {
      margin-inline-end: 1ex;
    }
  }
}

.updates-success-table {
  margin-block-end: 1em;
}

.update-success-actions > button {
  margin-block: var(--pf-v5-global--spacer--xs);
  margin-inline: var(--pf-v5-global--spacer--sm) 0;
}

.update-success-table-title {
  padding-inline-start: var(--pf-v5-global--spacer--sm);
}

.cockpit-update-warning {
  margin-inline-end: var(--pf-v5-global--spacer--md);
}

.cockpit-update-warning-icon {
  margin-inline-end: var(--pf-v5-global--spacer--sm);
}

.cockpit-update-warning-text {
  color: var(--pf-v5-global--warning-color--200);
}

.autoupdates-card-error {
  margin-block-end: var(--pf-v5-global--spacer--md);
}

.ct-info-circle {
  color: var(--pf-v5-global--info-color--100);
}
