/* Typography options container */
.digiblocks-typography-options {
    margin-bottom: 24px;

    .digiblocks-select-control .components-select-control .components-flex,
    .digiblocks-popover > .components-base-control {
        display: grid;
        grid-template-columns: 50% 50%;
        align-items: center;
        gap: 0;

        label {
            margin-bottom: 0;
        }
    }
}

/* Typography toggle button and header */
.digiblocks-control-popup__options--action-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

body .components-button.digiblocks-pencil-button {
    background: transparent !important;
    border: none;
    cursor: pointer;
    padding: 2px;
    margin: 0;
    height: 28px;
    width: 28px;
    padding: 5px;
    border: 1px solid #e6e7e9;
    border-radius: 14px;
    color: #50575e;

    .dashicons-edit {
        font-size: 15px;
        line-height: 20px;
        outline: none;
    }

    &:hover {
        color: #007cba;
    }

    &.is-pressed {
        color: #007cba;
        background-color: #fff;
    }
}

/* Typography advanced settings panel */
.digiblocks-popover {
    position: relative;
    top: 5px;
    width: 100%;
    border-radius: 2px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    background: #fff;

    &::before {
        content: "";
        position: absolute;
        inset-block-start: -16px;
        inset-inline-end: 8px;
        border: 8px solid transparent;
        border-block-end-color: #fff;
    }
}

/* Font family control */
.digiblocks-font-family-searchable-select__wrapper {
    margin-bottom: 15px;

    .components-input-control__label {
        color: #50575e;
        font-size: 13px !important;
        line-height: 1.4em !important;
        margin-bottom: 10px;
        text-transform: none !important;
        font-weight: 400 !important;
    }
}

/* Custom font family select with search and preview */
.digiblocks-font-family-select {
    position: relative;
    margin-bottom: 16px;

    .digiblocks-font-family-select__field {
        display: flex;
        flex-direction: column;
    }

    .digiblocks-font-family-select__label {
        margin-bottom: 8px;
        color: #50575e;
        font-size: 13px;
        line-height: 1.4em;
        text-transform: none;
        font-weight: 400;
    }

    .digiblocks-font-family-select__control {
        position: relative;
    }

    .digiblocks-font-family-select__trigger {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-height: 30px;
        height: 30px;
        padding: 0px 6px;
        background: #fff;
        border: 1px solid #d5d5d5;
        border-radius: 2px;
        cursor: pointer;
        transition: border-color 0.15s ease;
        font-size: 13px;
        line-height: 1.4;
        color: #50575e;

        &:focus {
            border-color: #2271b1;
        }

        &[aria-expanded="true"] {
            border-color: #2271b1;

            svg {
                transform: rotate(180deg);
            }
        }

        svg {
            flex-shrink: 0;
            margin-left: 8px;
            color: #1e1e1e;
            transition: transform 0.2s ease;
        }
    }

    .digiblocks-font-family-select__value {
        flex: 1;
        text-align: left;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .digiblocks-font-family-select__dropdown {
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        right: 0;
        background: #fff;
        border: 1px solid #d5d5d5;
        border-radius: 2px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
        z-index: 1000;
        max-height: 320px;
        display: flex;
        flex-direction: column;
    }

    .digiblocks-font-family-select__search {
        padding: 8px;
        border-bottom: 1px solid #ddd;
        flex-shrink: 0;
    }

    .digiblocks-font-family-select__search-input {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid #d5d5d5;
        border-radius: 2px;
        font-size: 13px;
        line-height: 1.4;
        outline: none;
        transition: border-color 0.15s ease;

        &:focus {
            border-color: #2271b1;
        }

        &::placeholder {
            color: #757575;
        }
    }

    .digiblocks-font-family-select__list {
        overflow-y: auto;
        overflow-x: hidden;
        flex: 1;
        min-height: 0;

        &::-webkit-scrollbar {
            width: 12px;
        }

        &::-webkit-scrollbar-track {
            background: #f1f1f1;
        }

        &::-webkit-scrollbar-thumb {
            background: #ddd;
            border-radius: 6px;
            border: 3px solid #f1f1f1;

            &:hover {
                background: #ccc;
            }
        }
    }

    .digiblocks-font-option {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 10px 12px;
        border: none;
        background: transparent;
        text-align: left;
        cursor: pointer;
        transition: background-color 0.15s ease;
        font-size: 14px;
        line-height: 1.4;
        color: #1e1e1e;
        border-bottom: 1px solid #f0f0f0;

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

        &.is-selected {
            background-color: #f0f6fc;
            color: #2271b1;
        }

        svg {
            flex-shrink: 0;
            margin-left: 8px;
            color: #2271b1;
        }
    }

    .digiblocks-font-family-select__no-results {
        padding: 16px 12px;
        text-align: center;
        color: #757575;
        font-size: 13px;
    }

    @media (max-width: 782px) {
        .digiblocks-font-family-select__dropdown {
            max-height: 280px;
        }

        .digiblocks-font-option {
            padding: 12px;
            font-size: 16px;
        }

        .digiblocks-font-family-select__search-input {
            font-size: 16px;
            padding: 10px 12px;
        }
    }
}

/* Size type field tabs */
.digiblocks-size-type-field-tabs {
    margin-bottom: 15px;

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

/* Control header and label */
.digiblocks-control__header {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;

    .digiblocks-control__actions {
        gap: 0.25rem;
    }
}

.digiblocks-responsive-label-wrap {
    display: flex;
    align-items: center;
}

/* Select control layout */
.digiblocks-select-control {
    margin-bottom: 15px;

    &--layout-inline {
        .components-base-control__field {
            display: flex;
            flex-direction: column;
        }

        .components-base-control__label,
        .components-input-control__label {
            margin-bottom: 8px;
            color: #50575e;
            font-size: 13px !important;
            line-height: 1.4em !important;
            text-transform: none !important;
            font-weight: 400 !important;
        }
    }
}

body
    .digiblocks-popover
    .digiblocks-select-control
    select.components-select-control__input {
    color: #50575e;
    text-transform: capitalize;
    height: 30px;
    min-height: 30px;
    padding: 0px 20px 0px 6px;

    .components-input-control-suffix-wrapper {
        padding-inline-end: 6px;
    }
}

/* Typography decoration */
.digiblocks-typography-decoration {
    margin-bottom: 15px;
}

/* Make sure the dropdown menu is on top of other elements */
.components-popover.components-dropdown-menu__popover {
    z-index: 1000;
}
