/*
   "c-rg" stands for [c]omponent [r]epeatable [g]roup
 */
.c-rg {
    position:relative;
    padding-top: 20px;
    margin-bottom: 15px;
}

.c-rg__control--view {
    position:absolute;
    right: 0;
}

.wp-core-ui .button.c-rg__btn--active {
    background: #eee;
    border-color: #999;
    -webkit-box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
    box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 );
    -webkit-transform: translateY(1px);
    -ms-transform: translateY(1px);
    transform: translateY(1px);
}

.wp-core-ui .button.c-rg__btn--active.disabled,
.wp-core-ui .button.js-rfg-view-switch-disabled {
    cursor: no-drop;
}

/*
   "c-rgx" stands for [c]omponent [r]epeatable [g]roup [x]-axis
   The style rules for the horizontal display of a repeatable group
*/

/* General */
.c-rgx {
    box-sizing: border-box;
    background: #fafafa;
    border: 1px solid #ddd;
}

.c-rgx__body {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    width: calc(100% - 60px);
    margin: 0 30px;
}

.c-rgx__title {
    font-size: 1em;
    font-weight: bold;
    margin-bottom: 2px;
}

.c-rgx__title .fa,
.c-rgx__th .fa  {
    font-size: 1.2em;
    vertical-align: text-bottom;
}

.c-rgx__input_container label {
    display: none;
}

.c-rgx__warning {
    background-color: #fffece;
    border: 1px solid #ececec;
    padding: 7px;
    margin-bottom: 5px;
}

.c-rgx__warning p {
    margin: 0;
}

/* Icons */
.c-rgx__icon {
    font-size: 140%;
    display: inline-block;
    width: 16px;
}

.c-rgx__icon--trash {
    cursor: pointer;
    color: #a00;
}



/* Table */
.c-rgx__table {
    width: 100%;
    border-spacing: 0;
}

.c-rgx__tbody {
    background-color: #fff;
}

.c-rgx__td,
.c-rgx__th {
    padding: 5px 20px;
    vertical-align: top;
    text-align: left;
}

.c-rgx__tbody .c-rgx__th,
.c-rgx__td {
    border-top: 1px solid #ddd;
}

.c-rgx__tr--nested .c-rgx__thead .c-rgx__th,
.c-rgx__tr--nested > .c-rgx__td {
    border-top-width: 0;
}

.c-rgx__tbody.ui-sortable-helper > tr > th,
.c-rgx__tbody.ui-sortable-helper > tr td {
    border-bottom: 1px solid #ddd;
}

.c-rgx__table--slave .c-rgx__tbody:last-child .c-rgx__th,
.c-rgx__table--slave .c-rgx__tbody:last-child .c-rgx__td {
    /* border-bottom: 1px solid #ddd; */
}

.c-rgx__table--master .c-rgx__th {
    background: #fafafa;
    vertical-align: middle;
}

.c-rgx__th--invisible {
    visibility: hidden;
}

.c-rgx__level--1 > .c-rgx__icon {
    position: absolute;
    top: 40%;
    left: 7px;
}

.c-rgx_sort--handle {
    cursor: move;
    cursor: ns-resize;
    color: #aaa;
}

.c-rgx__table--slave > thead > tr > th:first-child,
.c-rgx__table--slave > thead > tr > th:last-child,
.c-rgx__table--slave > tbody > tr > th:first-child,
.c-rgx__table--slave > tbody > tr > th:last-child {
    text-align: center;
    padding: 0 3px;
    width: 20px;
}

.c-rgx__table--master td.c-rgx__td--group-container {
    padding: 0;
}

.c-rgx__table--master .c-rgx {
    margin: 5px 10px 10px;
}

.c-rgx__table--slave > .c-rgx__tbody > tr > th:first-child {
    border-right: 1px solid #ddd;
}

.c-rgx__table--slave > .c-rgx__tbody > tr > th:last-child {
    border-left: 1px solid #ddd;
}

.c-rgx__table--master th:nth-child(2),
.c-rgx__table--master td:nth-child(2) {
    padding-left: 3px;
}

.c-rgx__table--master th:nth-last-child(2),
.c-rgx__table--master td:nth-last-child(2) {
    padding-right: 5px;
}

