/**
 * Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

.LogHistory {
  font-family: monospace;
  font-size: 0.9em;
  overflow: auto;
  background-color: white;

  .LogHistoryEmpty {
    padding: 16px;
    font-size: 1em;
  }
}

.log-entry {
  align-items: center;
  display: grid;
  grid-template-areas: 'timestamp level tag message';
  grid-template-columns: fit-content(100%) fit-content(100%) fit-content(100%) 1fr;
  padding-left: 8px;
  background-color: var(--mdc-theme-surface);

  &:first-child {
    border-top: 1px solid var(--mdc-theme-surface);
  }

  &:nth-last-child(2) {
    border-bottom: 1px solid #ccc;
  }

  .log-timestamp {
    grid-area: timestamp;
    opacity: 0.6;
    align-self: start;
    margin-right: 4px;
  }

  .log-level {
    border-radius: 3px;
    border-width: 0;
    color: rgba(0, 0, 0, 1);
    cursor: pointer;
    font-family: monospace;
    font-weight: bold;
    grid-area: level;
    padding: 0px 3px;
    margin-right: 4px;

    align-self: start;
    text-align: center;

    &.warn {
      background-color: orange;
    }

    &.user {
      background-color: lightblue;
    }

    &:hover {
      background-color: rgba(0, 0, 0, 0.15);
    }
  }

  .log-tag {
    border-left: 1px solid #ccc;
    background-color: white;
    align-self: stretch;
    padding: 0px 0px 0px 2px;

    .log-tag-button {
      padding: 1px 3px;
      align-self: stretch;
      color: var(--mdc-theme-secondary);
      border-radius: 2px;

      &:hover {
        background-color: rgba(0, 0, 0, 0.1);
        cursor: pointer;
      }
    }
  }

  .log-message-single {
    grid-column: 4 / span 1;
    grid-row: 1;
    line-height: 1.2em;
    word-break: break-all;
    white-space: pre-wrap;
    align-self: stretch;
    background-color: white;
    padding: 1px 3px;
  }

  .log-message-multi {
    grid-column: 1 / span 4;
    grid-row: 2;
  }

  .log-data-rich {
    display: block;
    grid-column: 1 / span 4;
    grid-row: 2;
    visibility: visible;
    padding-bottom: 8px;
  }

  .log-toggle {
    align-content: center;
    appearance: unset;
    background-color: #eee;
    border-radius: 4px;
    cursor: pointer;
    display: grid;
    font-size: 1.2em;
    font-weight: bold;
    grid-area: expand;
    height: 30px;
    justify-content: center;
    margin: 0px;
    opacity: 1;
    outline: none;
    width: 30px;

    &:hover {
      background-color: #ddd;
    }

    &:after {
      align-content: center;
      display: grid;
      height: 30px;
      justify-content: center;
      width: 30px;
    }

    &:checked:after {
      content: '-';
    }

    &:not(:checked):after {
      content: '+';
    }
  }

  .log-toggle:checked ~ .log-data-rich {
    display: block;
    grid-column: 1 / span 4;
    grid-row: 2;
    visibility: visible;
  }

  pre {
    margin: 10px 0px 0px 0px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    overflow: auto;
    white-space: pre;
    font-size: 0.9em;
  }
}
