.field--widget-paragraphs {
  counter-reset: university-counter;
}

/* increment only top-level rows that actually contain a paragraph item */
.field--widget-paragraphs table.field-multiple-table>tbody>tr:has(.paragraph-top) {
  counter-increment: university-counter;
}

.field--widget-paragraphs table.field-multiple-table>tbody>tr:has(.paragraph-top) .paragraph-top::before {
  content: counter(university-counter) ". ";
  font-weight: 700;
  margin-right: 6px;
}

.draggable:hover {
  background-color: transparent;
}

.text-content table, .views-table, .draggable-table {
  margin-block-start: unset;
}

/* .js .field--widget-paragraphs .field-multiple-table {
  margin-bottom: 0;
} */

:is(.text-content table, .views-table, .draggable-table) th {
  border-block-end: none;

  h4 {
    border-block-end: 2px solid var(--color-primary);
    padding-bottom: 16px;
  }
}

.field--type-file {

  /* wrapper injected by JS */
  .dope-file {
    display: grid;
    gap: .5rem;
  }

  .dope-file input[type="file"] {
    position: absolute;
    left: -9999px;
  }

  .dope-file__button {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .9rem;
    border: 1px solid var(--color-primary);
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 2.2rem;
    background: #f7f7fc;
  }

  /* Icon */
  .dope-file__button::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 18px;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
    width: 18px;
    height: 18px;
    background-image: url('data:image/svg+xml,<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3.55457 6.31525L2.05128 5.53203C2.93377 3.70526 5.43122 1.11231 7.19071 0.196088L7.5679 0L7.94509 0.196088C9.70458 1.11232 12.202 3.70526 13.0845 5.53203L11.5812 6.31525C11.0396 5.19373 9.67122 3.63822 8.40877 2.60232V12.0348H6.72702V2.60232C5.46458 3.63822 4.09623 5.19373 3.55457 6.31525ZM15.1358 12.0348V15.236H0V12.0348H1.68175V13.4899H13.454V12.0348H15.1358Z" fill="%230032A0"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
  }

  .dope-file__name {
    font-size: .9rem;
    opacity: .8;
  }

  /* style each uploaded file row
     when it's a multivalue field a table
     is added so we have to style the table
     along with the form-managed-file
   */
  table.draggable-table {

    border-spacing: 0 22px;

    thead {
      display: none;
    }

    tr:hover {
      border-radius: 12px;
    }

    td {
      vertical-align: middle;
      background-color: var(--color-table-bg);
      padding: 4px 16px !important;

      &:hover {
        background-color: var(--color-table-bg);
        padding: 4px 16px !important;
      }

      &:first-child {
        border-radius: 12px 0 0 12px;

        .tabledrag-handle {
          display: none;
        }

      }

      &:last-child {
        border-radius: 0 12px 12px 0;
        text-align: right;
      }
    }
  }

  .olivero-details {
    border-color: var(--color--gray-90);
    border-radius: 12px;
    box-shadow: 0 0 0 var(--color--gray-90);
  }

  .olivero-details__summary {
    pointer-events: none;
    background: #f7f7fc;
    border-radius: 12px 12px 0 0;
    color: var(--color-primary);
    font-weight: 400;
    font-size: 16px;
    padding: 14px;

    &::before {
      display: none;
    }
  }

  .olivero-details__wrapper {
    margin: 18px;

    .draggable-table {
      .draggable {
        height: 64px;
      }
    }
  }
}

