@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;}
@property --color-rdg-leader-board-button {syntax: "<color>"; inherits: true; initial-value: #FFFFFF;}
@property --color-rdg-leader-board-button-border {syntax: "<color>"; inherits: true; initial-value: #E9ECEF;}

.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;

        @include title;

        #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 {
            overflow: hidden;
            overflow-x: auto;
            
            display: flex;
            flex-direction: column;
            position: relative;
            container-type: inline-size;
            box-shadow: 0px 20px 40px 0px var(--color-rdg-handicappers-hub-shadow);
            border-radius: 1rem;

            a {
                color: var(--color-rdg-leader-board-sortable-th);
            }

            .shadow {
                .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;
                        gap: .7rem;
                        justify-content: space-between;
                        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;
                            border-radius: .5rem;
                            overflow: hidden;

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

                            @media (max-width: $breakpoint-sm) {
                                & {
                                    width: 100%;
                                }
                            }
                            
                            select {
                                width: 100%;
                                padding: .5rem;
                                color: var(--color-rdg-leader-board-sortable-td-name);
                            }
                        }
                    }
                }

                .list {
                    width: 100%;
                    overflow-x: auto;
                    white-space: nowrap;
                    background-color: var(--color-white);

                    .list-items {
                        color: var(--color-rdg-leader-board-sortable-th);

                        @include message;

                        .table-wrapper {
                            border-bottom: none;
                            margin: auto;
                            max-width: 100%;
                            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: 2rem 0;

            button {
                background-color: var(--color-rdg-leader-board-button);
                border: 1px solid var(--color-rdg-leader-board-button-border);
                border-radius: .8rem;
                color: var(--color-rdg-leader-board-table-filter-bg);
                padding: 8px 32px 8px 32px;

                &:hover {
                    background-color: var(--color-rdg-leader-board-button-border);
                }
            }

            button.disabled {
                background-color: var(--color-rdg-leader-board-button-border);
                color: var(--color-rdg-leader-board-button);
                cursor: not-allowed;
            }
        }

        .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;
            }

            th.name {
                text-align: left;
            }

            .w-1 {
                width: 4%;
            }

            .w-2 {
                width: 21%;
            }

            .w-3 {
                width: 8%;
            }

            .w-4 {
                width: 8%;
            }

            .w-5 {
                width: 8%;
            }

            .w-6 {
                width: 8%;
            }

            .w-7 {
                width: 8%;
            }

            .w-8 {
                width: 8%;
            }

            .w-9 {
                width: 15%;
            }

            .w-10 {
                width: 12%;
            }

            td.top {
                text-align: center;
            }

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

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

            td.group {
                color: var(--color-rdg-leader-board-sortable-td-name);
                text-align: right;

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

.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;
                }
            }
        }
    }
}
