@use '../../../styles/_globals.scss' as *;

:host {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;

  :host-context([dir='rtl']) {
    direction: rtl;
  }
}

:host-context(.isMac.isElectron) {
  padding-top: var(--mac-title-bar-padding);
}

.formatting-toolbar {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 2px;
  padding: var(--s) var(--s2);
  background-color: var(--bg-lightest);
  border-bottom: 1px solid var(--extra-border-color);
  position: relative;
  z-index: 1;
  color: var(--text-color);

  .toolbar-divider {
    width: 1px;
    flex-shrink: 0;
    background: var(--divider-color);
    margin: 4px 4px;
  }

  .heading-label {
    font-weight: bold;
    font-size: 11px;
    line-height: 1;
  }

  .mat-mdc-icon-button {
    --mdc-icon-button-icon-size: 18px;
    min-width: 28px;
    width: 28px;
    height: 28px;
    padding: 0;
    line-height: 28px;
    flex-shrink: 0;

    mat-icon,
    .mat-icon {
      font-size: 18px;
      width: 18px;
      height: 18px;
      line-height: 18px;
    }
  }
}

.content {
  flex-grow: 1;
  position: relative;
  color: var(--text-color-more-intense);
  background-color: var(--bg-lightest);
  display: flex;
  flex-direction: column;
  // Allow proper flex shrinking
  min-height: 0;
  overflow: hidden;

  .editor-section {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    // Allow proper flex shrinking
    min-height: 0;
    overflow: hidden;

    textarea {
      flex-grow: 1;
      padding: var(--s) var(--s2);
      box-sizing: border-box;
      overflow: auto;
      background: inherit;
      color: inherit;
      border: none;
      word-wrap: break-word;
      display: block;
      resize: none;
      font-size: 14px;
      // Allow proper flex shrinking
      min-height: 0;

      @include scrollY;

      &:focus {
        outline: none;
      }
    }
  }

  .markdown-preview {
    flex-grow: 1;
    padding: var(--s) var(--s2);
    box-sizing: border-box;
    overflow: auto;

    @include scrollY;
  }

  &.split-view {
    flex-direction: row;

    .editor-section,
    .markdown-preview {
      width: 50%;
    }

    .markdown-preview {
      border-left: 2px solid;
      border-color: var(--extra-border-color);
    }
  }
}

.controls {
  flex-direction: row;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  box-shadow: var(--whiteframe-shadow-2dp);
  padding: 0 var(--s2);

  > button {
    margin: var(--s);
  }
}

.left-buttons {
  align-items: flex-start;
  flex-grow: 0;
  flex-shrink: 0;
  margin: 8px;
  margin-right: auto;
}
