@import "../../../../assets/scss/abstracts/variables";
@import "../../../../assets/scss/abstracts/mixins";

@property --color-rdg-leader-board-table-filter {syntax: "<color>"; inherits: true; initial-value: #ffffff;}
@property --color-rdg-leader-board-table-filter-bg {syntax: "<color>"; inherits: true; initial-value: #03467d;}
@property --color-rdg-leader-board-list-item-table-wrapper-border {syntax: "<color>"; inherits: true; initial-value: #cadae5;}
@property --color-rdg-leader-board-list-item-table-wrapper-scrollbar {syntax: "<color>"; inherits: true; initial-value: #dedede;}
@property --color-rdg-leader-board-list-item-table-wrapper-static-column {syntax: "<color>"; inherits: true; initial-value: #262626;}
@property --color-rdg-leader-board-sortable-th-before {syntax: "<color>"; inherits: true; initial-value: transparent;}
@property --color-rdg-leader-board-sortable-dir-d-after {syntax: "<color>"; inherits: true; initial-value: #0160ac;}
@property --color-rdg-leader-board-sortable-dir-u-after {syntax: "<color>"; inherits: true; initial-value: #0160ac;}
@property --color-rdg-leader-board-sortable-indicador-left-hover-before {syntax: "<color>"; inherits: true; initial-value: inherit;}
@property --color-rdg-leader-board-sortable-indicador-left-dir-d-before {syntax: "<color>"; inherits: true; initial-value: #0160ac;}
@property --color-rdg-leader-board-sortable-indicador-left-dir-u-before {syntax: "<color>"; inherits: true; initial-value: #0160ac;}
@property --color-rdg-leader-board-sortable-th {syntax: "<color>"; inherits: true; initial-value: #344767;}
@property --color-rdg-leader-board-sortable-th-bg {syntax: "<color>"; inherits: true; initial-value: #eef4fc;}
@property --color-rdg-leader-board-sortable-td-bg {syntax: "<color>"; inherits: true; initial-value: #ffffff;}
@property --color-rdg-leader-board-sortable-td-name {syntax: "<color>"; inherits: true; initial-value: #344767;}

.rdg-blocks .rdg-leader-board {
    .preview-thumbs {
        background-image: url('../images/rdg-leader-board-template-preview.jpg');
    }

    width: calc(var(--vw, 1vw) * 100);
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    max-width: 99.55vw;

    .container.content {
        width: 100%;
        display: flex;
        flex-direction: column;
        padding-left: 20px;
        padding-right: 20px;
        overflow-x: auto;
        position: relative;

        #wait {
            display: none;
            position: fixed;
            z-index: 1000;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            background: rgba(255, 255, 255, 0.8) url("../../assets/images/spinner.gif") 50% 50% no-repeat;
        }

        @include title;

        .table {
            overflow: hidden;
            border-top-left-radius: 1rem;
            border-top-right-radius: 1rem;
            //background-color: var(--color-white);
            overflow-x: auto;
            
            display: flex;
            flex-direction: column;
            position: relative;
            // border-radius: 16px;
            container-type: inline-size;
            // background-color: var(--color-rdg-handicappers-hub-bg);
            border: 1px solid var(--color-rdg-handicappers-hub-border);
            box-shadow: 0px 20px 50px 0px var(--color-rdg-handicappers-hub-shadow);

            #wait {
                display: none;
                position: absolute;
                z-index: 1000;
                top: 0;
                left: 0;
                height: 100%;
                width: 100%;
                border-radius: 16px;
                background: rgba(255, 255, 255, 0.8) url("../../assets/images/spinner.gif") 50% 50% no-repeat;
            }

            .table-filter {
                display: block;
                max-width: 100%;
                white-space: nowrap;
                
                @media (max-width: $breakpoint-md) {
                    & {
                        width: fit-content;
                    }
                }

                padding: 1rem;
                background-color: var(--color-rdg-leader-board-table-filter-bg);
                min-height: 3.5rem;

                .filter {
                    margin: 0;
                    width: 100%;
                    display: flex;
                    justify-content: space-between;
                    // flex-wrap: wrap;
                    gap: .7rem;
                    color: var(--color-rdg-leader-board-table-filter);

                    @media (max-width: $breakpoint-md) {
                        & {
                            flex-wrap: wrap;
                        }
                    }

                    .filter-option {
                        width: 100%;
                        display: flex;
                        align-items: center;
                        list-style: none;
                        font-weight: 600;
                        border-radius: .5rem;
                        overflow: hidden;

                        @media (max-width: $breakpoint-md) {
                            & {
                                width: 48%;
                            }
                        }

                        @media (max-width: $breakpoint-sm) {
                            & {
                                width: 100%;
                            }
                        }
                        
                        select {
                            width: 100%;
                            padding: .5rem;
                            font-size: .9rem;
                            text-transform: uppercase;
                            color: #111111;
                        }
                    }
                }
            }

            .list {
                overflow-x: auto;
                white-space: nowrap;
                border-bottom-right-radius: 1rem;
                border-bottom-left-radius: 1rem;
                background-color: var(--color-white);

                .list-items {
                    font-weight: 400;
                    font-size: 14px;
                    color: #344767;

                    @include message;

                    .table-wrapper {
                        //border: 2px solid var(--color-rdg-leader-board-list-item-table-wrapper-border);
                        border-bottom: none;
                        margin: auto;
                        max-width: 100%;
                        //overflow-x: auto;
                        scrollbar-color: var(--color-rdg-leader-board-list-item-table-wrapper-scrollbar);
                        scrollbar-width: thin;

                        .static-column {
                            box-shadow: 0 0 13px var(--color-rdg-leader-board-list-item-table-wrapper-static-column);
                            --webkit-clip-path: inset(0 -15px 0 0);
                            clip-path: inset(0 -15px 0 0);
                            left: 0;
                            padding-right: 10px;
                            position: sticky;

                            @media screen and (min-width: 48em) {
                                box-shadow: none;
                                padding-right: 10px;
                            }
                        }
                    }

                    .table-wrapper::-webkit-scrollbar {
                        width: 5px;
                    }

                    .table-wrapper::-webkit-scrollbar-thumb {
                        background: var(--color-rdg-leader-board-list-item-table-wrapper-scrollbar);
                        border-radius: 10px;
                    }

                    .table-wrapper::-webkit-scrollbar-track {
                        border-radius: 10px;
                        box-shadow: inset 0 0 5px var(--color-rdg-leader-board-list-item-table-wrapper-scrollbar);
                    }
                }
            }

            .list-pagination {
                display: flex;
                justify-content: center;
                margin-top: 2rem;

                button {
                    background-color: #FFFFFF;
                    border: 1px solid #E9ECEF;
                    border-radius: .8rem;
                    font-size: 12px;
                    font-weight: 400;
                    color: #1C4579;
                    padding: 8px 32px 8px 32px;

                    &:hover {
                        background-color: #E9ECEF;
                    }
                }
            }
        }

        .sortable {
            border-spacing: 0;
            border: none;

            tr:last-of-type {
                td,
            th {
                    border-bottom: none;
                }
            }

            th {
                cursor: pointer;
                border: none;
                background: var(--color-rdg-leader-board-sortable-th-bg);
                color: var(--color-rdg-leader-board-sortable-th);
                text-align: center;
                vertical-align: baseline;
                white-space: nowrap;

                &.no-sort {
                    pointer-events: none;
                }

                &::before {
                    transition: color 0.1s ease-in-out;
                    color: var(--color-rdg-leader-board-sortable-th-before);
                }

                &::after {
                    margin-left: 3px;
                    content: "▸";
                    transition: color 0.1s ease-in-out;
                }

                &.dir-d::after {
                    color: var(--color-rdg-leader-board-sortable-dir-d-after);
                    content: "▾";
                }

                &.dir-u::after {
                    color: var(--color-rdg-leader-board-sortable-dir-u-after);
                    content: "▴";
                }

                &.indicator-left::after {
                    content: "";
                }

                &.indicator-left::before {
                    margin-right: 3px;
                    content: "▸";
                }

                &.indicator-left:hover::before {
                    color: var(--color-rdg-leader-board-sortable-indicador-left-hover-before);
                }

                &.indicator-left.dir-d::before {
                    color: var(--color-rdg-leader-board-sortable-indicador-left-dir-d-before);
                    content: "▾";
                }

                &.indicator-left.dir-u::before {
                    color: var(--color-rdg-leader-board-sortable-indicador-left-dir-u-before);
                    content: "▴";
                }
            }

            td {
                background: var(--color-rdg-leader-board-sortable-td-bg);
            }

            td,
            th {
                padding: .5rem .5rem;
                border-left: none;
                border-right: none;
                border-top: none;
                text-align: right;
            }

            .w-1 {
                width: 4%;
            }

            .w-2 {
                width: 15%;
            }

            .w-3 {
                width: 10%;
            }

            td.top {
                text-align: center;
            }

            td.name {
                color: var(--color-rdg-leader-board-sortable-td-name);
                text-align: left;
                font-weight: 600;

                a:hover {
                    color: var(--color-danger)
                }
            }

            tbody {
                tr {
                    border: 5px solid red;
                }
            }
        }
    }
}

.acf-block-preview {
    .rdg-leader-board {
        width: 100%;
        left: 0;
        right: 0;
        margin-left: 0;
        margin-right: 0;

        .table {
            .table-menu {
                a {
                    text-decoration: none;
                }
            }
        }
    }
}
