<template>
  <div class="collect-quote">
    <div class="collect-quote__backdrop" />
    <div class="collect-quote__container">
      <div class="collect-quote__quote-container">
        <div class="collect-quote__title">Preview:</div>
        <div class="collect-quote__quote">
          <Quote :text="quote.quote" />
        </div>
      </div>
      <div class="collect-quote__inputgroup">
        <button class="collect-quote__button-close" @click="close">X</button>
        <form class="collect-quote__textinput-container">
          <input type="hidden" name="id" :value="quote.id" />
          <textarea class="collect-quote__textinput" v-model="quote.quote" />
        </form>
        <div class="collect-quote__cta-container">
          <button class="collect-quote__cta" @click="save">Save</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['quote'],
  methods: {
    save() {
      this.$nuxt.$emit('save-quote', this.quote)
    },
    close() {
      this.$nuxt.$emit('close-quote')
    },
  },
}
</script>

<style lang="scss">
@import '~/assets/css/components';

.collect-quote {
  color: $primary-text-color;

  &__backdrop {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
  }

  &__container {
    position: absolute;
    display: flex;
    left: 10%;
    top: 15%;
    width: 80%;
    height: 400px;
    background-color: $primary-box-background-color;
    border: 4px solid $primary-box-border-color;
    border-radius: 20px;
    color: $primary-box-text-color;
  }

  &__quote-container {
    position: relative;
    display: flex;
    flex-direction: column;
    left: 0;
    top: 0;
    width: 50%;
    height: 100%;
    border-right: 1px solid $primary-box-border-color;
    overflow: hidden;
  }

  &__title {
    font-size: 32px;
    font-family: "Wendy One";
    margin: 48px 0 16px 48px;
  }

  &__quote {
    align-self: center;
    max-width: 400px;
    margin: 0 48px;
  }

  &__inputgroup {
    width: 50%;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  &__textinput-container {
    margin: 48px 48px 0 48px;
  }

  &__textinput {
    width: 100%;
    height: 8em;
  }

  &__button-close {
    align-self: flex-end;
    width: 48px;
    height: 48px;
    margin: 2px;
    padding: 10px;
    background: none;
    border: 0;
    font-size: 24px;
    color: $primary-box-text-color;
    cursor: pointer;

    &:hover {
      background-color: $primary-box-hover-background-color;
      color: $primary-box-hover-text-color;
      border-radius: 16px;
    }
  }

  &__cta-container {
    position: relative;
    width: 100%;
    height: 100%;
  }

  &__cta {
    position: absolute;
    right: 0;
    bottom: 0;
    margin: 48px;
    background-color: $button-background-color;
    width: 80px;
    height: 48px;
    border: 4px solid $button-border-color;
    border-radius: 8px;
    color: $button-text-color;
    font-family: Dosis;
    font-size: 24px;
    cursor: pointer;

    &:hover {
      background-color: $button-hover-background-color;
      border-color: $button-hover-border-color;
      color: $button-hover-text-color;
    }
  }
}
</style>
