/*
 * This file is part of Cockpit.
 *
 * Copyright (C) 2015 Red Hat, Inc.
 *
 * Cockpit is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * Cockpit is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Cockpit; If not, see <https://www.gnu.org/licenses/>.
 */

.cockpit-log-panel:empty {
  border: none;
}

.cockpit-log-panel {
  overflow-x: unset;
}

.cockpit-log-panel .panel-body {
  padding: 0;
}

.cockpit-log-panel .pf-v6-c-card__body .panel-heading,
.cockpit-log-panel .panel-body .panel-heading {
  border-block-start: 0;
  background-color: var(--ct-color-bg);
  font-weight: var(--pf-t--global--font--weight--heading--default);
  font-size: var(--pf-t--global--font--size--heading--h3);
  padding-block: var(--pf-t--global--spacer--sm);
  inline-size: auto;
  color: var(--ct-color-list-text);
  display: flex;
}

.cockpit-log-panel .pf-v6-c-card__body .panel-heading {
  /* Align sub-heading within a PF4 card to the heading of the card */
  padding-inline-start: var(--pf-t--global--spacer--lg);
}

.cockpit-log-panel .panel-body .panel-heading:not(:first-child)::after {
  content: "\a0";
  display: block;
  flex: auto;
  background: linear-gradient(var(--ct-color-bg) 50%, var(--ct-color-border) calc(50% + 1px), var(--ct-color-bg) calc(50% + 2px));
  margin-block: 0;
  margin-inline: 0.5rem 0;
}

.cockpit-logline {
  --log-icon: 24px;
  --log-time: 3rem;
  --log-message: 1fr;
  --log-service-min: 0;
  --log-service: minmax(var(--log-service-min), max-content);
  background-color: var(--ct-color-list-bg);
  font-size: var(--pf-t--global--font--size--sm);
  padding-block: 0.5rem;
  padding-inline: 1rem;
  display: grid;
  grid-template-columns: var(--log-icon) var(--log-time) var(--log-message) var(--log-service);
  gap: var(--pf-t--global--spacer--sm);
  align-items: baseline;
}

.cockpit-log-panel .cockpit-logline:hover {
  background-color: var(--ct-color-list-hover-bg);
  cursor: pointer;
}

.cockpit-log-panel .cockpit-logline:hover .cockpit-log-message:not(.cockpit-logmsg-reboot) {
  color: var(--ct-color-list-hover-text);
  text-decoration: underline;
}

.cockpit-log-panel .cockpit-logline+.panel-heading {
  border-block-start-width: 1px;
}

/* Don't show headers without content */
.cockpit-log-panel .panel-heading:last-child {
  display: none !important;
}

.cockpit-logmsg-reboot {
  font-style: italic;
}

.cockpit-log-warning {
  display: flex;
  align-self: center;
  justify-content: center;
}

.empty-message {
  inline-size: 100%;
  color: var(--pf-v6-global--Color--200);
  display: block;
  padding-block: 0.5rem;
  padding-inline: 1rem;
  text-align: center;
}

.cockpit-log-time,
.cockpit-log-service,
.cockpit-log-service-reduced {
  color: var(--pf-v6-global--Color--200);
}

.cockpit-log-time {
  color: var(--pf-v6-global--Color--200);
  font-family: monospace;
  font-size: var(--pf-t--global--font--size--xs);
  justify-self: end;
  white-space: nowrap;
}

.cockpit-log-message,
.cockpit-log-service,
.cockpit-log-service-reduced {
  flex: auto;
}

.cockpit-log-message,
.cockpit-log-service,
.cockpit-log-service-reduced {
  font-size: var(--pf-t--global--font--size--sm);
}

.cockpit-log-service-container>.pf-v6-c-badge {
  margin-inline-start: var(--pf-t--global--spacer--xs);
}

.cockpit-log-service-container {
  display: flex;
  align-items: baseline;
}

@media screen and (max-width: 428px) {
  .cockpit-logline {
    /* Remove space for service */
    --log-service: 0;
  }

  .cockpit-log-service,
  .cockpit-log-service-reduced,
  .cockpit-log-service-container {
    /* Move service under message */
    grid-area: 2 / 3;
  }
}
