@use '@angular/material' as mat;
@use 'theme';

$label-color: mat.get-color-from-palette(theme.$app-foreground, secondary-text);

:host {
  display: flex;
  height: 100%;

  .page-box {
    position: relative;
    overflow-x: hidden;
  }

  header,
  footer {
    display: flex;
    user-select: none;
  }

  header {
    margin: 18px 12px 0;

    > * {
      vertical-align: middle;
      margin: auto 6px;
    }
  }

  footer {
    align-self: end;
    margin: 0 10px 18px;

    > * {
      margin: auto 8px;
    }
  }

  section {
    flex: auto;
    overflow-y: auto;
    display: flex;
    position: relative;
    align-items: stretch;

    > * {
      display: inline-block;
      vertical-align: top;
    }
  }
}

#form-container,
#preview-container {
  display: flex;
  flex-flow: column;
  padding: 18px;
  gap: 18px;
  box-sizing: border-box;
  height: fit-content;
}

#form-container {
  form {
    user-select: none;
    display: contents;

    mat-form-field {
      &.markdown mat-label::after {
        font-family: 'iconfont';
        content: ' \00e6d1';
      }
    }

    > * {
      display: block;
    }

    > mat-hint {
      font-size: 12px;

      .md-container {
        margin: 10px 0 2px 8px;
        transition: color 0.1s;

        &:hover {
          color: mat.get-color-from-palette(theme.$app-foreground, text);
        }
      }
    }
  }
}

#preview-container {
  mat-card {
    mat-card-subtitle {
      user-select: none;

      .loading {
        margin-left: 8px;
      }
    }
  }

  #preview-row1 {
    display: flex;
    gap: 18px;

    mat-card {
      flex: 1;
    }
  }
}

button,
mat-card-subtitle {
  .loading {
    display: inline-block;
  }
}

.ns-option {
  user-select: none;

  &.mat-option {
    line-height: 1.5em !important;
  }

  .ns-text {
    font-weight: 500;
  }

  .ns-raw {
    &::before {
      content: ' (';
    }

    &::after {
      content: ') ';
    }
  }

  .ns-intro {
    display: block;
    color: $label-color;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

mat-option .hint {
  user-select: none;
  display: flex;
  flex-direction: column;
  line-height: 1.2em;

  .hint-slaved {
    text-decoration: line-through;
  }

  .hint-namespace {
    color: mat.get-color-from-palette(theme.$app-primary, 700);
  }

  .hint-translation {
    .hint-namespace {
      color: mat.get-color-from-palette(theme.$app-primary, 300);
    }

    font-size: 70%;
    float: right;
    color: $label-color;
  }
}

@media not all and (max-width: 720px) {
  #root {
    padding: 6px;
  }

  footer {
    position: absolute;
    top: 18px;
    right: 0;
  }

  .narrow {
    display: none;
  }

  section {
    transform: translateX(0) !important;
    overflow: auto;
  }

  #form-container {
    width: 45%;
  }

  #preview-container {
    width: 55%;
  }
}

@media (max-width: 720px) {
  #root {
    padding: 0;
  }

  .wide {
    display: none;
  }

  section {
    width: 200%;

    > * {
      overflow: auto;
    }
  }

  #form-container,
  #preview-container {
    width: 50%;
  }
}

.eh-name ::ng-deep {
  img[ehimg] {
    max-width: 2em;
    max-height: 1.25em;
    vertical-align: middle;
  }
}
