extends ../PaperTemplateLayout.pug

block head 
  - var prefix = 'bc'
  style.
    .#{prefix}-root {
      color: #111;
      padding: 24px 30px;
      font-size: 12px;
      position: relative;
      box-shadow: inset 0 4px 0px 0 var(--invoice-primary-color);
    }
    .#{prefix}-header{
      box-sizing: border-box;
      display: flex;
      flex-flow: wrap;
      flex: 0 0 auto;
      -webkit-box-align: start;
      align-items: start;
      -webkit-box-pack: start;
      justify-content: flex-start;
      gap: 10px;
    }
    .#{prefix}-header-details{
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 20px;
      flex: 1 1 0%;
    }
    .#{prefix}-big-title {
      font-size: 30px;
      margin: 0;
      line-height: 1;
      font-weight: 500;
      color: #333;
    }
    .#{prefix}-logo-wrap img {
      width: 100%;
      height: 100%;
      max-width: 260px;
      max-height: 100px;
    }
    .#{prefix}-terms-list {
      display: flex;
      flex-direction: column;
      gap: 4px;
      margin-bottom: 24px;
    }
    .#{prefix}-terms-item {
      display: flex;
      flex-direction: row;
      gap: 12px;
    }
    .#{prefix}-terms-item__label {
      min-width: 120px;
      color: #333;
    }
    .#{prefix}-terms-item__value {
      /* Styles for the term value */
    }
    .#{prefix}-address-section{
      box-sizing: border-box;
      display: flex;
      flex-flow: wrap;
      -webkit-box-align: flex-start;
      align-items: flex-start;
      -webkit-box-pack: start;
      justify-content: flex-start;
      gap: 10px;
      margin-bottom: 24px;
    }
    .#{prefix}-address-section > * {
      flex: 1 1;
    }
    .#{prefix}-table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
      font-size: inherit;
    }
    .#{prefix}-table__header {
      font-weight: 400;
      border-bottom: 1px solid #000;
      padding: 2px 10px;
      color: #333;
    }
    .#{prefix}-table__header:first-of-type{
      padding-left: 0;
    }
    .#{prefix}-table__header:last-of-type{
      padding-right: 0;
    }
    .#{prefix}-table__header--right {
      text-align: right;
    }
    .#{prefix}-table__cell {
      border-bottom: 1px solid #F6F6F6;
      padding: 12px 10px;
    }
    .#{prefix}-table__cell:first-of-type{
      padding-left: 0;
    }
    .#{prefix}-table__cell:last-of-type {
      padding-right: 0;
    }
    .#{prefix}-table__cell--right {
      text-align: right;
    }
    .#{prefix}-table__cell--item .item {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .#{prefix}-table__cell--item .item .item__description{
      color: #5f6b7c;
    }
    .#{prefix}-totals {
      display: flex;
      flex-direction: column;
      margin-left: auto;
      width: 300px;
      margin-bottom: 24px;
    }
    .#{prefix}-totals__item {
      display: flex;
      padding: 4px 0;
    }
    .#{prefix}-totals__item--border-gray {
      border-bottom: 1px solid #DADADA;
    }
    .#{prefix}-totals__item--border-dark {
      border-bottom: 1px solid #000;
    }
    .#{prefix}-totals__item--font-weight-bold {
      font-weight: bold;
    }
    .#{prefix}-totals__item-label {
      min-width: 160px;
    }
    .#{prefix}-totals__item-amount {
      flex: 1 1 auto;
      text-align: right;
    }
    .#{prefix}-statement {
      margin-bottom: 20px;
    }
    .#{prefix}-statement__label {
      color: #666;
    }
    .#{prefix}-statement__value {
      white-space: pre-line;
    }

block content
 div(class=`${prefix}-root`)
  
  //- Header (includes big title, details and logo)
  div(class=`${prefix}-header`)
    //- Header details (includes big title and details)
    div(class=`${prefix}-header-details`)
      div(class=`${prefix}-big-title`) Credit Note

      div(class=`${prefix}-terms-list`)
        if showCreditNoteNumber
          div(class=`${prefix}-terms-item`)
            div(class=`${prefix}-terms-item__label`) #{creditNoteNumberLabel}:
            div(class=`${prefix}-terms-item__value`) #{creditNoteNumebr}

        if showCreditNoteDate
          div(class=`${prefix}-terms-item`)
            div(class=`${prefix}-terms-item__label`) #{creditNoteDateLabel}:
            div(class=`${prefix}-terms-item__value`) #{creditNoteDate}

    if showCompanyLogo && companyLogoUri
      div(class=`${prefix}-logo-wrap`)
        img(src=companyLogoUri alt=`Company Logo`)

  div(class=`${prefix}-address-section`)
    if showCompanyAddress
      div(class=`${prefix}-address-from`)
        div !{companyAddress}

    if showCustomerAddress
      div(class=`${prefix}-address-to`)
        strong #{billedToLabel}
        div !{customerAddress}

  table(class=`${prefix}-table`)
    thead
      tr
        th(class=`${prefix}-table__header ${prefix}-table__header--item`) #{'Item'}
        th(class=`${prefix}-table__header ${prefix}-table__header--quantity ${prefix}-table__header--right`) #{'Quantity'}
        th(class=`${prefix}-table__header ${prefix}-table__header--rate ${prefix}-table__header--right`) #{'Rate'}
        th(class=`${prefix}-table__header ${prefix}-table__header--total ${prefix}-table__header--right`) #{'Total'}
    tbody
      each line in lines
        tr(class=`${prefix}-table__row`)
          td(class=`${prefix}-table__cell ${prefix}-table__cell--item ${prefix}-table__cell--item`) 
            div.item
              div.item__label #{line.item}
              div.item__description #{line.description}
          td(class=`${prefix}-table__cell ${prefix}-table__cell--quantity ${prefix}-table__cell--right`) #{line.quantity}
          td(class=`${prefix}-table__cell ${prefix}-table__cell--rate ${prefix}-table__cell--right`) #{line.rate}
          td(class=`${prefix}-table__cell ${prefix}-table__cell--total ${prefix}-table__cell--right`) #{line.total}

  div(class=`${prefix}-totals`)
    if showSubtotal
      div(class=`${prefix}-totals__item ${prefix}-totals__item--border-gray`)
        div(class=`${prefix}-totals__item-label`) #{subtotallabel}
        div(class=`${prefix}-totals__item-amount`) #{subtotal}

    if showTotal
      div(class=`${prefix}-totals__item ${prefix}-totals__item--border-dark`)
        div(class=`${prefix}-totals__item-amount`) #{totalLabel}:
        div(class=`${prefix}-totals__item-label`) #{total}

  if showCustomerNote && customerNote
    div(class=`${prefix}-statement`)
      div(class=`${prefix}-statement__label`) #{customerNoteLabel}:
      div(class=`${prefix}-statement__value`) #{customerNote}

  if showTermsConditions && termsConditions
    div(class=`${prefix}-statement`)
      div(class=`${prefix}-statement__label`) #{termsConditionsLabel}:
      div(class=`${prefix}-statement__value`) #{termsConditions}