.c-rgx__table--master > thead > tr > th:first-child,
.c-rgx__table--master > tbody > tr > th:first-child,
.c-rgx__table--master > thead > tr > th:last-child,
.c-rgx__table--master > tbody > tr > th:last-child {
    position: fixed;
    width: 30px;
    padding: 0;
    text-align: center;
    vertical-align: middle;
    margin-left: -30px;
    box-sizing: border-box;
    border-right: 1px solid #ddd;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

.c-rgx__table--master > thead > tr > th:last-child,
.c-rgx__table--master > tbody > tr > th:last-child {
    left: 50%;
    margin-left: 0;
    border-right: 0;
    border-left: 1px solid #ddd;
}

.c-rgx__table--master .wpt-form-textfield,
.c-rgx__table--master .wpt-form-textarea {
    min-width: 150px;
}

.c-rgy__item--fields .wpt-form-textfield,
.c-rgy__item--fields .wpt-form-textarea {
    width: 80%;
    width: calc(100% - 150px);
}

.c-rgx__table--master .wpt-form-item,
.c-rgx__nested--control {
    white-space: nowrap;
}

.c-rgx__table--master img.toolset-wpml-lock {
    display: none;
}

.c-rgx__table--master .wpt-form-radio-label,
.c-rgx__table--master .wpt-form-checkbox-label {
    display: inline;
}


/* Table cell which contains [show] / [create] / [hide] control of nested repeatable group */
.c-rgx__td--nested-active {
    position: relative;
    height: 45px; /* this works like a min-height */
}

.c-rgx__td--nested-active:before,
.c-rgx__td--nested-active:after {
    content: "";
    width: 0;
    height: 0;
    position: absolute;
    bottom: -6px;
    left: 50px;
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 20px solid #fafafa;
    background-color: transparent;
}

.c-rgx__td--nested-active:before {
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 20px solid #ddd;
    bottom: -5px;
}

.c-rgx__count {
    display: inline-block;
    background-color: #444444;
    color: #fff;
    font-size: 9px;
    width: 17px;
    height: 17px;
    text-align: center;
    line-height: 17px;
    font-weight: 600;
    margin-top: 5px;
    -webkit-border-radius: 10px;
    border-radius: 10px;
    z-index: 26;
}

.c-rgx__count--number {
    display: block;
}



/* Button */
.c-rgx__btn {
    min-width: 75px;
    text-align: center;
}

.c-rgx__table .c-rgx__btn {
    margin-right: 10px;
}

.c-rgx__btn--add {
    text-align: right;
}



/* The container shown if there is no item yet */
.c-rgx__empty--container {
    text-align: center;
    margin: 20px;
}



/* Overlap of item (currently only used for delete countdown) */
.c-rgx__overlap--countdown {
    position: absolute;
    background: rgba(238, 238, 238, 1);
    top: 0;
    left: 0;
    vertical-align: middle;
    text-align: center;
}

.c-rgx__overlap--countdown span {
    line-height: 140%;
}

.c-rgx__overlap--countdown span span {
    display: inline-block;
    width: 9px;
}



/* Loading dots
   credits to https://codepen.io/vkjgr/pen/gbPaVx */
.c-rgx__loading:after {
    content: '.';
    animation: a-rgx-loading-dots 1s steps(5, end) infinite;}

@keyframes a-rgx-loading-dots {
    0%, 20% {
        color: rgba(0,0,0,0);
        text-shadow:
                .25em 0 0 rgba(0,0,0,0),
                .5em 0 0 rgba(0,0,0,0);
    }
    40% {
        color: black;
        text-shadow:
                .25em 0 0 rgba(0,0,0,0),
                .5em 0 0 rgba(0,0,0,0);
    }
    60% {
        text-shadow:
                .25em 0 0 black,
                .5em 0 0 rgba(0,0,0,0);
    }
    80%, 100% {
        text-shadow:
                .25em 0 0 black,
                .5em 0 0 black;
    }
}


/*
   "c-rgy" stands for [c]omponent [r]epeatable [g]roup [y]-axis
   The style rules for the vertical display of a repeatable group
*/

.c-rgy__table--master > thead {
    display: none;
}

.c-rgy__table--master > tbody > tr > th:first-child,
.c-rgy__table--master > tbody > tr > th:last-child {
    position: inherit;
    margin-left: 0;
    border-bottom: 0;
}

.c-rgy__table--master td {
    border-top: 1px solid #ddd;
}

.c-rgy__table--master tbody:first-of-type > tr > td {
    border-top: 0;
}

.c-rgy__table--master tbody:first-of-type > tr > th:first-child,
.c-rgy__table--master tbody:first-of-type > tr > th:last-child {
    border-top: 0;
}

.c-rgy__table--master th:nth-last-child(2),
.c-rgy__table--master td:nth-last-child(2) {
    padding: 0;
}

.c-rgy__item--toggle,
.c-rgy__item--fields {
    padding: 10px;
}

.c-rgy__item--toggle {
    background: #fafafa;
    cursor: pointer;
}

.c-rgy__item--toggle span:first-of-type {
    font-weight: bold;
}

.c-rgy__item--toggle span:last-of-type {
    font-style: italic;
}

.c-rgy__item--toggle-hover {
    padding-left: 30px;
}

.c-rgy__overlap--title-container {
    position: absolute;
    z-index: 1000; /* must be this high for the case a select2 field is above the rfg table */
}

.c-rgy__overlap--title,
.c-rgy__overlap--title-introduction {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    position: absolute;
    top: -35px;
    left: 45px;
    padding: 5px;
    background: #0085ba;
    border-radius: 4px;
    z-index: 2;
    width: 380px;
}

.c-rgy__overlap--title:after {
    content: '';
    position: absolute;
    bottom: -8px;
    transform: rotate(45deg);
    left: -8px;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 20px solid #0085ba;
    z-index: -1;
}

.c-rgy__overlap--title-introduction {
    top: auto;
    bottom: 40px;
    color: #fff;
    padding: 10px;
}

.c-rgy__overlap--title-introduction p:first-child {
    margin-top: 0;
}

.c-rgy__overlap--title-introduction p:last-child {
    margin-bottom: 0;
}

.c-rgy__overlap--title-introduction ul {
    list-style: disc;
    margin-left: 18px;
}
.c-rgy__overlap--title-introduction span {
    cursor: pointer;
    text-decoration: underline;
}

.c-rgy__overlap--title-introduction span:hover {
    text-decoration: none;
}

.c-rgy__overlap--title input[type=text] {
    height: 28px;
    width: 100%;
}

.c-rgy__overlap--title-trigger {
    cursor: pointer;
    display: inline-block;
    padding: 0 3px;
}

.c-rgy__overlap--title-trigger:hover .fa {
    color: #0085ba;
}

.c-rgy__overlap--title-trigger .fa {
    font-size: 15px;
}

.c-rgy__item--fields {
    padding-top: 0;
    border-top: 1px solid #eeeeee;
}

.c-rgy--nested {
    position: absolute;
    left: 170px;
    top: 50%;
    transform: translate(0, -50%);
    width: 80%;
    width: calc( 100% - 200px );
    min-width: 480px;
}

.c-rgy--nested .c-rgy--nested {
    width: 80%;
    width: calc( 100% - 100px );
}

.c-rgy__body--nested {
    background: #f5f5f5;
    padding: 0 10px 10px;
}

.c-rgy__body--nested .c-rgy__body--nested {
    background: #f1f1f1;
}

.c-rgy__body--nested .c-rgy__body--nested .c-rgy__body--nested {
    background: #e9e9e9;
}

.c-rgy__items--nested {
    border: 1px solid #ddd;
}

.postbox[id^="wpcf-group-"] {
    z-index: 1;
}

.c-rgy__group--toggle-active {
    position: relative;
}

.c-rgy--nested:before,
.c-rgy--nested:after {
    content: "";
    width: 0;
    height: 0;
    position: absolute;
    top: 40%;
    top: calc( 50% - 30px );
    left: -29px;
    width: 0;
    height: 0;
    border-top: 30px solid transparent;
    border-bottom: 30px solid transparent;
    border-right: 40px solid #f5f5f5;
    background-color: transparent;
}

.c-rgy--nested:before {
    border-right-color: #ddd;
    left: -30px;
}
.c-rgy__body--nested .c-rgy--nested:after {
    border-right-color: #f1f1f1;
}

.c-rgy__body--nested .c-rgy__body--nested .c-rgy--nested:after {
    border-right-color: #e9e9e9;
}

.c-rgy__body--nested .wpt-file .textfield,
.c-rgy__body--nested .wpt-image .textfield,
.c-rgy__body--nested .wpt-audio .textfield,
.c-rgy__body--nested .wpt-video .textfield {
    width: 60%;
}

/**
 * Toogle Buttons
 */
.wp-core-ui .button.types-toogle-button {
    border-radius: 0;
    box-shadow: none;
    border-right: 0;
    box-shadow: 0 1px 0 #cccccc !important;
}
.wp-core-ui .button.types-toogle-button:first-child {
    border-radius: 3px 0 0 3px;
}
.wp-core-ui .button.types-toogle-button:first-child:not(.disabled) {
    box-shadow: 1px 1px 0 #cccccc !important;
}
.wp-core-ui .button.types-toogle-button:last-child {
    border-radius: 0 3px 3px 0;
    border-right: 1px solid #cccccc;
}
.wp-core-ui .button.types-toogle-button.disabled {
    background: #eeeeee !important;
}

.c-rgx__button--container {
    position: relative;
    display: inline-block;
    margin-left: 20px;
}

/*
   For RFG Field Conditions
   .wpt-hidden is used in legacy to hide a field which conditions are not met. For rfg items we use knockout to
   manage the visibility. As .wpt-hidden has also functionial use we cannot just remove it on rfg fields, therefore
   we force with !important the visibility.

   Also we need to fix radio / checkboxes which height is set to auto when conditions are used. In an RFG group
   "auto" results to 0px height.
 */
.c-rgx__table .wpt-hidden {
    display: block !important;
}

.c-rgx__table input[type="radio"],
.c-rgx__table input[type="checkbox"] {
    height: 16px !important;
}
