@use 'mixins';

.contain-image {
    display: flex;
    width: 100%;
    max-width: max-content;
    max-height: 540px;
    img {
        object-fit: contain;
        width: 100%;
        height: auto;
    }
}

.page-new {
    background-color: var(--color-body);
    display: flex;
    flex-direction: column;
    overflow-y: scroll;
    @include mixins.mobile {
        padding-bottom: var(--gap);
        .card,
        .card-sub {
            border-left: var(--card-border-left);
            border-right: var(--card-border-right);
            border-radius: var(--border-radius);
        }
    }
    .page-new-content {
        max-width: 990px;
        width: 100%;
        padding: 0 var(--gap);
        align-self: center;
        justify-self: center;
        display: grid;
        grid-template-columns: 660px 1fr;
        grid-template-rows: 1fr;
        @include mixins.mobile() {
            width: 100%;
            grid-template-columns: 1fr;
        }
        .page-new-content-post {
            margin-right: var(--gap);
            @include mixins.mobile() {
                margin-right: 0;
            }
        }
        .card-rules {
            align-self: flex-start;
            @include mixins.mobile() {
                margin-top: var(--gap);
            }
        }
        .page-new-select {
            position: relative;
            width: 100%;
            margin-bottom: var(--gap);
            --input-padding: 14px;
            img,
            svg {
                position: absolute;
                width: 20px;
                height: 20px;
                top: 50%;
                left: 8px;
                transform: translateY(-50%);
            }
            img {
                border-radius: 50%;
            }
            .page-new-select-input {
                position: relative;
                input {
                    width: 100%;
                    background-color: var(--color-bg);
                    padding: var(--input-padding);
                    padding-left: 42px;
                    &:hover {
                        border-color: transparent;
                    }
                    &:focus {
                        border-color: var(--color-input-border-focus);
                    }
                    &.is-active {
                        border-bottom-left-radius: 0;
                        border-bottom-right-radius: 0;
                    }
                }
            }
            .page-new-select-suggest {
                display: none;
                z-index: 100;
                flex-direction: column;
                position: absolute;
                top: 100%;
                left: 0;
                width: 100%;
                border: 2px solid var(--color-input-border-focus);
                border-top: none;
                border-radius: var(--border-radius);
                border-top-left-radius: 0;
                border-top-right-radius: 0;
                background: var(--color-bg);
                .page-new-select-suggest-item {
                    position: relative;
                    padding: 7px var(--input-padding) 7px var(--input-padding);
                    padding-left: 42px;
                    display: flex;
                    flex-direction: column;
                    cursor: pointer;
                    transition: all var(--t-time);
                    &:hover,
                    &.is-hovering {
                        background-color: rgba(var(--base-bg), 0.04);
                    }
                    .page-new-select-suggest-detail {
                        font-size: var(--fs-xs);
                        text-transform: uppercase;
                        opacity: 0.8;
                    }
                }
            }
            &.is-active {
                .page-new-select-suggest {
                    display: flex;
                }
            }
        }
        .page-new-form {
            --form-padding: 15px;
            --textarea-min-height: 300px;
            position: relative;
            width: 100%;
            display: flex;
            .page-new-tabs {
                width: 100%;
                // border-top-left-radius: var(--border-radius);
                // border-top-right-radius: var(--border-radius);
                display: grid;
                grid-template-columns: repeat(3, 1fr);
                border-bottom: 1px solid var(--color-card-border);
                &.is-two-tabs {
                    grid-template-columns: repeat(2, 1fr);
                }
                .pn-tabs-item {
                    display: flex;
                    justify-content: center;
                    border: none;
                    border-right: 1px solid var(--color-card-border);
                    padding: var(--gap) 0;
                    &:hover {
                        background-color: rgba(var(--base-bg), 0.04);
                    }
                    &.is-selected {
                        background-color: rgba(var(--base-fg), 0.048);
                    }
                    &:last-child {
                        border-right: none;
                    }
                }
                .page-new-icon-text {
                    color: var(--color-fg);
                }
                .page-new-icon-image {
                    color: var(--color-red);
                }
                .page-new-icon-link {
                    color: var(--color-brand);
                }
            }
            .page-new-form-disabled {
                position: absolute;
                background: rgba(var(--base-fg), 0.05);
                left: 0;
                right: 0;
                top: -2px;
                bottom: 0;
                border-radius: var(--border-radius);
                display: flex;
                align-items: center;
                justify-content: center;
                text-align: center;
                padding: var(--gap);
            }
            textarea:not(.page-new-image-alt) {
                padding: 0;
                background-color: transparent;
                border: none;
                overflow: hidden;
                margin: var(--form-padding);
            }
            textarea.page-new-post-title {
                font-size: var(--fs-xl);
                font-weight: 600;
                margin-bottom: 0;
                word-break: break-word;
            }
            .page-new-post-body,
            .page-new-image-upload {
                min-height: var(--textarea-min-height);
                margin: var(--form-padding);
            }
            .page-new-image-upload {
                display: grid;
                grid-template-columns: 1fr 1fr;
                grid-gap: 8px;
                > * {
                    aspect-ratio: 1 / 1;
                }
                &:not(.has-no-images) {
                    .page-new-image-drop {
                        height: unset;
                    }
                }
                &.has-no-images {
                    grid-template-columns: 1fr;
                }
                &.is-disabled {
                    opacity: 0.8;
                    .page-new-image-drop {
                        cursor: unset;
                    }
                }
                @include mixins.mobile() {
                    grid-template-columns: 1fr;
                    > * {
                        aspect-ratio: unset;
                    }
                    .page-new-image-drop {
                        height: 300px !important;
                    }
                }
                .page-new-image-drop {
                    width: 100%;
                    height: var(--textarea-min-height);
                    border: 1px solid rgb(var(--base-fg), 0.2);
                    border-radius: var(--border-radius);
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    text-align: center;
                    padding: var(--gap);
                    cursor: pointer;
                    transition: all 0.2s;
                    &:hover,
                    &.is-dropping {
                        background-color: rgba(var(--base-bg), 0.028);
                    }
                    &.is-disabled {
                        cursor: initial;
                    }
                    .page-new-image-text {
                        display: flex;
                        flex-direction: column;
                        align-items: center;
                        .is-small {
                            font-size: var(--fs-xs);
                        }
                    }
                }
                .page-new-image {
                    position: relative;
                    display: flex;
                    flex-direction: column;
                    border-radius: var(--border-radius);
                    --button-background: rgba(0, 0, 0, 0.7);
                    --color: #fff;
                    .contain-image {
                        max-height: none;
                        .image,
                        img {
                            border-radius: var(--border-radius);
                        }
                    }
                    .button-close {
                        position: absolute;
                        top: 8px;
                        right: 8px;
                        background-color: var(--button-background);
                        padding: 6px;
                        border-radius: 50%;
                        border: 1px solid rgba(var(--base-fg), 0.2);
                        color: var(--color);
                    }
                    .button-alt-text {
                        position: absolute;
                        top: 8px;
                        left: 8px;
                        background-color: var(--button-background);
                        color: var(--color);
                    }
                    .button-close,
                    .button-alt-text {
                        &:hover {
                            background-color: #000;
                        }
                    }
                }
                .page-new-image-uploading {
                    .page-new-uploading-text {
                        flex-shrink: 0;
                    }
                }
                .page-new-image-deleted {
                    width: 100%;
                    height: var(--textarea-min-height);
                    border: 1px solid lightgray;
                    border-radius: var(--border-radius);
                    background-color: rgba(var(--base-bg), 0.028);
                    color: gray;
                    svg {
                        width: 60px;
                        height: auto;
                    }
                }
            }
        }
        .page-new-rules {
            height: max-content;
        }
        .page-new-buttons {
            grid-column: 1 / -1;
            display: flex;
            margin: var(--gap) 0;
            > * {
                margin-left: 4px;
                margin-right: var(--gap);
            }
            @include mixins.mobile() {
                flex-direction: row-reverse;
            }
        }
    }
    .new-page-user-group {
        display: flex;
        > * {
            margin-right: var(--gap);
            &:last-child {
                margin-right: 0;
            }
        }
        @include mixins.mobile() {
            flex-direction: column;
            > * {
                margin-right: 0;
                margin-bottom: var(--gap);
                &:last-child {
                    margin-bottom: 0;
                }
            }
        }
    }
    .new-page-help,
    .new-page-user-group {
        margin-top: var(--gap);
        margin-left: 4px;
    }
    .new-page-sidebar {
        @include mixins.mobile {
            margin-top: var(--gap);
        }
        > * {
            margin-bottom: var(--gap);
        }
    }
}

.modal {
    .modal-add-alt-text {
        width: auto;
        max-width: auto;
        .modal-card-content {
            img {
                border-radius: var(--border-radius);
            }
            > * {
                margin-bottom: var(--gap);
                &:last-child {
                    margin-bottom: 0;
                }
            }
            textarea {
                min-height: 100px;
            }
        }
    }
}