.form-managed-file:has(.file) {
  background-color: var(--color-table-bg);
  padding: 4px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

/*
 * ALL REMOVE BUTTONS
*/
input[id*="-remove-button"],
input[id*="-actions-delete"] {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 400;
  border: 1px solid var(--color-primary);
}

.field--type-link:has(table) {
  table.draggable-table {
    & tr {
      .field-label {
        padding-right: 0;
      }

      td {
        .form-item {
          margin-bottom: 0;
        }
      }

      & td:has(input) {
        text-align: right;
        vertical-align: middle;
      }
    }
  }

  label {
    display: none;
  }
}


/* Hide drag handle globaly */
.tabledrag-handle,
a.tabledrag-handle {
  display: none !important;
}

/* Hide the "Show row weights" toggle */
.tabledrag-toggle-weight-wrapper {
  display: none !important;
}

/* If you want to hide the weight column too */
td.tabledrag-hide,
th.tabledrag-hide,
input.js-tabledrag-weight {
  display: none !important;
}


table.draggable-table {
  border-collapse: separate;
  border-spacing: 0;

  td {
    border-block-end: 0;
  }

}

/* table:has(.paragraph-type--university) {
  border-collapse: separate;
  border-spacing: 0;
}

:is(.text-content table, .views-table, .draggable-table) tr:last-child td {
  border-block-end: none;
}
 */


.js .field--widget-paragraphs td {
  padding: 0 0 22px 0;
}

.field--widget-paragraphs {

  .paragraphs-subform {
    border: 1px solid var(--color-primary);
    border-radius: 0 0 12px 12px;
    border-top: none;
    padding: 16px;
    margin-top: 0;
  }

  .paragraphs-features__delete-confirmation {
    border: 1px solid var(--color-primary);
    border-radius: 12px;
    padding: 16px;

    .form-actions {
      margin: 16px 0 0;
    }
  }

  td {
    .paragraph-top:first-child {
      margin-block: 0;
    }
  }

  .paragraph-top {
    padding: 24px 16px;
    background-color: var(--color-primary);
    color: var(--color-white);
    font-size: var(--fs-20);
    font-weight: 700;
    line-height: 1.25;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;

    .button {
      --sp1: 0;
      height: 40px;
      line-height: 0;
    }

    .form-wrapper {
      margin-block: 0;
    }

    .paragraphs-actions {
      display: flex;
      flex-direction: row-reverse;
      margin-left: auto;

      button {
        text-indent: -9999px;
        background-repeat: no-repeat;
        background-size: 24px 24px;
        background-position: center;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M9.1709 4C9.58273 2.83481 10.694 2 12.0002 2C13.3064 2 14.4177 2.83481 14.8295 4" stroke="white" stroke-width="1.5" stroke-linecap="round"/><path d="M20.5001 6H3.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/><path d="M18.8332 8.5L18.3732 15.3991C18.1962 18.054 18.1077 19.3815 17.2427 20.1907C16.3777 21 15.0473 21 12.3865 21H11.6132C8.95235 21 7.62195 21 6.75694 20.1907C5.89194 19.3815 5.80344 18.054 5.62644 15.3991L5.1665 8.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/><path d="M9.5 11L10 16" stroke="white" stroke-width="1.5" stroke-linecap="round"/><path d="M14.5 11L14 16" stroke="white" stroke-width="1.5" stroke-linecap="round"/></svg>');
        padding: 16px 20px;
      }
    }
  }

  @media (min-width:992px) {
    .paragraph-top{
      position: sticky;
      top: 0;
      z-index: 10;

    }
  }

  .paragraphs-icon-button {
    padding-left: 40px;
    padding-right: 16px;
    font-size: 16px;
    background-color: var(--color-white);
    background-image: url('../../images/pen.png');
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 20px 20px;
  }

  .paragraphs-features__delete-confirm {
    background-color: transparent;
    border-color: var(--color-white);
    color: var(--color-white);
  }

}

.form-actions .paragraphs-add-wrapper {

  margin-inline-end: 0;

  .button {
    padding-block: 16px;
    padding-inline: 24px;
    background-color: var(--color-accent-complete);
    border-color: var(--color-accent-complete);

    &:focus {
      color: var(--color-primary);
      background-color: var(--color-accent-complete);
      border-color: var(--color-accent-complete);
      outline: 2px solid var(--color-accent-complete);
    }
  }

}
