@use 'sass:map';
@use '../styles/mat-selectors' as ms;
@use '../styles/flex' as flex;

.adf-app-list-item {
    cursor: pointer;
}

$tile-themes: (
    theme-1: (
        bg: #269abc,
        color: #168aac
    ),
    theme-2: (
        bg: #7da9b0,
        color: #6d99a0
    ),
    theme-3: (
        bg: #7689ab,
        color: #66799b
    ),
    theme-4: (
        bg: #c74e3e,
        color: #b73e2e
    ),
    theme-5: (
        bg: #fab96c,
        color: #eaa95c
    ),
    theme-6: (
        bg: #759d4c,
        color: #658d3c
    ),
    theme-7: (
        bg: #b1b489,
        color: #a1a479
    ),
    theme-8: (
        bg: #a17299,
        color: #916289
    ),
    theme-9: (
        bg: #696c67,
        color: #595c57
    ),
    theme-10: (
        bg: #cabb33,
        color: #baab23
    )
);

.adf-app-list-spinner,
.adf-app-list-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 85vh;

    #{ms.$mat-progress-spinner} {
        margin: 0 auto;
    }
}

.adf-apps {
    width: 100%;

    .adf-app-listgrid {
        padding: 8px;
        flex-flow: row wrap;
        display: flex;

        &-item {
            outline: none;
            padding: 8px;
            box-sizing: border-box;
            flex: 1 1 33.3333%;
            max-width: 33.3333%;

            @include flex.layout-bp(lt-md) {
                flex: 1 1 50%;
                max-width: 50%;
            }

            @include flex.layout-bp(lt-sm) {
                flex: 1 1 100%;
                max-width: 100%;
            }

            &-card {
                @for $i from 1 through 10 {
                    &.theme-#{$i} {
                        $tile-theme: map.get($tile-themes, theme-#{$i});

                        background-color: map.get($tile-theme, bg);

                        .adf-app-listgrid-item-card-logo-icon {
                            color: map.get($tile-theme, color);
                        }
                    }
                }

                outline: none;
                flex-direction: column;
                display: flex;
                transition:
                    transform 280ms cubic-bezier(0.4, 0, 0.2, 1),
                    box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
                min-height: 200px;
                padding: 0;

                &:hover {
                    box-shadow: var(--mat-sys-level3);
                    cursor: pointer;
                    transform: scale(1.015);
                }

                &-logo {
                    position: absolute;
                    right: 20px;
                    top: 20px;
                    padding: 16px;
                    z-index: 9;

                    &-icon {
                        font-size: 70px;
                        width: 1em;
                        height: 1em;
                    }
                }

                &-title {
                    padding: 16px;
                    margin-bottom: 0;
                    z-index: 9999;

                    h1 {
                        width: 80%;
                        font: var(--mat-sys-headline-medium);
                        margin: 0;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                        overflow: hidden;
                    }
                }

                &-subtitle {
                    z-index: 9999;
                    padding: 16px;
                    flex: 1 0 auto;

                    .adf-line-clamp {
                        position: relative;
                        line-height: 1.25;
                        padding: 0;
                        overflow: hidden;
                        text-overflow: ellipsis;
                    }
                }

                &-actions:has(.adf-app-listgrid-item-card-actions-icon) {
                    padding: 0 16px 16px;
                    border-top: 1px solid var(--mat-sys-outline-variant);
                    min-height: 48px;
                    box-sizing: border-box;
                    margin-left: 0;
                    margin-right: 0;

                    &:last-child {
                        margin-bottom: 0;
                    }
                }
            }
        }
    }
}
