/* -------------------------------------------
    Gutenberg Blocks
    - Base Style
    - WP Block Search & WC Block Search
    - Sidebar Widget
---------------------------------------------- */

@import '../config';
@import '../mixins';
@import '../direction';

// Base Style
.alignleft {
    float: left;
    clear: both;
    margin-#{$right}: 1.5em
}

.alignright {
    float: right;
    clear: both;
    margin-#{$left}: 1.5em
}

.aligncenter {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    clear: both
}

ul.aligncenter,
ol.aligncenter {
    list-style-position: inside;
    padding: 0;
}

.alignfull,
.alignwide {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.alignwide {
    width: 90%;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

img.aligncenter,
.wp-caption.aligncenter {
    display: block;
    margin: 0 auto
}

.alignnone {
    display: block
}

.main-content>.wp-block-columns:not(.alignwide):not(.alignfull) {
    max-width: var(--alpha-container-width);
}

.main-content>.alignwide {
    max-width: var(--alpha-container-fluid-width);
    padding-left: 30px;
    padding-right: 30px;
    margin-left: auto;
    margin-right: auto;
}

.main-content>.wp-block-columns:not(.alignfull) {
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
}

@include mq(1280px) {
    .main-content>.wp-block-columns:not(.alignwide):not(.alignfull) {
        max-width: 1280px;
        padding-left: 0;
        padding-right: 0;
        margin-left: auto;
        margin-right: auto;
    }
}

@include mq(1820px) {
    .main-content>.alignwide.wp-block-columns {
        max-width: 1800px;
        padding-left: 0;
        padding-right: 0;
        margin-left: auto;
        margin-right: auto;
    }
}

.container,
.container-fluid {
    .wp-block-columns:not(.alignfull) {
        padding-left: 0;
        padding-right: 0;
    }

    .main-content>.wp-block-columns {
        margin-left: -10px;
        margin-right: -10px;
    }

    .alignwide {
        padding-left: 0;
        padding-right: 0;
    }
}

.container-fluid .main-content> {
    @include mq(1300px) {
        .wp-block-columns:not(.alignwide):not(.alignfull) {
            margin-left: auto;
            margin-right: auto;
        }
    }
}

.wp-block-columns {
    gap: 0;
    margin-left: -10px;
    margin-right: -10px;
}

@include mq(xs, max) {
    .wp-block-columns:not(.alignfull) {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

.wp-block-columns>.wp-block-column {
    padding-left: 15px;
    padding-right: 15px;
    margin-#{$left}: 0 !important;
}

.wp-block-columns {
    display: flex;
    flex-wrap: wrap;
    margin-left: -15px;
    margin-right: -15px;
}

.wp-block-column {
    padding-left: 15px;
    padding-right: 15px;
}

// WP Block Search & WC Block Search
.wp-block-search,
.post-password-form {
    margin-bottom: 2rem;
    font-size: 0.85em;

    input {
        font-size: inherit;
    }
}

.post-password-form {
    &>p {
        display: flex;
        align-items: flex-end;
    }

    input[type=submit] {
        padding: .9rem .6rem;
    }
}

.wp-block-search {
    &.wp-block-search__button-inside {
        .wp-block-search__inside-wrapper {
            border: 1px solid var(--alpha-change-border-color);

            .wp-block-search__input {
                border: none;
                padding: side-values(0 0 0 10px);
            }
        }

        .wp-block-search__button,
        .wp-block-search__button:hover {
            background: transparent;
        }
    }

    .wp-block-search__inside-wrapper {
        display: flex;
        flex-wrap: nowrap;
    }

    .wp-block-search__button {
        background: none;
        color: var(--alpha-change-color-dark-1);
        border: 0;

        svg {
            display: none;
        }

        &:before {
            display: inline-block;
            vertical-align: middle;
            font-family: $framework-font;
            font-size: 1.11em;
            font-weight: 400;
            line-height: 1em;
            padding-#{$right}: 5px;
            content: "\e97e";
        }

        &:hover {
            color: var(--alpha-primary-color);
        }

        &.has-icon:before {
            padding-#{$right}: 0;
        }
    }

    &.wp-block-search__button-inside .wp-block-search__button,
    .wp-block-search__button {
        padding: .125em .5em;
    }
}

.wp-block-search__button.has-icon {
    line-height: 0;
}

.wp-block-search .wp-block-search__label,
.wc-block-product-search__label {
    display: block;
    padding: 13px 0;
    color: var(--alpha-heading-color, var(--alpha-body-color));
    font-size: 16px;
    font-weight: 600;
}

.wp-block-search.wp-block-search__button-inside .wp-block-search__inside-wrapper {
    max-width: 100%;
    padding: 4px;
    border-radius: var(--alpha-border-radius);
    border-color: var(--alpha-change-border-color);

    .has-icon {
        border-width: 0;
    }
}

.wp-block-search .wp-block-search__input,
.wc-block-product-search .wc-block-product-search__field,
.woocommerce-product-search input,
.post-password-form input[type="password"] {
    width: 100%;
    min-height: 3.6rem;
    padding: .65em 1.53em;

    &.form-solid {
        background-color: var(--alpha-change-color-light-1);
        border: 0;
        color: #8d8d8d;
    }
}

.wp-block-search button:not(.has-icon),
.woocommerce-product-search button,
.post-password-form input[type="submit"] {
    display: inline-block;
    min-width: 9rem;
    flex: 0 0 auto;
    border-width: 0;
    background-color: var(--alpha-primary-color);
    color: var(--alpha-change-color-light-1);
    outline: 0;
    text-align: center;
    transition: color .3s, border-color .3s, background-color .3s, box-shadow .3s;
    white-space: nowrap;

    &:hover {
        background-color: var(--alpha-primary-color-hover);
    }
}

.wp-block-search button:not(.has-icon):hover {
    color: #fff
}

.wp-block-search button.has-icon,
.wc-block-product-search__button {
    color: var(--alpha-change-color-dark-1);
    font-size: 1.285714em;
    background: transparent;
    border: 1px solid var(--alpha-change-border-color);

    svg {
        display: none;
    }

    &::before {
        content: "\e97e";
        font-family: $framework-font;
    }

    &:hover,
    &:focus {
        color: var(--alpha-primary-color);
    }
}

.wc-block-product-search {
    font-size: 0.922em;

    .wc-block-product-search__button {
        overflow: inherit;
    }
}

.widget_product_search .woocommerce-product-search {
    display: flex;
}

.wp-block-search__icon-button .wp-block-search__input {
    padding: 1.2rem 2rem;
}

.wp-block-search__text-button .wp-block-search__input {
    border-radius: 0;
}

// Sidebar Widget
.wp-block-latest-comments__comment {
    line-height: 1.1;
}

.wp-block-latest-comments .avatar,
.wp-block-latest-comments__comment-avatar {
    height: auto !important;
    padding-top: 0 !important;
}

.sidebar {
    .widget_block {
        margin-bottom: 1rem;

        h2,
        [class*="wp-block-woocommerce-"] h3 {
            font-size: 1.8rem;
            padding: 1.6rem 0;
            margin-bottom: 0;
        }
    }

    @include mq(lg) {
        .widget:first-child .wp-block-group__inner-container>h2 {
            padding-top: 0;
        }
    }

    .wp-block-latest-comments {
        padding-#{$left}: 0;
        margin: 0;
    }

    .wp-block-latest-comments__comment-date {
        margin-top: .5rem;
    }

    .widget {
        >:last-child {
            margin-bottom: 3.7rem; // @issue

            &.wp-block-group {
                margin-bottom: 0;

                >.wp-block-group__inner-container {
                    >:last-child {
                        margin-bottom: 3.7rem;
                    }

                    >ul:last-child {
                        margin: -.4rem 0 3rem; // @issue
                    }
                }
            }
        }

        >ul:last-child {
            margin-bottom: 3rem; // @issue
        }

        &:last-child {
            .wp-block-group>.wp-block-group__inner-container {
                >:last-child {
                    margin-bottom: 0;
                }
            }
        }
    }
}

.widget-block .alpha-block {
    text-align: initial;
}